From 83338a56c0d2ae60f514823121f2adbf7aeee0c2 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Mon, 25 Nov 2024 14:26:11 +0530 Subject: [PATCH 1/2] fix: disable desk_access for lms roles --- lms/install.py | 16 ++++++++++++---- lms/patches.txt | 3 ++- .../v2_0/update_desk_access_for_lms_roles.py | 9 +++++++++ 3 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 lms/patches/v2_0/update_desk_access_for_lms_roles.py diff --git a/lms/install.py b/lms/install.py index a0225486d..23fdc584c 100644 --- a/lms/install.py +++ b/lms/install.py @@ -66,7 +66,9 @@ def delete_lms_roles(): def create_course_creator_role(): - if not frappe.db.exists("Role", "Course Creator"): + if frappe.db.exists("Role", "Course Creator"): + frappe.db.set_value("Role", "Course Creator", "desk_access", 0) + else: role = frappe.get_doc( { "doctype": "Role", @@ -79,7 +81,9 @@ def create_course_creator_role(): def create_moderator_role(): - if not frappe.db.exists("Role", "Moderator"): + if frappe.db.exists("Role", "Moderator"): + frappe.db.set_value("Role", "Moderator", "desk_access", 0) + else: role = frappe.get_doc( { "doctype": "Role", @@ -92,7 +96,9 @@ def create_moderator_role(): def create_evaluator_role(): - if not frappe.db.exists("Role", "Batch Evaluator"): + if frappe.db.exists("Role", "Batch Evaluator"): + frappe.db.set_value("Role", "Batch Evaluator", "desk_access", 0) + else: role = frappe.new_doc("Role") role.update( { @@ -105,7 +111,9 @@ def create_evaluator_role(): def create_lms_student_role(): - if not frappe.db.exists("Role", "LMS Student"): + if frappe.db.exists("Role", "LMS Student"): + frappe.db.set_value("Role", "LMS Student", "desk_access", 0) + else: role = frappe.new_doc("Role") role.update( { diff --git a/lms/patches.txt b/lms/patches.txt index ef4d6d038..4f11ed08e 100644 --- a/lms/patches.txt +++ b/lms/patches.txt @@ -93,4 +93,5 @@ lms.patches.v2_0.sidebar_settings lms.patches.v2_0.delete_certificate_request_notification #18-09-2024 lms.patches.v2_0.add_course_statistics #21-10-2024 lms.patches.v2_0.give_discussions_permissions -lms.patches.v2_0.delete_web_forms \ No newline at end of file +lms.patches.v2_0.delete_web_forms +lms.patches.v2_0.update_desk_access_for_lms_roles \ No newline at end of file diff --git a/lms/patches/v2_0/update_desk_access_for_lms_roles.py b/lms/patches/v2_0/update_desk_access_for_lms_roles.py new file mode 100644 index 000000000..dae974c1c --- /dev/null +++ b/lms/patches/v2_0/update_desk_access_for_lms_roles.py @@ -0,0 +1,9 @@ +import frappe + + +def execute(): + roles = ["Course Creator", "Moderator", "Batch Evaluator", "LMS Student"] + + for role in roles: + if frappe.db.exists("Role", role): + frappe.db.set_value("Role", role, "desk_access", 0) From d49d6382536d16479dd96ae29aa9a3398b216dc7 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Mon, 25 Nov 2024 14:36:32 +0530 Subject: [PATCH 2/2] fix: amount validation for course --- lms/lms/doctype/lms_course/lms_course.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lms/lms/doctype/lms_course/lms_course.py b/lms/lms/doctype/lms_course/lms_course.py index e3e54a40b..c66e456d1 100644 --- a/lms/lms/doctype/lms_course/lms_course.py +++ b/lms/lms/doctype/lms_course/lms_course.py @@ -53,7 +53,7 @@ def validate_payments_app(self): frappe.throw(_("Please install the Payments app to create a paid courses.")) def validate_amount_and_currency(self): - if self.paid_course and (not self.amount and not self.currency): + if self.paid_course and (not self.course_price and not self.currency): frappe.throw(_("Amount and currency are required for paid courses.")) def on_update(self):