Merge pull request #210 from pateljannat/patch-for-chapters-and-lessons

fix: Patch for chapters and lessons
This commit is contained in:
Jannat Patel
2021-09-21 10:21:31 +05:30
committed by GitHub
2 changed files with 33 additions and 0 deletions

View File

@@ -11,3 +11,4 @@ execute:frappe.delete_doc("DocType", "LMS Message")
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

View File

@@ -0,0 +1,32 @@
import frappe
def execute():
frappe.reload_doc("lms", "doctype", "lms_course")
frappe.reload_doc("lms", "doctype", "chapter")
frappe.reload_doc("lms", "doctype", "lesson")
frappe.reload_doc("lms", "doctype", "chapter_reference")
frappe.reload_doc("lms", "doctype", "lesson_reference")
if not frappe.db.count("Chapter Reference"):
move_chapters()
if not frappe.db.count("Lesson Reference"):
move_lessons()
def move_chapters():
docs = frappe.get_all("Chapters", fields=["*"])
for doc in docs:
keys = doc
keys.update({"doctype": "Chapter Reference"})
del keys["name"]
frappe.get_doc(keys).save()
def move_lessons():
docs = frappe.get_all("Lessons", fields=["*"])
for doc in docs:
keys = doc
keys.update({"doctype": "Lesson Reference"})
del keys["name"]
frappe.get_doc(keys).save()