from . import __version__ as app_version

app_name = "influxframework"
app_title = "InfluxFramework Framework"
app_publisher = "InfluxFramework Technologies"
app_description = "Full stack web framework with Python, Javascript, MariaDB, Redis, Node"
source_link = "https://github.com/influxframework/influxframework"
app_license = "MIT"
app_logo_url = "/assets/influxframework/images/influxframework-framework-logo.svg"

develop_version = "14.x.x-develop"

app_email = "developers@influxframework.io"

docs_app = "influxframework_docs"

translator_url = "https://translate.influxerp.com"

before_install = "influxframework.utils.install.before_install"
after_install = "influxframework.utils.install.after_install"

page_js = {"setup-wizard": "public/js/influxframework/setup_wizard.js"}

# website
app_include_js = [
	"libs.bundle.js",
	"desk.bundle.js",
	"list.bundle.js",
	"form.bundle.js",
	"controls.bundle.js",
	"report.bundle.js",
]
app_include_css = [
	"desk.bundle.css",
	"report.bundle.css",
]

doctype_js = {
	"Web Page": "public/js/influxframework/utils/web_template.js",
	"Website Settings": "public/js/influxframework/utils/web_template.js",
}

web_include_js = ["website_script.js"]

web_include_css = []

email_css = ["email.bundle.css"]

website_route_rules = [
	{"from_route": "/blog/<category>", "to_route": "Blog Post"},
	{"from_route": "/kb/<category>", "to_route": "Help Article"},
	{"from_route": "/newsletters", "to_route": "Newsletter"},
	{"from_route": "/profile", "to_route": "me"},
	{"from_route": "/app/<path:app_path>", "to_route": "app"},
]

website_redirects = [
	{"source": r"/desk(.*)", "target": r"/app\1"},
]

base_template = "templates/base.html"

write_file_keys = ["file_url", "file_name"]

notification_config = "influxframework.core.notifications.get_notification_config"

before_tests = "influxframework.utils.install.before_tests"

email_append_to = ["Event", "ToDo", "Communication"]

calendars = ["Event"]

leaderboards = "influxframework.desk.leaderboard.get_leaderboards"

# login

on_session_creation = [
	"influxframework.core.doctype.activity_log.feed.login_feed",
	"influxframework.core.doctype.user.user.notify_admin_access_to_system_manager",
]

on_logout = (
	"influxframework.core.doctype.session_default_settings.session_default_settings.clear_session_defaults"
)

# permissions

permission_query_conditions = {
	"Event": "influxframework.desk.doctype.event.event.get_permission_query_conditions",
	"ToDo": "influxframework.desk.doctype.todo.todo.get_permission_query_conditions",
	"User": "influxframework.core.doctype.user.user.get_permission_query_conditions",
	"Dashboard Settings": "influxframework.desk.doctype.dashboard_settings.dashboard_settings.get_permission_query_conditions",
	"Notification Log": "influxframework.desk.doctype.notification_log.notification_log.get_permission_query_conditions",
	"Dashboard": "influxframework.desk.doctype.dashboard.dashboard.get_permission_query_conditions",
	"Dashboard Chart": "influxframework.desk.doctype.dashboard_chart.dashboard_chart.get_permission_query_conditions",
	"Number Card": "influxframework.desk.doctype.number_card.number_card.get_permission_query_conditions",
	"Notification Settings": "influxframework.desk.doctype.notification_settings.notification_settings.get_permission_query_conditions",
	"Note": "influxframework.desk.doctype.note.note.get_permission_query_conditions",
	"Kanban Board": "influxframework.desk.doctype.kanban_board.kanban_board.get_permission_query_conditions",
	"Contact": "influxframework.contacts.address_and_contact.get_permission_query_conditions_for_contact",
	"Address": "influxframework.contacts.address_and_contact.get_permission_query_conditions_for_address",
	"Communication": "influxframework.core.doctype.communication.communication.get_permission_query_conditions_for_communication",
	"Workflow Action": "influxframework.workflow.doctype.workflow_action.workflow_action.get_permission_query_conditions",
	"Prepared Report": "influxframework.core.doctype.prepared_report.prepared_report.get_permission_query_condition",
}

has_permission = {
	"Event": "influxframework.desk.doctype.event.event.has_permission",
	"ToDo": "influxframework.desk.doctype.todo.todo.has_permission",
	"User": "influxframework.core.doctype.user.user.has_permission",
	"Note": "influxframework.desk.doctype.note.note.has_permission",
	"Dashboard Chart": "influxframework.desk.doctype.dashboard_chart.dashboard_chart.has_permission",
	"Number Card": "influxframework.desk.doctype.number_card.number_card.has_permission",
	"Kanban Board": "influxframework.desk.doctype.kanban_board.kanban_board.has_permission",
	"Contact": "influxframework.contacts.address_and_contact.has_permission",
	"Address": "influxframework.contacts.address_and_contact.has_permission",
	"Communication": "influxframework.core.doctype.communication.communication.has_permission",
	"Workflow Action": "influxframework.workflow.doctype.workflow_action.workflow_action.has_permission",
	"File": "influxframework.core.doctype.file.file.has_permission",
	"Prepared Report": "influxframework.core.doctype.prepared_report.prepared_report.has_permission",
}

has_website_permission = {
	"Address": "influxframework.contacts.doctype.address.address.has_website_permission"
}

jinja = {
	"methods": "influxframework.utils.jinja_globals",
	"filters": [
		"influxframework.utils.data.global_date_format",
		"influxframework.utils.markdown",
		"influxframework.website.utils.get_shade",
		"influxframework.website.utils.abs_url",
	],
}

standard_queries = {"User": "influxframework.core.doctype.user.user.user_query"}

doc_events = {
	"*": {
		"after_insert": [
			"influxframework.event_streaming.doctype.event_update_log.event_update_log.notify_consumers"
		],
		"on_update": [
			"influxframework.desk.notifications.clear_doctype_notifications",
			"influxframework.core.doctype.activity_log.feed.update_feed",
			"influxframework.workflow.doctype.workflow_action.workflow_action.process_workflow_actions",
			"influxframework.automation.doctype.assignment_rule.assignment_rule.apply",
			"influxframework.core.doctype.file.utils.attach_files_to_document",
			"influxframework.event_streaming.doctype.event_update_log.event_update_log.notify_consumers",
			"influxframework.automation.doctype.assignment_rule.assignment_rule.update_due_date",
			"influxframework.core.doctype.user_type.user_type.apply_permissions_for_non_standard_user_type",
		],
		"after_rename": "influxframework.desk.notifications.clear_doctype_notifications",
		"on_cancel": [
			"influxframework.desk.notifications.clear_doctype_notifications",
			"influxframework.workflow.doctype.workflow_action.workflow_action.process_workflow_actions",
			"influxframework.event_streaming.doctype.event_update_log.event_update_log.notify_consumers",
		],
		"on_trash": [
			"influxframework.desk.notifications.clear_doctype_notifications",
			"influxframework.workflow.doctype.workflow_action.workflow_action.process_workflow_actions",
			"influxframework.event_streaming.doctype.event_update_log.event_update_log.notify_consumers",
		],
		"on_update_after_submit": [
			"influxframework.workflow.doctype.workflow_action.workflow_action.process_workflow_actions"
		],
		"on_change": [
			"influxframework.social.doctype.energy_point_rule.energy_point_rule.process_energy_points",
			"influxframework.automation.doctype.milestone_tracker.milestone_tracker.evaluate_milestone",
		],
	},
	"Event": {
		"after_insert": "influxframework.integrations.doctype.google_calendar.google_calendar.insert_event_in_google_calendar",
		"on_update": "influxframework.integrations.doctype.google_calendar.google_calendar.update_event_in_google_calendar",
		"on_trash": "influxframework.integrations.doctype.google_calendar.google_calendar.delete_event_from_google_calendar",
	},
	"Contact": {
		"after_insert": "influxframework.integrations.doctype.google_contacts.google_contacts.insert_contacts_to_google_contacts",
		"on_update": "influxframework.integrations.doctype.google_contacts.google_contacts.update_contacts_to_google_contacts",
	},
	"DocType": {
		"on_update": "influxframework.cache_manager.build_domain_restriced_doctype_cache",
	},
	"Page": {
		"on_update": "influxframework.cache_manager.build_domain_restriced_page_cache",
	},
}

scheduler_events = {
	"cron": {
		"0/15 * * * *": [
			"influxframework.oauth.delete_oauth2_data",
			"influxframework.website.doctype.web_page.web_page.check_publish_status",
			"influxframework.twofactor.delete_all_barcodes_for_users",
		]
	},
	"all": [
		"influxframework.email.queue.flush",
		"influxframework.email.doctype.email_account.email_account.pull",
		"influxframework.email.doctype.email_account.email_account.notify_unreplied",
		"influxframework.utils.global_search.sync_global_search",
		"influxframework.monitor.flush",
	],
	"hourly": [
		"influxframework.model.utils.link_count.update_link_count",
		"influxframework.model.utils.user_settings.sync_user_settings",
		"influxframework.utils.error.collect_error_snapshots",
		"influxframework.desk.page.backups.backups.delete_downloadable_backups",
		"influxframework.deferred_insert.save_to_db",
		"influxframework.desk.form.document_follow.send_hourly_updates",
		"influxframework.integrations.doctype.google_calendar.google_calendar.sync",
		"influxframework.email.doctype.newsletter.newsletter.send_scheduled_email",
		"influxframework.website.doctype.personal_data_deletion_request.personal_data_deletion_request.process_data_deletion_request",
	],
	"daily": [
		"influxframework.email.queue.set_expiry_for_email_queue",
		"influxframework.desk.notifications.clear_notifications",
		"influxframework.desk.doctype.event.event.send_event_digest",
		"influxframework.sessions.clear_expired_sessions",
		"influxframework.email.doctype.notification.notification.trigger_daily_alerts",
		"influxframework.website.doctype.personal_data_deletion_request.personal_data_deletion_request.remove_unverified_record",
		"influxframework.desk.form.document_follow.send_daily_updates",
		"influxframework.social.doctype.energy_point_settings.energy_point_settings.allocate_review_points",
		"influxframework.integrations.doctype.google_contacts.google_contacts.sync",
		"influxframework.automation.doctype.auto_repeat.auto_repeat.make_auto_repeat_entry",
		"influxframework.automation.doctype.auto_repeat.auto_repeat.set_auto_repeat_as_completed",
		"influxframework.email.doctype.unhandled_email.unhandled_email.remove_old_unhandled_emails",
		"influxframework.core.doctype.prepared_report.prepared_report.delete_expired_prepared_reports",
		"influxframework.core.doctype.log_settings.log_settings.run_log_clean_up",
		"influxframework.utils.subscription.enable_manage_subscription",
	],
	"daily_long": [
		"influxframework.integrations.doctype.dropbox_settings.dropbox_settings.take_backups_daily",
		"influxframework.utils.change_log.check_for_update",
		"influxframework.integrations.doctype.s3_backup_settings.s3_backup_settings.take_backups_daily",
		"influxframework.email.doctype.auto_email_report.auto_email_report.send_daily",
		"influxframework.integrations.doctype.google_drive.google_drive.daily_backup",
	],
	"weekly_long": [
		"influxframework.integrations.doctype.dropbox_settings.dropbox_settings.take_backups_weekly",
		"influxframework.integrations.doctype.s3_backup_settings.s3_backup_settings.take_backups_weekly",
		"influxframework.desk.form.document_follow.send_weekly_updates",
		"influxframework.social.doctype.energy_point_log.energy_point_log.send_weekly_summary",
		"influxframework.integrations.doctype.google_drive.google_drive.weekly_backup",
	],
	"monthly": [
		"influxframework.email.doctype.auto_email_report.auto_email_report.send_monthly",
		"influxframework.social.doctype.energy_point_log.energy_point_log.send_monthly_summary",
	],
	"monthly_long": [
		"influxframework.integrations.doctype.s3_backup_settings.s3_backup_settings.take_backups_monthly"
	],
}

get_translated_dict = {
	("doctype", "System Settings"): "influxframework.geo.country_info.get_translated_dict",
	("page", "setup-wizard"): "influxframework.geo.country_info.get_translated_dict",
}

sounds = [
	{"name": "email", "src": "/assets/influxframework/sounds/email.mp3", "volume": 0.1},
	{"name": "submit", "src": "/assets/influxframework/sounds/submit.mp3", "volume": 0.1},
	{"name": "cancel", "src": "/assets/influxframework/sounds/cancel.mp3", "volume": 0.1},
	{"name": "delete", "src": "/assets/influxframework/sounds/delete.mp3", "volume": 0.05},
	{"name": "click", "src": "/assets/influxframework/sounds/click.mp3", "volume": 0.05},
	{"name": "error", "src": "/assets/influxframework/sounds/error.mp3", "volume": 0.1},
	{"name": "alert", "src": "/assets/influxframework/sounds/alert.mp3", "volume": 0.2},
	# {"name": "chime", "src": "/assets/influxframework/sounds/chime.mp3"},
]

setup_wizard_exception = [
	"influxframework.desk.page.setup_wizard.setup_wizard.email_setup_wizard_exception",
	"influxframework.desk.page.setup_wizard.setup_wizard.log_setup_wizard_exception",
]

before_migrate = []
after_migrate = ["influxframework.website.doctype.website_theme.website_theme.after_migrate"]

otp_methods = ["OTP App", "Email", "SMS"]

user_data_fields = [
	{"doctype": "Access Log", "strict": True},
	{"doctype": "Activity Log", "strict": True},
	{"doctype": "Comment", "strict": True},
	{
		"doctype": "Contact",
		"filter_by": "email_id",
		"redact_fields": ["first_name", "last_name", "phone", "mobile_no"],
		"rename": True,
	},
	{"doctype": "Contact Email", "filter_by": "email_id"},
	{
		"doctype": "Address",
		"filter_by": "email_id",
		"redact_fields": [
			"address_title",
			"address_line1",
			"address_line2",
			"city",
			"county",
			"state",
			"pincode",
			"phone",
			"fax",
		],
	},
	{
		"doctype": "Communication",
		"filter_by": "sender",
		"redact_fields": ["sender_full_name", "phone_no", "content"],
	},
	{"doctype": "Communication", "filter_by": "recipients"},
	{"doctype": "Email Group Member", "filter_by": "email"},
	{"doctype": "Email Unsubscribe", "filter_by": "email", "partial": True},
	{"doctype": "Email Queue", "filter_by": "sender"},
	{"doctype": "Email Queue Recipient", "filter_by": "recipient"},
	{
		"doctype": "File",
		"filter_by": "attached_to_name",
		"redact_fields": ["file_name", "file_url"],
	},
	{
		"doctype": "User",
		"filter_by": "name",
		"redact_fields": [
			"email",
			"username",
			"first_name",
			"middle_name",
			"last_name",
			"full_name",
			"birth_date",
			"user_image",
			"phone",
			"mobile_no",
			"location",
			"banner_image",
			"interest",
			"bio",
			"email_signature",
		],
	},
	{"doctype": "Version", "strict": True},
]

global_search_doctypes = {
	"Default": [
		{"doctype": "Contact"},
		{"doctype": "Address"},
		{"doctype": "ToDo"},
		{"doctype": "Note"},
		{"doctype": "Event"},
		{"doctype": "Blog Post"},
		{"doctype": "Dashboard"},
		{"doctype": "Country"},
		{"doctype": "Currency"},
		{"doctype": "Newsletter"},
		{"doctype": "Letter Head"},
		{"doctype": "Workflow"},
		{"doctype": "Web Page"},
		{"doctype": "Web Form"},
	]
}

override_whitelisted_methods = {
	"influxframework.core.doctype.file.file.download_file": "download_file",
	"influxframework.core.doctype.file.file.unzip_file": "influxframework.core.api.file.unzip_file",
	"influxframework.core.doctype.file.file.get_attached_images": "influxframework.core.api.file.get_attached_images",
	"influxframework.core.doctype.file.file.get_files_in_folder": "influxframework.core.api.file.get_files_in_folder",
	"influxframework.core.doctype.file.file.get_files_by_search_text": "influxframework.core.api.file.get_files_by_search_text",
	"influxframework.core.doctype.file.file.get_max_file_size": "influxframework.core.api.file.get_max_file_size",
	"influxframework.core.doctype.file.file.create_new_folder": "influxframework.core.api.file.create_new_folder",
	"influxframework.core.doctype.file.file.move_file": "influxframework.core.api.file.move_file",
	"influxframework.core.doctype.file.file.zip_files": "influxframework.core.api.file.zip_files",
}
