fix: permission issues on badges

This commit is contained in:
Jannat Patel
2026-02-19 15:59:03 +05:30
parent 08373dc2ab
commit c88d36df1e
6 changed files with 47 additions and 113 deletions

View File

@@ -1298,6 +1298,7 @@ def get_lms_settings():
"contact_us_url",
"livecode_url",
"disable_pwa",
"allow_job_posting",
]
settings = frappe._dict()
@@ -1310,7 +1311,6 @@ def get_lms_settings():
@frappe.whitelist()
def cancel_evaluation(evaluation: dict):
evaluation = frappe._dict(evaluation)
print(evaluation.member, frappe.session.user)
if evaluation.member != frappe.session.user:
frappe.throw(_("You do not have permission to cancel this evaluation."), frappe.PermissionError)
@@ -2219,3 +2219,17 @@ def get_assessment_from_lesson(course: str, assessmentType: str):
assessments.append(quiz_name)
return assessments
@frappe.whitelist()
def get_badges(member: str):
if not has_lms_role(frappe.get_roles()):
frappe.throw(_("You do not have permission to access badges."), frappe.PermissionError)
badges = frappe.get_all(
"LMS Badge Assignment",
{"member": member},
["name", "member", "badge", "badge_image", "badge_description", "issued_on"],
)
return badges

View File

@@ -100,7 +100,7 @@
"link_fieldname": "badge"
}
],
"modified": "2026-02-19 12:04:56.263316",
"modified": "2026-02-19 15:05:49.719925",
"modified_by": "sayali@frappe.io",
"module": "LMS",
"name": "LMS Badge",
@@ -131,15 +131,6 @@
"role": "Moderator",
"share": 1,
"write": 1
},
{
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "LMS Student",
"share": 1
}
],
"row_format": "Dynamic",

View File

@@ -84,7 +84,7 @@
"grid_page_length": 50,
"index_web_pages_for_search": 1,
"links": [],
"modified": "2025-12-04 17:06:26.090276",
"modified": "2026-02-19 15:06:08.389081",
"modified_by": "sayali@frappe.io",
"module": "LMS",
"name": "LMS Badge Assignment",
@@ -120,10 +120,6 @@
"read": 1,
"role": "LMS Student"
},
{
"read": 1,
"role": "LMS Student"
},
{
"create": 1,
"delete": 1,

View File

@@ -76,7 +76,9 @@
"contact_us_tab",
"contact_us_email",
"column_break_gcgv",
"contact_us_url"
"contact_us_url",
"jobs_tab",
"allow_job_posting"
],
"fields": [
{
@@ -471,13 +473,24 @@
{
"fieldname": "column_break_dtns",
"fieldtype": "Column Break"
},
{
"fieldname": "jobs_tab",
"fieldtype": "Tab Break",
"label": "Jobs"
},
{
"default": "1",
"fieldname": "allow_job_posting",
"fieldtype": "Check",
"label": "Allow Job Posting"
}
],
"grid_page_length": 50,
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2026-01-01 19:36:54.443390",
"modified": "2026-02-19 12:57:28.499184",
"modified_by": "sayali@frappe.io",
"module": "LMS",
"name": "LMS Settings",