Skip to content

Commit

Permalink
Merge pull request #1150 from pateljannat/roles-desk-access-issue
Browse files Browse the repository at this point in the history
fix: desk access and course amount validation issue
  • Loading branch information
pateljannat authored Nov 25, 2024
2 parents 562020d + d49d638 commit a90e3d6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
16 changes: 12 additions & 4 deletions lms/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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(
{
Expand All @@ -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(
{
Expand Down
2 changes: 1 addition & 1 deletion lms/lms/doctype/lms_course/lms_course.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion lms/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
lms.patches.v2_0.delete_web_forms
lms.patches.v2_0.update_desk_access_for_lms_roles
9 changes: 9 additions & 0 deletions lms/patches/v2_0/update_desk_access_for_lms_roles.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit a90e3d6

Please sign in to comment.