From dc877a9c09d4af5fae224cbab7c2b9107002b82e Mon Sep 17 00:00:00 2001 From: pateljannat Date: Wed, 29 Sep 2021 16:42:07 +0530 Subject: [PATCH] fix: renamed chapter and lesson doctype --- .../lms/doctype/course_chapter/__init__.py | 0 .../doctype/course_chapter/course_chapter.js | 8 ++ .../course_chapter/course_chapter.json | 86 ++++++++++++++++ .../doctype/course_chapter/course_chapter.py | 8 ++ .../course_chapter/test_course_chapter.py | 8 ++ .../lms/doctype/course_lesson/__init__.py | 0 .../doctype/course_lesson/course_lesson.js | 8 ++ .../doctype/course_lesson/course_lesson.json | 97 +++++++++++++++++++ .../doctype/course_lesson/course_lesson.py | 8 ++ .../course_lesson/test_course_lesson.py | 8 ++ community/lms/doctype/exercise/exercise.json | 4 +- .../exercise_submission.json | 4 +- .../lms_batch_membership.json | 4 +- .../lms_course_progress.json | 4 +- community/patches.txt | 1 + .../v0_0/rename_chapter_and_lesson_doctype.py | 30 ++++++ 16 files changed, 270 insertions(+), 8 deletions(-) create mode 100644 community/lms/doctype/course_chapter/__init__.py create mode 100644 community/lms/doctype/course_chapter/course_chapter.js create mode 100644 community/lms/doctype/course_chapter/course_chapter.json create mode 100644 community/lms/doctype/course_chapter/course_chapter.py create mode 100644 community/lms/doctype/course_chapter/test_course_chapter.py create mode 100644 community/lms/doctype/course_lesson/__init__.py create mode 100644 community/lms/doctype/course_lesson/course_lesson.js create mode 100644 community/lms/doctype/course_lesson/course_lesson.json create mode 100644 community/lms/doctype/course_lesson/course_lesson.py create mode 100644 community/lms/doctype/course_lesson/test_course_lesson.py create mode 100644 community/patches/v0_0/rename_chapter_and_lesson_doctype.py diff --git a/community/lms/doctype/course_chapter/__init__.py b/community/lms/doctype/course_chapter/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/community/lms/doctype/course_chapter/course_chapter.js b/community/lms/doctype/course_chapter/course_chapter.js new file mode 100644 index 00000000..f23a53a8 --- /dev/null +++ b/community/lms/doctype/course_chapter/course_chapter.js @@ -0,0 +1,8 @@ +// Copyright (c) 2021, FOSS United and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Course Chapter', { + // refresh: function(frm) { + + // } +}); diff --git a/community/lms/doctype/course_chapter/course_chapter.json b/community/lms/doctype/course_chapter/course_chapter.json new file mode 100644 index 00000000..2956fbe9 --- /dev/null +++ b/community/lms/doctype/course_chapter/course_chapter.json @@ -0,0 +1,86 @@ +{ + "actions": [], + "allow_rename": 1, + "autoname": "CHP.", + "creation": "2021-05-03 05:49:08.383057", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "course", + "title", + "column_break_3", + "description", + "section_break_5", + "lessons" + ], + "fields": [ + { + "fieldname": "course", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Course", + "options": "LMS Course", + "reqd": 1 + }, + { + "fieldname": "title", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Title", + "reqd": 1 + }, + { + "fieldname": "column_break_3", + "fieldtype": "Column Break" + }, + { + "fieldname": "description", + "fieldtype": "Small Text", + "label": "Description" + }, + { + "fieldname": "section_break_5", + "fieldtype": "Section Break" + }, + { + "fieldname": "lessons", + "fieldtype": "Table", + "label": "Lessons", + "options": "Lesson Reference" + } + ], + "index_web_pages_for_search": 1, + "links": [ + { + "group": "Lessons", + "link_doctype": "Course Lesson", + "link_fieldname": "chapter" + } + ], + "modified": "2021-09-29 15:33:44.611221", + "modified_by": "Administrator", + "module": "LMS", + "name": "Course Chapter", + "naming_rule": "Expression", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + } + ], + "search_fields": "title", + "sort_field": "modified", + "sort_order": "DESC", + "title_field": "title", + "track_changes": 1 +} diff --git a/community/lms/doctype/course_chapter/course_chapter.py b/community/lms/doctype/course_chapter/course_chapter.py new file mode 100644 index 00000000..9556f2ae --- /dev/null +++ b/community/lms/doctype/course_chapter/course_chapter.py @@ -0,0 +1,8 @@ +# Copyright (c) 2021, FOSS United and contributors +# For license information, please see license.txt + +# import frappe +from frappe.model.document import Document + +class CourseChapter(Document): + pass diff --git a/community/lms/doctype/course_chapter/test_course_chapter.py b/community/lms/doctype/course_chapter/test_course_chapter.py new file mode 100644 index 00000000..d14cd9fd --- /dev/null +++ b/community/lms/doctype/course_chapter/test_course_chapter.py @@ -0,0 +1,8 @@ +# Copyright (c) 2021, FOSS United and Contributors +# See license.txt + +# import frappe +import unittest + +class TestCourseChapter(unittest.TestCase): + pass diff --git a/community/lms/doctype/course_lesson/__init__.py b/community/lms/doctype/course_lesson/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/community/lms/doctype/course_lesson/course_lesson.js b/community/lms/doctype/course_lesson/course_lesson.js new file mode 100644 index 00000000..66699dfa --- /dev/null +++ b/community/lms/doctype/course_lesson/course_lesson.js @@ -0,0 +1,8 @@ +// Copyright (c) 2021, FOSS United and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Course Lesson', { + // refresh: function(frm) { + + // } +}); diff --git a/community/lms/doctype/course_lesson/course_lesson.json b/community/lms/doctype/course_lesson/course_lesson.json new file mode 100644 index 00000000..03606e82 --- /dev/null +++ b/community/lms/doctype/course_lesson/course_lesson.json @@ -0,0 +1,97 @@ +{ + "actions": [], + "allow_rename": 1, + "autoname": "LES.", + "creation": "2021-05-03 06:21:12.995987", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "chapter", + "include_in_preview", + "column_break_4", + "title", + "index_label", + "section_break_6", + "body", + "help_section", + "help" + ], + "fields": [ + { + "fieldname": "chapter", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Chapter", + "options": "Course Chapter", + "reqd": 1 + }, + { + "default": "0", + "fieldname": "include_in_preview", + "fieldtype": "Check", + "label": "Include In Preview" + }, + { + "fieldname": "column_break_4", + "fieldtype": "Column Break" + }, + { + "fieldname": "title", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Title", + "reqd": 1 + }, + { + "fieldname": "index_label", + "fieldtype": "Data", + "label": "Index Label", + "read_only": 1 + }, + { + "fieldname": "section_break_6", + "fieldtype": "Section Break" + }, + { + "fieldname": "body", + "fieldtype": "Markdown Editor", + "label": "Body", + "reqd": 1 + }, + { + "fieldname": "help_section", + "fieldtype": "Section Break", + "label": "Help" + }, + { + "fieldname": "help", + "fieldtype": "HTML" + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2021-09-29 15:28:51.418015", + "modified_by": "Administrator", + "module": "LMS", + "name": "Course Lesson", + "naming_rule": "Expression", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + } + ], + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1 +} diff --git a/community/lms/doctype/course_lesson/course_lesson.py b/community/lms/doctype/course_lesson/course_lesson.py new file mode 100644 index 00000000..c6be9e00 --- /dev/null +++ b/community/lms/doctype/course_lesson/course_lesson.py @@ -0,0 +1,8 @@ +# Copyright (c) 2021, FOSS United and contributors +# For license information, please see license.txt + +# import frappe +from frappe.model.document import Document + +class CourseLesson(Document): + pass diff --git a/community/lms/doctype/course_lesson/test_course_lesson.py b/community/lms/doctype/course_lesson/test_course_lesson.py new file mode 100644 index 00000000..c5c40a94 --- /dev/null +++ b/community/lms/doctype/course_lesson/test_course_lesson.py @@ -0,0 +1,8 @@ +# Copyright (c) 2021, FOSS United and Contributors +# See license.txt + +# import frappe +import unittest + +class TestCourseLesson(unittest.TestCase): + pass diff --git a/community/lms/doctype/exercise/exercise.json b/community/lms/doctype/exercise/exercise.json index e7f0ea7c..67530594 100644 --- a/community/lms/doctype/exercise/exercise.json +++ b/community/lms/doctype/exercise/exercise.json @@ -78,7 +78,7 @@ "fieldtype": "Link", "in_list_view": 1, "label": "Lesson", - "options": "Lesson" + "options": "Course Lesson" }, { "fieldname": "index_", @@ -96,7 +96,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2021-06-01 05:22:15.656013", + "modified": "2021-09-29 15:27:55.585874", "modified_by": "Administrator", "module": "LMS", "name": "Exercise", diff --git a/community/lms/doctype/exercise_submission/exercise_submission.json b/community/lms/doctype/exercise_submission/exercise_submission.json index 125af148..229e9de6 100644 --- a/community/lms/doctype/exercise_submission/exercise_submission.json +++ b/community/lms/doctype/exercise_submission/exercise_submission.json @@ -53,7 +53,7 @@ "fieldname": "lesson", "fieldtype": "Link", "label": "Lesson", - "options": "Lesson" + "options": "Course Lesson" }, { "fieldname": "image", @@ -94,7 +94,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2021-06-24 16:22:50.570845", + "modified": "2021-09-29 15:27:57.273879", "modified_by": "Administrator", "module": "LMS", "name": "Exercise Submission", diff --git a/community/lms/doctype/lms_batch_membership/lms_batch_membership.json b/community/lms/doctype/lms_batch_membership/lms_batch_membership.json index 3a0bfa0c..7a6a8497 100644 --- a/community/lms/doctype/lms_batch_membership/lms_batch_membership.json +++ b/community/lms/doctype/lms_batch_membership/lms_batch_membership.json @@ -72,7 +72,7 @@ "fieldname": "current_lesson", "fieldtype": "Link", "label": "Current Lesson", - "options": "Lesson" + "options": "Course Lesson" }, { "fetch_from": "member.username", @@ -84,7 +84,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2021-08-04 17:10:42.708479", + "modified": "2021-09-29 15:27:58.765399", "modified_by": "Administrator", "module": "LMS", "name": "LMS Batch Membership", diff --git a/community/lms/doctype/lms_course_progress/lms_course_progress.json b/community/lms/doctype/lms_course_progress/lms_course_progress.json index 33d785f6..db1772ab 100644 --- a/community/lms/doctype/lms_course_progress/lms_course_progress.json +++ b/community/lms/doctype/lms_course_progress/lms_course_progress.json @@ -28,7 +28,7 @@ "fieldtype": "Link", "in_list_view": 1, "label": "Chapter", - "options": "Chapter", + "options": "Course Chapter", "read_only": 1 }, { @@ -53,7 +53,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2021-06-02 13:05:31.114939", + "modified": "2021-09-29 15:26:43.911664", "modified_by": "Administrator", "module": "LMS", "name": "LMS Course Progress", diff --git a/community/patches.txt b/community/patches.txt index 0ab8479a..9d729b93 100644 --- a/community/patches.txt +++ b/community/patches.txt @@ -12,3 +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 diff --git a/community/patches/v0_0/rename_chapter_and_lesson_doctype.py b/community/patches/v0_0/rename_chapter_and_lesson_doctype.py new file mode 100644 index 00000000..b0b544a6 --- /dev/null +++ b/community/patches/v0_0/rename_chapter_and_lesson_doctype.py @@ -0,0 +1,30 @@ +import frappe + +def execute(): + frappe.reload_doc("lms", "doctype", "course_chapter") + frappe.reload_doc("lms", "doctype", "course_lesson") + + if not frappe.db.count("Course Chapter"): + move_chapters() + + if not frappe.db.count("Course Lesson"): + move_lessons() + + frappe.delete_doc("DocType", "Chapter") + frappe.delete_doc("DocType", "Lesson") + +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() + +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()