feat: lms student role
This commit is contained in:
@@ -54,6 +54,7 @@ def create_lms_roles():
|
||||
create_course_creator_role()
|
||||
create_moderator_role()
|
||||
create_evaluator_role()
|
||||
create_lms_student_role()
|
||||
|
||||
|
||||
def delete_lms_roles():
|
||||
@@ -106,6 +107,19 @@ def create_evaluator_role():
|
||||
role.save()
|
||||
|
||||
|
||||
def create_lms_student_role():
|
||||
if not frappe.db.exists("Role", "LMS Student"):
|
||||
role = frappe.new_doc("Role")
|
||||
role.update(
|
||||
{
|
||||
"role_name": "LMS Student",
|
||||
"home_page": "",
|
||||
"desk_access": 0,
|
||||
}
|
||||
)
|
||||
role.save()
|
||||
|
||||
|
||||
def set_default_certificate_print_format():
|
||||
filters = {
|
||||
"doc_type": "LMS Certificate",
|
||||
|
||||
@@ -116,7 +116,7 @@
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"make_attachments_public": 1,
|
||||
"modified": "2022-09-15 17:22:21.662675",
|
||||
"modified": "2023-09-29 17:03:30.825021",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Job",
|
||||
"name": "Job Opportunity",
|
||||
@@ -144,7 +144,7 @@
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "All",
|
||||
"role": "LMS Student",
|
||||
"select": 1,
|
||||
"share": 1,
|
||||
"write": 1
|
||||
|
||||
@@ -40,7 +40,7 @@ def save_current_lesson(course_name, lesson_name):
|
||||
return
|
||||
doc = frappe.get_doc("LMS Enrollment", name)
|
||||
doc.current_lesson = lesson_name
|
||||
doc.save(ignore_permissions=True)
|
||||
doc.save()
|
||||
return {"current_lesson": doc.current_lesson}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ def join_cohort(course, cohort, subgroup, invite_code):
|
||||
return {"ok": True, "status": "record found"}
|
||||
else:
|
||||
doc = frappe.get_doc(data)
|
||||
doc.insert(ignore_permissions=True)
|
||||
doc.insert()
|
||||
return {"ok": True, "status": "record created"}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ def approve_cohort_join_request(join_request):
|
||||
return {"ok": False, "error": "Permission Deined"}
|
||||
|
||||
r.status = "Accepted"
|
||||
r.save(ignore_permissions=True)
|
||||
r.save()
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ def reject_cohort_join_request(join_request):
|
||||
return {"ok": False, "error": "Permission Deined"}
|
||||
|
||||
r.status = "Rejected"
|
||||
r.save(ignore_permissions=True)
|
||||
r.save()
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ def undo_reject_cohort_join_request(join_request):
|
||||
return {"ok": False, "error": "Permission Deined"}
|
||||
|
||||
r.status = "Pending"
|
||||
r.save(ignore_permissions=True)
|
||||
r.save()
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2021-12-16 15:06:03.985221",
|
||||
"modified": "2023-09-29 17:08:18.950560",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "Cohort Join Request",
|
||||
@@ -68,9 +68,21 @@
|
||||
"role": "System Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "LMS Student",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"states": [],
|
||||
"track_changes": 1
|
||||
}
|
||||
@@ -59,7 +59,7 @@
|
||||
"link_fieldname": "chapter"
|
||||
}
|
||||
],
|
||||
"modified": "2022-03-14 17:57:00.707416",
|
||||
"modified": "2023-09-29 17:03:58.013819",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "Course Chapter",
|
||||
@@ -86,7 +86,7 @@
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "All",
|
||||
"role": "LMS Student",
|
||||
"select": 1,
|
||||
"share": 1,
|
||||
"write": 1
|
||||
|
||||
@@ -141,7 +141,7 @@
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2023-09-27 15:45:54.738573",
|
||||
"modified": "2023-09-29 17:04:19.252897",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "Course Lesson",
|
||||
@@ -169,7 +169,7 @@
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "All",
|
||||
"role": "LMS Student",
|
||||
"select": 1,
|
||||
"share": 1,
|
||||
"write": 1
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2021-12-21 09:34:35.018280",
|
||||
"modified": "2023-09-29 17:04:58.167481",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "Function",
|
||||
@@ -44,11 +44,12 @@
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "All",
|
||||
"role": "LMS Student",
|
||||
"select": 1,
|
||||
"share": 1
|
||||
}
|
||||
],
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC"
|
||||
"sort_order": "DESC",
|
||||
"states": []
|
||||
}
|
||||
@@ -19,7 +19,7 @@
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2021-12-21 09:35:20.443192",
|
||||
"modified": "2023-09-29 17:05:27.231982",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "Industry",
|
||||
@@ -44,11 +44,12 @@
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "All",
|
||||
"role": "LMS Student",
|
||||
"select": 1,
|
||||
"share": 1
|
||||
}
|
||||
],
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC"
|
||||
"sort_order": "DESC",
|
||||
"states": []
|
||||
}
|
||||
@@ -123,7 +123,7 @@
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2023-08-24 17:52:35.487141",
|
||||
"modified": "2023-09-29 17:07:38.695936",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Enrollment",
|
||||
@@ -140,6 +140,17 @@
|
||||
"role": "System Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "LMS Student",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"quick_entry": 1,
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2021-12-21 09:35:44.265910",
|
||||
"modified": "2023-09-29 17:05:50.502696",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "User Skill",
|
||||
@@ -44,11 +44,12 @@
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "All",
|
||||
"role": "LMS Student",
|
||||
"select": 1,
|
||||
"share": 1
|
||||
}
|
||||
],
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC"
|
||||
"sort_order": "DESC",
|
||||
"states": []
|
||||
}
|
||||
@@ -72,4 +72,4 @@ def create_evaluation(user, course, date, rating, status):
|
||||
"status": status,
|
||||
}
|
||||
)
|
||||
evaluation.save(ignore_permissions=True)
|
||||
evaluation.save()
|
||||
|
||||
@@ -585,7 +585,7 @@ def validate_image(path):
|
||||
if path and "/private" in path:
|
||||
file = frappe.get_doc("File", {"file_url": path})
|
||||
file.is_private = 0
|
||||
file.save(ignore_permissions=True)
|
||||
file.save()
|
||||
return file.file_url
|
||||
return path
|
||||
|
||||
|
||||
@@ -69,4 +69,5 @@ lms.patches.v1_0.rename_lms_class_to_lms_batch
|
||||
lms.patches.v1_0.rename_classes_in_navbar
|
||||
lms.patches.v1_0.publish_batches
|
||||
lms.patches.v1_0.publish_certificates
|
||||
lms.patches.v1_0.change_naming_for_batch_course #14-09-2023
|
||||
lms.patches.v1_0.change_naming_for_batch_course #14-09-2023
|
||||
lms.patches.v1_0.create_student_role
|
||||
22
lms/patches/v1_0/create_student_role.py
Normal file
22
lms/patches/v1_0/create_student_role.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import frappe
|
||||
from lms.install import create_lms_student_role
|
||||
|
||||
|
||||
def execute():
|
||||
create_lms_student_role()
|
||||
|
||||
users = frappe.get_all(
|
||||
"User", filters={"user_type": "Website User", "enabled": 1}, pluck="name"
|
||||
)
|
||||
|
||||
for user in users:
|
||||
filters = {
|
||||
"parent": user,
|
||||
"parenttype": "User",
|
||||
"parentfield": "roles",
|
||||
"role": "LMS Student",
|
||||
}
|
||||
if not frappe.db.exists("Has Role", filters):
|
||||
doc = frappe.new_doc("Has Role")
|
||||
doc.update(filters)
|
||||
doc.save()
|
||||
Reference in New Issue
Block a user