feat: cookie policy

This commit is contained in:
Jannat Patel
2022-03-09 14:32:50 +05:30
parent 3bdf6df70d
commit fb72704a33
5 changed files with 57 additions and 25 deletions

View File

@@ -80,10 +80,10 @@
"in_standard_filter": 0,
"insert_after": "country",
"is_virtual": 0,
"label": "Acceptance for Terms of Use and/or Privacy Policy",
"label": "Acceptance for Terms and/or Policies",
"length": 0,
"mandatory_depends_on": null,
"modified": "2021-12-31 19:15:34.932910",
"modified": "2021-12-31 19:15:34.932911",
"module": null,
"name": "User-verify_terms",
"no_copy": 0,

View File

@@ -185,7 +185,8 @@ jinja = {
"school.lms.utils.get_initial_members",
"school.lms.utils.get_sorted_reviews",
"school.lms.utils.is_instructor",
"school.lms.utils.convert_number_to_character"
"school.lms.utils.convert_number_to_character",
"school.lms.utils.get_signup_optin_checks"
],
"filters": []
}

View File

@@ -13,9 +13,12 @@
"signup_settings_section",
"terms_of_use",
"terms_page",
"column_break_12",
"column_break_9",
"privacy_policy",
"privacy_policy_page",
"column_break_12",
"cookie_policy",
"cookie_policy_page",
"mentor_request_section",
"mentor_request_creation",
"mentor_request_status_update"
@@ -96,17 +99,36 @@
"fieldname": "privacy_policy_page",
"fieldtype": "Link",
"label": "Privacy Policy Page",
"mandatory_depends_on": "privacy_policy",
"options": "Web Page"
},
{
"fieldname": "column_break_12",
"fieldtype": "Column Break"
},
{
"fieldname": "column_break_9",
"fieldtype": "Column Break"
},
{
"default": "0",
"fieldname": "cookie_policy",
"fieldtype": "Check",
"label": "Show Cookie Policy on Signup"
},
{
"depends_on": "cookie_policy",
"fieldname": "cookie_policy_page",
"fieldtype": "Link",
"label": "Cookie Policy Page",
"mandatory_depends_on": "cookie_policy",
"options": "Web Page"
}
],
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2022-02-23 16:15:28.586903",
"modified": "2022-03-09 12:40:27.464136",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Settings",

View File

@@ -3,6 +3,7 @@ import frappe
from frappe.utils import flt, cint, cstr
from school.lms.md import markdown_to_html
import string
from frappe import _
RE_SLUG_NOTALLOWED = re.compile("[^a-z0-9]+")
@@ -296,3 +297,30 @@ def is_instructor(course):
def convert_number_to_character(number):
return string.ascii_uppercase[number]
def get_signup_optin_checks():
mapper = frappe._dict({
"terms_of_use": {
"page_name": "terms_page",
"title": _("Terms of Use")
},
"privacy_policy": {
"page_name": "privacy_policy_page",
"title": _("Privacy Policy")
},
"cookie_policy": {
"page_name": "cookie_policy_page",
"title": _("Cookie Policy")
}
})
checks = ["terms_of_use", "privacy_policy", "cookie_policy"]
links = []
for check in checks:
if frappe.db.get_single_value("LMS Settings", check):
page = frappe.db.get_single_value("LMS Settings", mapper[check].get("page_name"))
route = frappe.db.get_value("Web Page", page, "route")
links.append("<a href='/" + route + "'>" + mapper[check].get("title") + "</a>")
return (", ").join(links)

View File

@@ -10,24 +10,6 @@
<input type="email" id="signup_email" class="form-control"
placeholder="{{ _('jane@example.com') }}" required>
</div>
{% set terms_of_use = frappe.db.get_single_value("LMS Settings", "terms_of_use") %}
{% set privacy_policy = frappe.db.get_single_value("LMS Settings", "privacy_policy") %}
{% if terms_of_use or privacy_policy %}
{% if terms_of_use %}
{% set terms_page = frappe.db.get_single_value("LMS Settings", "terms_page") %}
{% set terms_page_route = frappe.db.get_value("Web Page", terms_page, "route") %}
{% set terms_link = "<a href='/" + terms_page_route +"'>" + _("Terms of Use") + "</a>" %}
{% endif %}
{% if privacy_policy %}
{% set privacy_policy_page = frappe.db.get_single_value("LMS Settings", "privacy_policy_page") %}
{% set privacy_page_route = frappe.db.get_value("Web Page", privacy_policy_page, "route") %}
{% set privacy_link = "<a href='/" + privacy_page_route +"'>" + _("Privacy Policy") + "</a>" %}
{% endif %}
{% set final_link = terms_link + _(" and ") + privacy_link if terms_of_use and privacy_policy else terms_link if terms_of_use else privacy_link %}
<div class="form-group">
<div class="checkbox">
@@ -37,13 +19,12 @@
data-fieldtype="Check" data-fieldname="terms" id="signup-terms" required>
</span>
<span class="label-area">
{{ _("I have read and agree to your {0}").format(final_link) }}
{{ _("I have read and agree to your {0}").format(get_signup_optin_checks()) }}
</span>
</label>
<p class="help-box small text-muted"></p>
</div>
</div>
{% endif %}
</div>
<div class="page-card-actions">
<button class="btn btn-sm btn-primary btn-block btn-signup"