fix: Move document_share_key_expiry to System Settings

- Having `document_share_key_expiry` on each doctype is overkill so kept it at System Settings
This commit is contained in:
Suraj Shetty 2022-02-07 13:42:28 +05:30
parent 24908e31a8
commit a0af8d577f
5 changed files with 13 additions and 24 deletions

View file

@ -5,7 +5,6 @@
"creation": "2013-02-18 13:36:19",
"description": "DocType is a Table / Form in the application.",
"doctype": "DocType",
"document_share_key_expiry": 90,
"document_type": "Document",
"engine": "InnoDB",
"field_order": [
@ -57,7 +56,6 @@
"color",
"show_preview_popup",
"show_name_in_global_search",
"document_share_key_expiry",
"email_settings_sb",
"default_email_template",
"column_break_51",
@ -584,13 +582,6 @@
"fieldname": "document_states_section",
"fieldtype": "Section Break",
"label": "Document States"
},
{
"default": "90",
"description": "Set number of days after which a Document Share Key will be expired",
"fieldname": "document_share_key_expiry",
"fieldtype": "Int",
"label": "Document Share Key Expiry (in Days)"
}
],
"icon": "fa fa-bolt",
@ -672,7 +663,7 @@
"link_fieldname": "reference_doctype"
}
],
"modified": "2021-12-28 03:19:19.033347",
"modified": "2022-02-07 03:03:03.847356",
"modified_by": "Administrator",
"module": "Core",
"name": "DocType",

View file

@ -4,7 +4,6 @@
"autoname": "format:DOCUMENT-SHARE-KEY-{########}",
"creation": "2022-01-14 13:40:49.487646",
"doctype": "DocType",
"document_share_key_expiry": 90,
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [

View file

@ -8,8 +8,7 @@ class DocumentShareKey(Document):
def before_insert(self):
self.key = frappe.generate_hash(length=32)
if not self.expires_on:
meta = frappe.get_meta("DocType", self.reference_doctype)
self.expires_on = frappe.utils.add_days(None, days=meta.get("document_share_key_expiry") or 90)
self.expires_on = frappe.utils.add_days(None, days=frappe.get_system_settings("document_share_key_expiry") or 90)
def is_expired(self):
return self.expires_on < frappe.utils.getdate()

View file

@ -1,7 +1,8 @@
{
"actions": [],
"creation": "2014-04-17 16:53:52.640856",
"creation": "2022-01-06 03:18:16.326761",
"doctype": "DocType",
"document_share_key_expiry": 90,
"document_type": "System",
"engine": "InnoDB",
"field_order": [
@ -35,6 +36,7 @@
"security",
"session_expiry",
"session_expiry_mobile",
"document_share_key_expiry",
"column_break_13",
"deny_multiple_sessions",
"allow_login_using_mobile_number",
@ -485,12 +487,19 @@
"fieldtype": "Select",
"label": "First Day of the Week",
"options": "Sunday\nMonday\nTuesday\nWednesday\nThursday\nFriday\nSaturday"
},
{
"default": "90",
"description": "Set number of days after which a Document Share Key will be expired",
"fieldname": "document_share_key_expiry",
"fieldtype": "Int",
"label": "Document Share Key Expiry (in Days)"
}
],
"icon": "fa fa-cog",
"issingle": 1,
"links": [],
"modified": "2022-01-04 11:28:34.881192",
"modified": "2022-02-07 03:07:20.782827",
"modified_by": "Administrator",
"module": "Core",
"name": "System Settings",

View file

@ -3,7 +3,6 @@
"autoname": "DL.####",
"creation": "2013-01-29 17:55:08",
"doctype": "DocType",
"document_share_key_expiry": 90,
"document_type": "Document",
"editable_grid": 1,
"engine": "InnoDB",
@ -32,7 +31,6 @@
"default_print_format",
"column_break_29",
"show_preview_popup",
"document_share_key_expiry",
"email_settings_section",
"default_email_template",
"column_break_26",
@ -298,13 +296,6 @@
"fieldtype": "Table",
"label": "States",
"options": "DocType State"
},
{
"default": "90",
"description": "Set number of days after which a Document Share Key will be expired",
"fieldname": "document_share_key_expiry",
"fieldtype": "Int",
"label": "Document Share Key Expiry (in Days)"
}
],
"hide_toolbar": 1,