From 0b83307f7d5688b9e394f50e9c2404e530659e5c Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Fri, 17 Dec 2021 11:24:28 +0530 Subject: [PATCH 1/9] fix: custom signup form --- school/fixtures/custom_field.json | 172 ++++++++++++++---- school/hooks.py | 4 + .../doctype/lms_settings/lms_settings.json | 9 +- school/overrides/user.py | 71 +++++++- school/plugins.py | 5 + school/templates/signup-form.html | 60 ++++++ 6 files changed, 287 insertions(+), 34 deletions(-) create mode 100644 school/templates/signup-form.html diff --git a/school/fixtures/custom_field.json b/school/fixtures/custom_field.json index 51bae85e..cee6ac83 100644 --- a/school/fixtures/custom_field.json +++ b/school/fixtures/custom_field.json @@ -1,4 +1,112 @@ [ + { + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "default": null, + "depends_on": null, + "description": null, + "docstatus": 0, + "doctype": "Custom Field", + "dt": "User", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "country", + "fieldtype": "Link", + "hidden": 0, + "hide_border": 0, + "hide_days": 0, + "hide_seconds": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_preview": 0, + "in_standard_filter": 0, + "insert_after": "username", + "label": "Country", + "length": 0, + "mandatory_depends_on": null, + "modified": "2021-12-18 19:14:11.571754", + "module": null, + "name": "User-country", + "no_copy": 0, + "non_negative": 0, + "options": "Country", + "parent": null, + "parentfield": null, + "parenttype": null, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "print_width": null, + "read_only": 0, + "read_only_depends_on": null, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "translatable": 0, + "unique": 0, + "width": null + }, + { + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "default": null, + "depends_on": null, + "description": null, + "docstatus": 0, + "doctype": "Custom Field", + "dt": "User", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "verify_age", + "fieldtype": "Check", + "hidden": 0, + "hide_border": 0, + "hide_days": 0, + "hide_seconds": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_preview": 0, + "in_standard_filter": 0, + "insert_after": "country", + "label": "Age is 18 years or over", + "length": 0, + "mandatory_depends_on": null, + "modified": "2021-12-18 19:15:34.932908", + "module": null, + "name": "User-verify_age", + "no_copy": 0, + "non_negative": 0, + "options": null, + "parent": null, + "parentfield": null, + "parenttype": null, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "print_width": null, + "read_only": 0, + "read_only_depends_on": null, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "translatable": 0, + "unique": 0, + "width": null + }, { "allow_in_quick_entry": 0, "allow_on_submit": 0, @@ -30,7 +138,7 @@ "label": "City", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 14:46:55.834145", + "modified": "2021-12-18 14:46:55.834145", "module": null, "name": "User-city", "no_copy": 0, @@ -84,7 +192,7 @@ "label": "College Name", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 14:46:55.834145", + "modified": "2021-12-18 14:46:55.834145", "module": null, "name": "User-college", "no_copy": 0, @@ -138,7 +246,7 @@ "label": "Branch", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 14:46:55.834145", + "modified": "2021-12-18 14:46:55.834145", "module": null, "name": "User-branch", "no_copy": 0, @@ -192,7 +300,7 @@ "label": "LinkedIn ID", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 14:46:55.834145", + "modified": "2021-12-18 14:46:55.834145", "module": null, "name": "User-linkedin", "no_copy": 0, @@ -246,7 +354,7 @@ "label": "Github ID", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 14:46:55.834145", + "modified": "2021-12-18 14:46:55.834145", "module": null, "name": "User-github", "no_copy": 0, @@ -300,7 +408,7 @@ "label": "Medium ID", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 14:46:55.834145", + "modified": "2021-12-18 14:46:55.834145", "module": null, "name": "User-medium", "no_copy": 0, @@ -354,7 +462,7 @@ "label": "Profession", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 14:46:55.834145", + "modified": "2021-12-18 14:46:55.834145", "module": null, "name": "User-profession", "no_copy": 0, @@ -408,7 +516,7 @@ "label": "Education Details", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 11:57:55.170625", + "modified": "2021-12-18 11:57:55.170625", "module": null, "name": "User-education_details", "no_copy": 0, @@ -462,7 +570,7 @@ "label": "Hide my Private Information from others", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 11:57:47.942967", + "modified": "2021-12-18 11:57:47.942967", "module": null, "name": "User-hide_my_private_information_from_others", "no_copy": 0, @@ -516,7 +624,7 @@ "label": "Profile Complete", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 11:00:13.792809", + "modified": "2021-12-18 11:00:13.792809", "module": null, "name": "User-profile_complete", "no_copy": 0, @@ -570,7 +678,7 @@ "label": "Cover Image", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 10:59:52.682112", + "modified": "2021-12-18 10:59:52.682112", "module": null, "name": "User-cover_image", "no_copy": 0, @@ -624,7 +732,7 @@ "label": "Education", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 11:58:56.052663", + "modified": "2021-12-18 11:58:56.052663", "module": null, "name": "User-education", "no_copy": 0, @@ -678,7 +786,7 @@ "label": "Work Experience Details", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 11:56:29.466560", + "modified": "2021-12-18 11:56:29.466560", "module": null, "name": "User-work_experience_details", "no_copy": 0, @@ -732,7 +840,7 @@ "label": "Work Experience", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 11:58:43.329371", + "modified": "2021-12-18 11:58:43.329371", "module": null, "name": "User-work_experience", "no_copy": 0, @@ -786,7 +894,7 @@ "label": "Certification Details", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 11:59:36.478416", + "modified": "2021-12-18 11:59:36.478416", "module": null, "name": "User-certification_details", "no_copy": 0, @@ -840,7 +948,7 @@ "label": "Certification", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 11:59:54.850517", + "modified": "2021-12-18 11:59:54.850517", "module": null, "name": "User-certification", "no_copy": 0, @@ -894,7 +1002,7 @@ "label": "Skill Details", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 12:01:29.335323", + "modified": "2021-12-18 12:01:29.335323", "module": null, "name": "User-skill_details", "no_copy": 0, @@ -948,7 +1056,7 @@ "label": "Skill", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 15:32:13.944672", + "modified": "2021-12-18 15:32:13.944672", "module": null, "name": "User-skill", "no_copy": 0, @@ -1002,7 +1110,7 @@ "label": "Career Preference Details", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 15:35:50.764368", + "modified": "2021-12-18 15:35:50.764368", "module": null, "name": "User-carrer_preference_details", "no_copy": 0, @@ -1056,7 +1164,7 @@ "label": "Preferred Functions", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 17:12:36.454519", + "modified": "2021-12-18 17:12:36.454519", "module": null, "name": "User-preferred_functions", "no_copy": 0, @@ -1110,7 +1218,7 @@ "label": "Preferred Location", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 17:12:40.105066", + "modified": "2021-12-18 17:12:40.105066", "module": null, "name": "User-preferred_location", "no_copy": 0, @@ -1164,7 +1272,7 @@ "label": "", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 12:47:32.673594", + "modified": "2021-12-18 12:47:32.673594", "module": null, "name": "User-career_preference_column", "no_copy": 0, @@ -1218,7 +1326,7 @@ "label": "Preferred Industries", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 17:12:31.604282", + "modified": "2021-12-18 17:12:31.604282", "module": null, "name": "User-preferred_industries", "no_copy": 0, @@ -1272,7 +1380,7 @@ "label": "Dream Companies", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 12:49:19.295124", + "modified": "2021-12-18 12:49:19.295124", "module": null, "name": "User-dream_companies", "no_copy": 0, @@ -1326,7 +1434,7 @@ "label": "Work Environment", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 12:49:46.685634", + "modified": "2021-12-18 12:49:46.685634", "module": null, "name": "User-work_environment", "no_copy": 0, @@ -1380,7 +1488,7 @@ "label": "Attire Preference", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 12:03:02.296214", + "modified": "2021-12-18 12:03:02.296214", "module": null, "name": "User-attire", "no_copy": 0, @@ -1434,7 +1542,7 @@ "label": "Collaboration Preference", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 12:02:49.680208", + "modified": "2021-12-18 12:02:49.680208", "module": null, "name": "User-collaboration", "no_copy": 0, @@ -1488,7 +1596,7 @@ "label": "Role Preference", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 16:10:37.349479", + "modified": "2021-12-18 16:10:37.349479", "module": null, "name": "User-role", "no_copy": 0, @@ -1542,7 +1650,7 @@ "label": "", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 16:45:46.776903", + "modified": "2021-12-18 16:45:46.776903", "module": null, "name": "User-work_environment_column", "no_copy": 0, @@ -1596,7 +1704,7 @@ "label": "Location Preference", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 12:02:04.328536", + "modified": "2021-12-18 12:02:04.328536", "module": null, "name": "User-location_preference", "no_copy": 0, @@ -1650,7 +1758,7 @@ "label": "Time Preference", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 16:16:37.885306", + "modified": "2021-12-18 16:16:37.885306", "module": null, "name": "User-time", "no_copy": 0, @@ -1704,7 +1812,7 @@ "label": "Company Type", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-17 12:01:41.342622", + "modified": "2021-12-18 12:01:41.342622", "module": null, "name": "User-company_type", "no_copy": 0, diff --git a/school/hooks.py b/school/hooks.py index e3b2b351..ab211455 100644 --- a/school/hooks.py +++ b/school/hooks.py @@ -187,3 +187,7 @@ page_renderer = [ # set this to "/" to have profiles on the top-level profile_url_prefix = "/users/" + +custom_signup_form = "school.plugins.show_custom_signup" + +on_login = "school.overrides.user.set_country_from_ip" diff --git a/school/lms/doctype/lms_settings/lms_settings.json b/school/lms/doctype/lms_settings/lms_settings.json index 4f539a26..21b97e57 100644 --- a/school/lms/doctype/lms_settings/lms_settings.json +++ b/school/lms/doctype/lms_settings/lms_settings.json @@ -8,6 +8,7 @@ "livecode_url", "column_break_2", "email_sender", + "verify_age", "mentor_request_section", "mentor_request_creation", "mentor_request_status_update", @@ -65,12 +66,18 @@ "fieldname": "search_placeholder", "fieldtype": "Data", "label": "Search Field Placeholder" + }, + { + "default": "0", + "fieldname": "verify_age", + "fieldtype": "Check", + "label": "Verify Age during Signup" } ], "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2021-11-25 14:12:21.514922", + "modified": "2021-12-16 17:13:42.423197", "modified_by": "Administrator", "module": "LMS", "name": "LMS Settings", diff --git a/school/overrides/user.py b/school/overrides/user.py index 26d60024..d2ef2fb7 100644 --- a/school/overrides/user.py +++ b/school/overrides/user.py @@ -1,10 +1,13 @@ import frappe from frappe.core.doctype.user.user import User -from frappe.utils import cint +from frappe.utils import cint, escape_html, random_string import hashlib import random import re from frappe import _ +from frappe.website.utils import is_signup_disabled +import requests +from frappe.geo.country_info import get_all class CustomUser(User): @@ -156,3 +159,69 @@ class CustomUser(User): "in_progress": in_progress, "completed": completed } + +@frappe.whitelist(allow_guest=True) +def sign_up(email, full_name, verify_age): + if is_signup_disabled(): + frappe.throw(_('Sign Up is disabled'), title='Not Allowed') + + user = frappe.db.get("User", {"email": email}) + if user: + if user.enabled: + return 0, _("Already Registered") + else: + return 0, _("Registered but disabled") + else: + if frappe.db.get_creation_count('User', 60) > 300: + frappe.respond_as_web_page(_('Temporarily Disabled'), + _('Too many users signed up recently, so the registration is disabled. Please try back in an hour'), + http_status_code=429) + + user = frappe.get_doc({ + "doctype":"User", + "email": email, + "first_name": escape_html(full_name), + "verify_age": verify_age, + "enabled": 1, + "new_password": random_string(10), + "user_type": "Website User" + }) + user.flags.ignore_permissions = True + user.flags.ignore_password_policy = True + user.insert() + + set_country_from_ip(user.name) + + # set default signup role as per Portal Settings + default_role = frappe.db.get_value("Portal Settings", None, "default_role") + if default_role: + user.add_roles(default_role) + + if user.flags.email_sent: + return 1, _("Please check your email for verification") + else: + return 2, _("Please ask your administrator to verify your sign-up") + + +def set_country_from_ip(user=None): + if not user: + user = frappe.session.user + + user_country = frappe.db.get_value("User", user, "country") + if user_country: + return + + frappe.db.set_value("User", user, "country", get_country_code()) + return + +def get_country_code(): + res = requests.get("http://ip-api.com/json/?fields=61439") + + try: + data = res.json() + if data.get("status") != "fail": + return data.get("country") + except Exception: + pass + + return {} diff --git a/school/plugins.py b/school/plugins.py index 5643f57c..490a07ca 100644 --- a/school/plugins.py +++ b/school/plugins.py @@ -109,3 +109,8 @@ def youtube_video_renderer(video_id): def video_renderer(src): return "".format(src) + +def show_custom_signup(): + if frappe.db.get_single_value("LMS Settings", "verify_age"): + return "school/templates/signup-form.html" + return None diff --git a/school/templates/signup-form.html b/school/templates/signup-form.html new file mode 100644 index 00000000..bf0fa2a9 --- /dev/null +++ b/school/templates/signup-form.html @@ -0,0 +1,60 @@ +
+
+
+ + +
+
+ + +
+
+
+ +

+
+
+
+
+ + + +
+
+ + From 6a3442d0584b945b7bab4d9a7619bf3f6cb19cf4 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Fri, 17 Dec 2021 19:42:57 +0530 Subject: [PATCH 2/9] fix: user and country data --- school/overrides/user.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/school/overrides/user.py b/school/overrides/user.py index d2ef2fb7..81779ccd 100644 --- a/school/overrides/user.py +++ b/school/overrides/user.py @@ -182,6 +182,7 @@ def sign_up(email, full_name, verify_age): "email": email, "first_name": escape_html(full_name), "verify_age": verify_age, + "country": "", "enabled": 1, "new_password": random_string(10), "user_type": "Website User" @@ -189,8 +190,7 @@ def sign_up(email, full_name, verify_age): user.flags.ignore_permissions = True user.flags.ignore_password_policy = True user.insert() - - set_country_from_ip(user.name) + set_country_from_ip(None, user.name) # set default signup role as per Portal Settings default_role = frappe.db.get_value("Portal Settings", None, "default_role") @@ -203,14 +203,13 @@ def sign_up(email, full_name, verify_age): return 2, _("Please ask your administrator to verify your sign-up") -def set_country_from_ip(user=None): - if not user: - user = frappe.session.user +def set_country_from_ip(login_manager=None, user=None): + if not user and login_manager: + user = login_manager.user user_country = frappe.db.get_value("User", user, "country") if user_country: return - frappe.db.set_value("User", user, "country", get_country_code()) return From 067be4973d47062d03008c5e1c0e18156740d9fd Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Mon, 20 Dec 2021 09:42:31 +0530 Subject: [PATCH 3/9] fix: string translation --- school/templates/signup-form.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/school/templates/signup-form.html b/school/templates/signup-form.html index bf0fa2a9..ba5117a7 100644 --- a/school/templates/signup-form.html +++ b/school/templates/signup-form.html @@ -17,7 +17,7 @@ - I confirm that I am 18 years old or above + {{ _("I confirm that I am 18 years old or above") }}

From 4edf4936c16718aefff1e444cdb95475bbbba100 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Mon, 20 Dec 2021 10:04:50 +0530 Subject: [PATCH 4/9] fix: pass path in hooks instead of function --- school/hooks.py | 3 ++- school/plugins.py | 5 ----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/school/hooks.py b/school/hooks.py index ab211455..323d089e 100644 --- a/school/hooks.py +++ b/school/hooks.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals from . import __version__ as app_version +import frappe app_name = "school" app_title = "School" @@ -188,6 +189,6 @@ page_renderer = [ # set this to "/" to have profiles on the top-level profile_url_prefix = "/users/" -custom_signup_form = "school.plugins.show_custom_signup" +custom_signup_form = "school/templates/signup-form.html" if frappe.db.get_single_value("LMS Settings", "verify_age") else None on_login = "school.overrides.user.set_country_from_ip" diff --git a/school/plugins.py b/school/plugins.py index 490a07ca..5643f57c 100644 --- a/school/plugins.py +++ b/school/plugins.py @@ -109,8 +109,3 @@ def youtube_video_renderer(video_id): def video_renderer(src): return "".format(src) - -def show_custom_signup(): - if frappe.db.get_single_value("LMS Settings", "verify_age"): - return "school/templates/signup-form.html" - return None From 45e396428545d31bf606d12515ecf9bbd5232138 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Mon, 20 Dec 2021 11:06:51 +0530 Subject: [PATCH 5/9] fix: renamed signup hook and moved default form to a template --- school/hooks.py | 2 +- school/plugins.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/school/hooks.py b/school/hooks.py index 323d089e..c7334667 100644 --- a/school/hooks.py +++ b/school/hooks.py @@ -189,6 +189,6 @@ page_renderer = [ # set this to "/" to have profiles on the top-level profile_url_prefix = "/users/" -custom_signup_form = "school/templates/signup-form.html" if frappe.db.get_single_value("LMS Settings", "verify_age") else None +signup_form_template = "school.plugins.show_custom_signup" on_login = "school.overrides.user.set_country_from_ip" diff --git a/school/plugins.py b/school/plugins.py index 5643f57c..490a07ca 100644 --- a/school/plugins.py +++ b/school/plugins.py @@ -109,3 +109,8 @@ def youtube_video_renderer(video_id): def video_renderer(src): return "".format(src) + +def show_custom_signup(): + if frappe.db.get_single_value("LMS Settings", "verify_age"): + return "school/templates/signup-form.html" + return None From d3a3e7066d089c152b36988a80b15e947cd9d050 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Mon, 20 Dec 2021 11:28:55 +0530 Subject: [PATCH 6/9] fix: removed unnecessary imports --- school/hooks.py | 1 - 1 file changed, 1 deletion(-) diff --git a/school/hooks.py b/school/hooks.py index c7334667..7a6d7368 100644 --- a/school/hooks.py +++ b/school/hooks.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals from . import __version__ as app_version -import frappe app_name = "school" app_title = "School" From 6188c698e319f4b203efc1ca7bf4aff0c5297cfb Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Tue, 21 Dec 2021 15:41:32 +0530 Subject: [PATCH 7/9] fix: checkbox for terms of use --- school/fixtures/custom_field.json | 130 +++++++++++++----- school/fixtures/function.json | 20 +-- school/fixtures/industry.json | 40 +++--- .../doctype/lms_settings/lms_settings.json | 26 ++-- school/lms/web_form/profile/profile.json | 15 +- school/overrides/user.py | 4 +- school/patches.txt | 1 + school/plugins.py | 4 +- school/templates/signup-form.html | 13 +- school/www/courses/index.html | 4 +- 10 files changed, 170 insertions(+), 87 deletions(-) diff --git a/school/fixtures/custom_field.json b/school/fixtures/custom_field.json index cee6ac83..7c2e7f90 100644 --- a/school/fixtures/custom_field.json +++ b/school/fixtures/custom_field.json @@ -30,7 +30,7 @@ "label": "Country", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 19:14:11.571754", + "modified": "2021-12-21 19:14:11.571754", "module": null, "name": "User-country", "no_copy": 0, @@ -68,7 +68,7 @@ "dt": "User", "fetch_from": null, "fetch_if_empty": 0, - "fieldname": "verify_age", + "fieldname": "verify_terms", "fieldtype": "Check", "hidden": 0, "hide_border": 0, @@ -81,12 +81,12 @@ "in_preview": 0, "in_standard_filter": 0, "insert_after": "country", - "label": "Age is 18 years or over", + "label": "Acceptance for Terms of Use", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 19:15:34.932908", + "modified": "2021-12-21 19:15:34.932908", "module": null, - "name": "User-verify_age", + "name": "User-verify_terms", "no_copy": 0, "non_negative": 0, "options": null, @@ -138,7 +138,7 @@ "label": "City", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 14:46:55.834145", + "modified": "2021-12-21 14:46:55.834145", "module": null, "name": "User-city", "no_copy": 0, @@ -192,7 +192,7 @@ "label": "College Name", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 14:46:55.834145", + "modified": "2021-12-21 14:46:55.834145", "module": null, "name": "User-college", "no_copy": 0, @@ -246,7 +246,7 @@ "label": "Branch", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 14:46:55.834145", + "modified": "2021-12-21 14:46:55.834145", "module": null, "name": "User-branch", "no_copy": 0, @@ -300,7 +300,7 @@ "label": "LinkedIn ID", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 14:46:55.834145", + "modified": "2021-12-21 14:46:55.834145", "module": null, "name": "User-linkedin", "no_copy": 0, @@ -354,7 +354,7 @@ "label": "Github ID", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 14:46:55.834145", + "modified": "2021-12-21 14:46:55.834145", "module": null, "name": "User-github", "no_copy": 0, @@ -408,7 +408,7 @@ "label": "Medium ID", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 14:46:55.834145", + "modified": "2021-12-21 14:46:55.834145", "module": null, "name": "User-medium", "no_copy": 0, @@ -462,7 +462,7 @@ "label": "Profession", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 14:46:55.834145", + "modified": "2021-12-21 14:46:55.834145", "module": null, "name": "User-profession", "no_copy": 0, @@ -516,7 +516,7 @@ "label": "Education Details", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 11:57:55.170625", + "modified": "2021-12-21 11:57:55.170625", "module": null, "name": "User-education_details", "no_copy": 0, @@ -570,7 +570,7 @@ "label": "Hide my Private Information from others", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 11:57:47.942967", + "modified": "2021-12-21 11:57:47.942967", "module": null, "name": "User-hide_my_private_information_from_others", "no_copy": 0, @@ -624,7 +624,7 @@ "label": "Profile Complete", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 11:00:13.792809", + "modified": "2021-12-21 11:00:13.792809", "module": null, "name": "User-profile_complete", "no_copy": 0, @@ -678,7 +678,7 @@ "label": "Cover Image", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 10:59:52.682112", + "modified": "2021-12-21 10:59:52.682112", "module": null, "name": "User-cover_image", "no_copy": 0, @@ -732,7 +732,7 @@ "label": "Education", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 11:58:56.052663", + "modified": "2021-12-21 11:58:56.052663", "module": null, "name": "User-education", "no_copy": 0, @@ -786,7 +786,7 @@ "label": "Work Experience Details", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 11:56:29.466560", + "modified": "2021-12-21 11:56:29.466560", "module": null, "name": "User-work_experience_details", "no_copy": 0, @@ -840,7 +840,7 @@ "label": "Work Experience", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 11:58:43.329371", + "modified": "2021-12-21 11:58:43.329371", "module": null, "name": "User-work_experience", "no_copy": 0, @@ -863,6 +863,60 @@ "unique": 0, "width": null }, + { + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "default": null, + "depends_on": null, + "description": null, + "docstatus": 0, + "doctype": "Custom Field", + "dt": "User", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "volunteering_or_internship", + "fieldtype": "Table", + "hidden": 0, + "hide_border": 0, + "hide_days": 0, + "hide_seconds": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_preview": 0, + "in_standard_filter": 0, + "insert_after": "work_experience", + "label": "Volunteering or Internship", + "length": 0, + "mandatory_depends_on": null, + "modified": "2021-12-21 14:58:04.285835", + "module": null, + "name": "User-volunteering_or_internship", + "no_copy": 0, + "non_negative": 0, + "options": "Work Experience", + "parent": null, + "parentfield": null, + "parenttype": null, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "print_width": null, + "read_only": 0, + "read_only_depends_on": null, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "translatable": 0, + "unique": 0, + "width": null + }, { "allow_in_quick_entry": 0, "allow_on_submit": 0, @@ -890,11 +944,11 @@ "in_list_view": 0, "in_preview": 0, "in_standard_filter": 0, - "insert_after": "work_experience", + "insert_after": "volunteering_or_internship", "label": "Certification Details", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 11:59:36.478416", + "modified": "2021-12-21 14:58:29.975380", "module": null, "name": "User-certification_details", "no_copy": 0, @@ -948,7 +1002,7 @@ "label": "Certification", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 11:59:54.850517", + "modified": "2021-12-21 11:59:54.850517", "module": null, "name": "User-certification", "no_copy": 0, @@ -1002,7 +1056,7 @@ "label": "Skill Details", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 12:01:29.335323", + "modified": "2021-12-21 12:01:29.335323", "module": null, "name": "User-skill_details", "no_copy": 0, @@ -1056,7 +1110,7 @@ "label": "Skill", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 15:32:13.944672", + "modified": "2021-12-21 15:32:13.944672", "module": null, "name": "User-skill", "no_copy": 0, @@ -1110,7 +1164,7 @@ "label": "Career Preference Details", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 15:35:50.764368", + "modified": "2021-12-21 15:35:50.764368", "module": null, "name": "User-carrer_preference_details", "no_copy": 0, @@ -1164,7 +1218,7 @@ "label": "Preferred Functions", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 17:12:36.454519", + "modified": "2021-12-21 17:12:36.454519", "module": null, "name": "User-preferred_functions", "no_copy": 0, @@ -1218,7 +1272,7 @@ "label": "Preferred Location", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 17:12:40.105066", + "modified": "2021-12-21 17:12:40.105066", "module": null, "name": "User-preferred_location", "no_copy": 0, @@ -1272,7 +1326,7 @@ "label": "", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 12:47:32.673594", + "modified": "2021-12-21 12:47:32.673594", "module": null, "name": "User-career_preference_column", "no_copy": 0, @@ -1326,7 +1380,7 @@ "label": "Preferred Industries", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 17:12:31.604282", + "modified": "2021-12-21 17:12:31.604282", "module": null, "name": "User-preferred_industries", "no_copy": 0, @@ -1380,7 +1434,7 @@ "label": "Dream Companies", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 12:49:19.295124", + "modified": "2021-12-21 12:49:19.295124", "module": null, "name": "User-dream_companies", "no_copy": 0, @@ -1434,7 +1488,7 @@ "label": "Work Environment", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 12:49:46.685634", + "modified": "2021-12-21 12:49:46.685634", "module": null, "name": "User-work_environment", "no_copy": 0, @@ -1488,7 +1542,7 @@ "label": "Attire Preference", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 12:03:02.296214", + "modified": "2021-12-21 12:03:02.296214", "module": null, "name": "User-attire", "no_copy": 0, @@ -1542,7 +1596,7 @@ "label": "Collaboration Preference", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 12:02:49.680208", + "modified": "2021-12-21 12:02:49.680208", "module": null, "name": "User-collaboration", "no_copy": 0, @@ -1596,7 +1650,7 @@ "label": "Role Preference", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 16:10:37.349479", + "modified": "2021-12-21 16:10:37.349479", "module": null, "name": "User-role", "no_copy": 0, @@ -1650,7 +1704,7 @@ "label": "", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 16:45:46.776903", + "modified": "2021-12-21 16:45:46.776903", "module": null, "name": "User-work_environment_column", "no_copy": 0, @@ -1704,7 +1758,7 @@ "label": "Location Preference", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 12:02:04.328536", + "modified": "2021-12-21 12:02:04.328536", "module": null, "name": "User-location_preference", "no_copy": 0, @@ -1758,7 +1812,7 @@ "label": "Time Preference", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 16:16:37.885306", + "modified": "2021-12-21 16:16:37.885306", "module": null, "name": "User-time", "no_copy": 0, @@ -1812,7 +1866,7 @@ "label": "Company Type", "length": 0, "mandatory_depends_on": null, - "modified": "2021-12-18 12:01:41.342622", + "modified": "2021-12-21 12:01:41.342622", "module": null, "name": "User-company_type", "no_copy": 0, diff --git a/school/fixtures/function.json b/school/fixtures/function.json index e1dcbd89..b1701cd2 100644 --- a/school/fixtures/function.json +++ b/school/fixtures/function.json @@ -39,16 +39,6 @@ "parentfield": null, "parenttype": null }, - { - "docstatus": 0, - "doctype": "Function", - "function": "Engineering (Software & IT)", - "modified": "2021-12-14 15:16:26.348864", - "name": "Engineering (Software & IT)", - "parent": null, - "parentfield": null, - "parenttype": null - }, { "docstatus": 0, "doctype": "Function", @@ -158,5 +148,15 @@ "parent": null, "parentfield": null, "parenttype": null + }, + { + "docstatus": 0, + "doctype": "Function", + "function": "Engineering (Software & IT)", + "modified": "2021-12-14 15:16:26.348864", + "name": "Engineering (Software & IT)", + "parent": null, + "parentfield": null, + "parenttype": null } ] \ No newline at end of file diff --git a/school/fixtures/industry.json b/school/fixtures/industry.json index db34d12e..b14f4804 100644 --- a/school/fixtures/industry.json +++ b/school/fixtures/industry.json @@ -89,16 +89,6 @@ "parentfield": null, "parenttype": null }, - { - "docstatus": 0, - "doctype": "Industry", - "industry": "Education & Training", - "modified": "2021-12-14 15:21:18.105864", - "name": "Education & Training", - "parent": null, - "parentfield": null, - "parenttype": null - }, { "docstatus": 0, "doctype": "Industry", @@ -109,16 +99,6 @@ "parentfield": null, "parenttype": null }, - { - "docstatus": 0, - "doctype": "Industry", - "industry": "Engineering", - "modified": "2021-12-14 15:21:18.119149", - "name": "Engineering", - "parent": null, - "parentfield": null, - "parenttype": null - }, { "docstatus": 0, "doctype": "Industry", @@ -238,5 +218,25 @@ "parent": null, "parentfield": null, "parenttype": null + }, + { + "docstatus": 0, + "doctype": "Industry", + "industry": "Education & Training", + "modified": "2021-12-14 15:21:18.105864", + "name": "Education & Training", + "parent": null, + "parentfield": null, + "parenttype": null + }, + { + "docstatus": 0, + "doctype": "Industry", + "industry": "Engineering", + "modified": "2021-12-14 15:21:18.119149", + "name": "Engineering", + "parent": null, + "parentfield": null, + "parenttype": null } ] \ No newline at end of file diff --git a/school/lms/doctype/lms_settings/lms_settings.json b/school/lms/doctype/lms_settings/lms_settings.json index 8f890332..97f26512 100644 --- a/school/lms/doctype/lms_settings/lms_settings.json +++ b/school/lms/doctype/lms_settings/lms_settings.json @@ -7,11 +7,12 @@ "field_order": [ "livecode_url", "email_sender", - "verify_age", "column_break_2", "force_profile_completion", "show_search", "search_placeholder", + "terms_of_use", + "terms_page", "mentor_request_section", "mentor_request_creation", "mentor_request_status_update" @@ -62,23 +63,30 @@ "fieldtype": "Data", "label": "Search Field Placeholder" }, - { - "default": "0", - "fieldname": "verify_age", - "fieldtype": "Check", - "label": "Verify Age during Signup" - }, { "default": "0", "fieldname": "force_profile_completion", "fieldtype": "Check", "label": "Force users to complete their Profile" + }, + { + "default": "0", + "fieldname": "terms_of_use", + "fieldtype": "Check", + "label": "Show Terms of Use on Signup" + }, + { + "depends_on": "terms_of_use", + "fieldname": "terms_page", + "fieldtype": "Link", + "label": "Terms of Use Page", + "options": "Web Page" } ], "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2021-12-21 11:32:28.196404", + "modified": "2021-12-21 12:17:07.734189", "modified_by": "Administrator", "module": "LMS", "name": "LMS Settings", @@ -98,4 +106,4 @@ "sort_field": "modified", "sort_order": "DESC", "track_changes": 1 -} +} \ No newline at end of file diff --git a/school/lms/web_form/profile/profile.json b/school/lms/web_form/profile/profile.json index c581e8c6..4b882cfe 100644 --- a/school/lms/web_form/profile/profile.json +++ b/school/lms/web_form/profile/profile.json @@ -21,7 +21,7 @@ "is_standard": 1, "login_required": 1, "max_attachment_size": 0, - "modified": "2021-12-21 11:05:56.505121", + "modified": "2021-12-21 14:58:56.943438", "modified_by": "Administrator", "module": "LMS", "name": "profile", @@ -231,6 +231,19 @@ "max_value": 0, "options": "Work Experience", "read_only": 0, + "reqd": 1, + "show_in_filter": 0 + }, + { + "allow_read_on_all_link_options": 0, + "fieldname": "volunteering_or_internship", + "fieldtype": "Table", + "hidden": 0, + "label": "Volunteering or Internship", + "max_length": 0, + "max_value": 0, + "options": "Work Experience", + "read_only": 0, "reqd": 0, "show_in_filter": 0 }, diff --git a/school/overrides/user.py b/school/overrides/user.py index 7626d0ce..c4e0bb4a 100644 --- a/school/overrides/user.py +++ b/school/overrides/user.py @@ -174,7 +174,7 @@ class CustomUser(User): } @frappe.whitelist(allow_guest=True) -def sign_up(email, full_name, verify_age): +def sign_up(email, full_name, verify_terms): if is_signup_disabled(): frappe.throw(_('Sign Up is disabled'), title='Not Allowed') @@ -194,7 +194,7 @@ def sign_up(email, full_name, verify_age): "doctype":"User", "email": email, "first_name": escape_html(full_name), - "verify_age": verify_age, + "verify_terms": verify_terms, "country": "", "enabled": 1, "new_password": random_string(10), diff --git a/school/patches.txt b/school/patches.txt index 7c1bc406..4ce65a63 100644 --- a/school/patches.txt +++ b/school/patches.txt @@ -20,3 +20,4 @@ execute:frappe.delete_doc("DocType", "Lesson") #06-10-2021 execute:frappe.delete_doc("DocType", "LMS Topic") #06-10-2021 school.patches.v0_0.add_progress_to_membership #20-10-2021 execute:frappe.delete_doc("Workspace", "LMS", ignore_missing=True, force=True) #24-10-2021 +execute:frappe.delete_doc("Custom Field", "User-verify_age", ignore_missing=True, force=True) diff --git a/school/plugins.py b/school/plugins.py index ceb01c01..4e0e6bf6 100644 --- a/school/plugins.py +++ b/school/plugins.py @@ -122,6 +122,6 @@ def video_renderer(src): return "".format(src) def show_custom_signup(): - if frappe.db.get_single_value("LMS Settings", "verify_age"): + if frappe.db.get_single_value("LMS Settings", "terms_of_use"): return "school/templates/signup-form.html" - return None + return "frappe/templates/signup.html" diff --git a/school/templates/signup-form.html b/school/templates/signup-form.html index ba5117a7..046b3655 100644 --- a/school/templates/signup-form.html +++ b/school/templates/signup-form.html @@ -10,18 +10,25 @@ + {% if frappe.db.get_single_value("LMS Settings", "terms_of_use") %}

+ {% endif %}