diff --git a/community/lms/doctype/chapter_reference/chapter_reference.json b/community/lms/doctype/chapter_reference/chapter_reference.json index 7c63fbcf..a251b1a4 100644 --- a/community/lms/doctype/chapter_reference/chapter_reference.json +++ b/community/lms/doctype/chapter_reference/chapter_reference.json @@ -13,14 +13,14 @@ "fieldtype": "Link", "in_list_view": 1, "label": "Chapter", - "options": "Chapter", + "options": "Course Chapter", "reqd": 1 } ], "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2021-07-27 16:25:02.903245", + "modified": "2021-09-30 10:35:30.014950", "modified_by": "Administrator", "module": "LMS", "name": "Chapter Reference", diff --git a/community/lms/doctype/course_chapter/course_chapter.json b/community/lms/doctype/course_chapter/course_chapter.json index 63ce8e87..b33baa69 100644 --- a/community/lms/doctype/course_chapter/course_chapter.json +++ b/community/lms/doctype/course_chapter/course_chapter.json @@ -2,7 +2,7 @@ "actions": [], "allow_rename": 1, "autoname": "format:{####} {title}", - "creation": "2021-05-03 05:49:08.383050", + "creation": "2021-05-03 05:49:08.383058", "doctype": "DocType", "editable_grid": 1, "engine": "InnoDB", @@ -58,7 +58,7 @@ "link_fieldname": "chapter" } ], - "modified": "2021-09-29 15:33:44.611221", + "modified": "2021-09-29 15:33:44.611223", "modified_by": "Administrator", "module": "LMS", "name": "Course Chapter", diff --git a/community/lms/doctype/course_lesson/course_lesson.json b/community/lms/doctype/course_lesson/course_lesson.json index bacf3f47..77d54405 100644 --- a/community/lms/doctype/course_lesson/course_lesson.json +++ b/community/lms/doctype/course_lesson/course_lesson.json @@ -2,7 +2,7 @@ "actions": [], "allow_rename": 1, "autoname": "format:{####} {title}", - "creation": "2021-05-03 06:21:12.995981", + "creation": "2021-05-03 06:21:12.995984", "doctype": "DocType", "editable_grid": 1, "engine": "InnoDB", @@ -71,7 +71,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2021-09-29 15:28:51.418015", + "modified": "2021-09-29 15:28:51.418013", "modified_by": "Administrator", "module": "LMS", "name": "Course Lesson", diff --git a/community/lms/doctype/lesson_reference/lesson_reference.json b/community/lms/doctype/lesson_reference/lesson_reference.json index d7a0dc3a..a3e77ebb 100644 --- a/community/lms/doctype/lesson_reference/lesson_reference.json +++ b/community/lms/doctype/lesson_reference/lesson_reference.json @@ -13,14 +13,14 @@ "fieldtype": "Link", "in_list_view": 1, "label": "Lesson", - "options": "Lesson", + "options": "Course Lesson", "reqd": 1 } ], "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2021-08-31 10:44:42.048232", + "modified": "2021-09-30 10:35:47.832547", "modified_by": "Administrator", "module": "LMS", "name": "Lesson Reference", diff --git a/community/lms/doctype/lms_course/lms_course.json b/community/lms/doctype/lms_course/lms_course.json index 30a8475b..d2718857 100644 --- a/community/lms/doctype/lms_course/lms_course.json +++ b/community/lms/doctype/lms_course/lms_course.json @@ -148,7 +148,7 @@ "links": [ { "group": "Chapters", - "link_doctype": "Chapter", + "link_doctype": "Course Chapter", "link_fieldname": "course" }, { @@ -167,7 +167,7 @@ "link_fieldname": "course" } ], - "modified": "2021-09-20 12:00:18.325579", + "modified": "2021-09-30 10:36:48.759994", "modified_by": "Administrator", "module": "LMS", "name": "LMS Course", diff --git a/community/lms/doctype/lms_course/lms_course.py b/community/lms/doctype/lms_course/lms_course.py index d2805505..97c8ad10 100644 --- a/community/lms/doctype/lms_course/lms_course.py +++ b/community/lms/doctype/lms_course/lms_course.py @@ -153,7 +153,7 @@ class LMSCourse(Document): """ chapters = [] for row in self.chapters: - chapter_details = frappe.db.get_value("Chapter", row.chapter, + chapter_details = frappe.db.get_value("Course Chapter", row.chapter, ["name", "title", "description"], as_dict=True) chapter_details.idx = row.idx @@ -217,7 +217,7 @@ class LMSCourse(Document): if not lesson: return None - chapter = frappe.db.get_value("Chapters", {"chapter": lesson.parent}, ["idx"], as_dict=True) + chapter = frappe.db.get_value("Chapter Reference", {"chapter": lesson.parent}, ["idx"], as_dict=True) if not chapter: return None diff --git a/community/lms/workspace/lms/lms.json b/community/lms/workspace/lms/lms.json index 3bbe5663..4f3bf870 100644 --- a/community/lms/workspace/lms/lms.json +++ b/community/lms/workspace/lms/lms.json @@ -79,7 +79,7 @@ "hidden": 0, "is_query_report": 0, "label": "Chapter", - "link_to": "Chapter", + "link_to": "Course Chapter", "link_type": "DocType", "onboard": 0, "type": "Link" @@ -166,4 +166,4 @@ "type": "DocType" } ] -} \ No newline at end of file +} diff --git a/community/patches.txt b/community/patches.txt index 7651b808..e6d2fcb5 100644 --- a/community/patches.txt +++ b/community/patches.txt @@ -12,4 +12,4 @@ community.patches.v0_0.course_instructor_update execute:frappe.delete_doc("DocType", "Discussion Message") execute:frappe.delete_doc("DocType", "Discussion Thread") community.patches.v0_0.rename_chapters_and_lessons_doctype -community.patches.v0_0.rename_chapter_and_lesson_doctype #27-09-2021 +community.patches.v0_0.rename_chapter_and_lesson_doctype #29-09-2021 diff --git a/community/patches/v0_0/rename_chapter_and_lesson_doctype.py b/community/patches/v0_0/rename_chapter_and_lesson_doctype.py index f86d5f2b..4dd3bdca 100644 --- a/community/patches/v0_0/rename_chapter_and_lesson_doctype.py +++ b/community/patches/v0_0/rename_chapter_and_lesson_doctype.py @@ -10,25 +10,31 @@ def execute(): if not frappe.db.count("Course Lesson"): move_lessons() - frappe.delete_doc("DocType", "Chapter") - frappe.delete_doc("DocType", "Lesson") + change_parent_for_lesson_reference() def move_chapters(): docs = frappe.get_all("Chapter", fields=["*"]) for doc in docs: if frappe.db.exists("LMS Course", doc.course): - keys = doc - keys.update({"doctype": "Course Chapter"}) - del keys["name"] - frappe.get_doc(keys).save() + name = doc.name + doc.update({"doctype": "Course Chapter"}) + del doc["name"] + new_doc = frappe.get_doc(doc) + new_doc.save() + frappe.rename_doc("Course Chapter", new_doc.name, name) def move_lessons(): docs = frappe.get_all("Lesson", fields=["*"]) for doc in docs: - print(frappe.db.exists("Chapter", doc.chapter)) if frappe.db.exists("Chapter", doc.chapter): - keys = doc - print(doc) - keys.update({"doctype": "Course Lesson"}) - del keys["name"] - frappe.get_doc(keys).save() + name = doc.name + doc.update({"doctype": "Course Lesson"}) + del doc["name"] + new_doc = frappe.get_doc(doc) + new_doc.save() + frappe.rename_doc("Course Lesson", new_doc.name, name) + +def change_parent_for_lesson_reference(): + lesson_reference = frappe.get_all("Lesson Reference", fields=["name", "parent"]) + for reference in lesson_reference: + frappe.db.set_value("Lesson Reference", reference.name, "parenttype", "Course Chapter")