fix: condition to check course and chapter

This commit is contained in:
pateljannat
2021-09-29 17:55:08 +05:30
parent dc877a9c09
commit ddffc8372b
2 changed files with 11 additions and 9 deletions

View File

@@ -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 #25-09-2021
community.patches.v0_0.rename_chapter_and_lesson_doctype #26-09-2021

View File

@@ -16,15 +16,17 @@ def execute():
def move_chapters():
docs = frappe.get_all("Chapter", fields=["*"])
for doc in docs:
keys = doc
keys.update({"doctype": "Course Chapter"})
del keys["name"]
frappe.get_doc(keys).save()
if frappe.db.exists("LMS Course", doc.course):
keys = doc
keys.update({"doctype": "Course Chapter"})
del keys["name"]
frappe.get_doc(keys).save()
def move_lessons():
docs = frappe.get_all("Lesson", fields=["*"])
for doc in docs:
keys = doc
keys.update({"doctype": "Course Lesson"})
del keys["name"]
frappe.get_doc(keys).save()
if frappe.db.exists("Chapter", doc.chapter):
keys = doc
keys.update({"doctype": "Course Lesson"})
del keys["name"]
frappe.get_doc(keys).save()