mirror of
https://github.com/frappe/lms.git
synced 2026-05-02 13:39:31 +03:00
Merge pull request #1913 from rehanrehman389/cleanup-cohort
chore: Remove deprecated doctype and related links
This commit is contained in:
@@ -1,12 +1,5 @@
|
||||
{
|
||||
"actions": [
|
||||
{
|
||||
"action": "lms.lms.doctype.lms_course.lms_course.reindex_exercises",
|
||||
"action_type": "Server Action",
|
||||
"group": "Reindex",
|
||||
"label": "Reindex Exercises"
|
||||
}
|
||||
],
|
||||
"actions": [],
|
||||
"allow_import": 1,
|
||||
"allow_rename": 1,
|
||||
"creation": "2022-02-22 15:28:26.091549",
|
||||
@@ -313,7 +306,7 @@
|
||||
}
|
||||
],
|
||||
"make_attachments_public": 1,
|
||||
"modified": "2025-12-11 17:21:05.231761",
|
||||
"modified": "2025-12-15 15:15:42.226098",
|
||||
"modified_by": "sayali@frappe.io",
|
||||
"module": "LMS",
|
||||
"name": "LMS Course",
|
||||
|
||||
@@ -9,8 +9,6 @@ from frappe import _
|
||||
from frappe.model.document import Document
|
||||
from frappe.utils import cint, today
|
||||
|
||||
from lms.lms.utils import get_chapters
|
||||
|
||||
from ...utils import generate_slug, update_payment_record, validate_image
|
||||
|
||||
|
||||
@@ -133,58 +131,3 @@ class LMSCourse(Document):
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Course#{self.name}>"
|
||||
|
||||
def has_mentor(self, email):
|
||||
"""Checks if this course has a mentor with given email."""
|
||||
if not email or email == "Guest":
|
||||
return False
|
||||
|
||||
mapping = frappe.get_all("LMS Course Mentor Mapping", {"course": self.name, "mentor": email})
|
||||
return mapping != []
|
||||
|
||||
def add_mentor(self, email):
|
||||
"""Adds a new mentor to the course."""
|
||||
if not email:
|
||||
raise ValueError("Invalid email")
|
||||
if email == "Guest":
|
||||
raise ValueError("Guest user can not be added as a mentor")
|
||||
|
||||
# given user is already a mentor
|
||||
if self.has_mentor(email):
|
||||
return
|
||||
|
||||
doc = frappe.get_doc({"doctype": "LMS Course Mentor Mapping", "course": self.name, "mentor": email})
|
||||
doc.insert()
|
||||
|
||||
def get_cohorts(self):
|
||||
return frappe.get_all(
|
||||
"Cohort",
|
||||
{"course": self.name},
|
||||
["name", "slug", "title", "begin_date", "end_date"],
|
||||
order_by="creation",
|
||||
)
|
||||
|
||||
def get_cohort(self, cohort_slug):
|
||||
name = frappe.get_value("Cohort", {"course": self.name, "slug": cohort_slug})
|
||||
return name and frappe.get_doc("Cohort", name)
|
||||
|
||||
def reindex_exercises(self):
|
||||
for i, c in enumerate(get_chapters(self.name), start=1):
|
||||
self._reindex_exercises_in_chapter(c, i)
|
||||
|
||||
def _reindex_exercises_in_chapter(self, c, index):
|
||||
i = 1
|
||||
for lesson in self.get_lessons(c):
|
||||
for exercise in lesson.get_exercises():
|
||||
exercise.index_ = i
|
||||
exercise.index_label = f"{index}.{i}"
|
||||
exercise.save()
|
||||
i += 1
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def reindex_exercises(doc):
|
||||
course_data = json.loads(doc)
|
||||
course = frappe.get_doc("LMS Course", course_data["name"])
|
||||
course.reindex_exercises()
|
||||
frappe.msgprint("All exercises in this course have been re-indexed.")
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
"purchased_certificate",
|
||||
"certificate",
|
||||
"section_break_8",
|
||||
"cohort",
|
||||
"subgroup",
|
||||
"column_break_12",
|
||||
"member_type",
|
||||
"role"
|
||||
@@ -94,18 +92,6 @@
|
||||
"label": "Progress",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "cohort",
|
||||
"fieldtype": "Link",
|
||||
"label": "Cohort",
|
||||
"options": "Cohort"
|
||||
},
|
||||
{
|
||||
"fieldname": "subgroup",
|
||||
"fieldtype": "Link",
|
||||
"label": "Subgroup",
|
||||
"options": "Cohort Subgroup"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_12",
|
||||
"fieldtype": "Column Break"
|
||||
@@ -148,7 +134,7 @@
|
||||
"grid_page_length": 50,
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2025-12-09 21:27:30.733482",
|
||||
"modified": "2025-12-15 21:27:30.733483",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Enrollment",
|
||||
|
||||
@@ -37,8 +37,8 @@ class LMSEnrollment(Document):
|
||||
"LMS Payment",
|
||||
{
|
||||
"reference_doctype": "LMS Course",
|
||||
"reference_docname": course,
|
||||
"member": member,
|
||||
"reference_docname": self.course,
|
||||
"member": self.member,
|
||||
"payment_receipt": True,
|
||||
},
|
||||
)
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ dependencies = [
|
||||
# core dependencies
|
||||
"websocket_client~=1.6.4",
|
||||
"markdown~=3.5.1",
|
||||
"beautifulsoup4~=4.13.4",
|
||||
"beautifulsoup4>=4.12,<4.14",
|
||||
"lxml~=4.9.3",
|
||||
"cairocffi==1.5.1",
|
||||
"razorpay~=1.4.1",
|
||||
|
||||
Reference in New Issue
Block a user