feat: allow to disable standard pages (#33756)
* feat: allow to disable about and contact page * feat: change redirect to /404
This commit is contained in:
parent
79eb78db10
commit
27a68aaf8b
6 changed files with 26 additions and 7 deletions
|
|
@ -6,6 +6,7 @@
|
|||
"document_type": "Other",
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"is_disabled",
|
||||
"page_title",
|
||||
"company_introduction",
|
||||
"sb0",
|
||||
|
|
@ -75,6 +76,12 @@
|
|||
"fieldname": "team_members_subtitle",
|
||||
"fieldtype": "Small Text",
|
||||
"label": "Team Members Subtitle"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "is_disabled",
|
||||
"fieldtype": "Check",
|
||||
"label": "Disabled"
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-group",
|
||||
|
|
@ -82,7 +89,7 @@
|
|||
"index_web_pages_for_search": 1,
|
||||
"issingle": 1,
|
||||
"links": [],
|
||||
"modified": "2024-03-23 16:01:26.370657",
|
||||
"modified": "2025-08-22 15:56:33.957707",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Website",
|
||||
"name": "About Us Settings",
|
||||
|
|
@ -98,6 +105,7 @@
|
|||
"write": 1
|
||||
}
|
||||
],
|
||||
"row_format": "Dynamic",
|
||||
"sort_field": "creation",
|
||||
"sort_order": "DESC",
|
||||
"states": [],
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ class AboutUsSettings(Document):
|
|||
company_history_heading: DF.Data | None
|
||||
company_introduction: DF.TextEditor | None
|
||||
footer: DF.TextEditor | None
|
||||
is_disabled: DF.Check
|
||||
page_title: DF.Data | None
|
||||
team_members: DF.Table[AboutUsTeamMember]
|
||||
team_members_heading: DF.Data | None
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
"doctype": "DocType",
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"disable_contact_us",
|
||||
"introduction_section",
|
||||
"is_disabled",
|
||||
"forward_to_email",
|
||||
"heading",
|
||||
"introduction",
|
||||
|
|
@ -56,7 +56,6 @@
|
|||
"label": "Query Options"
|
||||
},
|
||||
{
|
||||
"collapsible": 1,
|
||||
"fieldname": "address",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Address"
|
||||
|
|
@ -120,16 +119,16 @@
|
|||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "disable_contact_us",
|
||||
"fieldname": "is_disabled",
|
||||
"fieldtype": "Check",
|
||||
"label": "Disable Contact Us Page"
|
||||
"label": "Disabled"
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-cog",
|
||||
"idx": 1,
|
||||
"issingle": 1,
|
||||
"links": [],
|
||||
"modified": "2025-05-15 07:19:31.401053",
|
||||
"modified": "2025-08-22 12:59:39.463182",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Website",
|
||||
"name": "Contact Us Settings",
|
||||
|
|
@ -145,6 +144,7 @@
|
|||
"write": 1
|
||||
}
|
||||
],
|
||||
"row_format": "Dynamic",
|
||||
"sort_field": "creation",
|
||||
"sort_order": "DESC",
|
||||
"states": [],
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ class ContactUsSettings(Document):
|
|||
forward_to_email: DF.Data | None
|
||||
heading: DF.Data | None
|
||||
introduction: DF.TextEditor | None
|
||||
is_disabled: DF.Check
|
||||
phone: DF.Data | None
|
||||
pincode: DF.Data | None
|
||||
query_options: DF.SmallText | None
|
||||
|
|
|
|||
|
|
@ -8,5 +8,7 @@ sitemap = 1
|
|||
|
||||
def get_context(context):
|
||||
context.doc = frappe.get_cached_doc("About Us Settings")
|
||||
|
||||
if context.doc.is_disabled:
|
||||
frappe.local.flags.redirect_location = "/404"
|
||||
raise frappe.Redirect
|
||||
return context
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@ sitemap = 1
|
|||
|
||||
def get_context(context):
|
||||
doc = frappe.get_doc("Contact Us Settings", "Contact Us Settings")
|
||||
if doc.is_disabled:
|
||||
frappe.local.flags.redirect_location = "/404"
|
||||
raise frappe.Redirect
|
||||
|
||||
if doc.query_options:
|
||||
query_options = [opt.strip() for opt in doc.query_options.replace(",", "\n").split("\n") if opt]
|
||||
|
|
@ -28,6 +31,10 @@ def get_context(context):
|
|||
@frappe.whitelist(allow_guest=True)
|
||||
@rate_limit(limit=1000, seconds=60 * 60)
|
||||
def send_message(sender, message, subject="Website Query"):
|
||||
doc = frappe.get_doc("Contact Us Settings", "Contact Us Settings")
|
||||
if doc.is_disabled:
|
||||
return
|
||||
|
||||
sender = validate_email_address(sender, throw=True)
|
||||
|
||||
message = escape_html(message)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue