From 9c6cc8ecd46a540d20daa35958e0f84434e1c3d0 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Tue, 23 Aug 2022 18:27:39 +0530 Subject: [PATCH] fix: removed web forms of old course creation flow --- lms/lms/web_form/chapter/__init__.py | 0 lms/lms/web_form/chapter/chapter.js | 11 -- lms/lms/web_form/chapter/chapter.json | 89 ------------ lms/lms/web_form/chapter/chapter.py | 5 - lms/lms/web_form/course/__init__.py | 0 lms/lms/web_form/course/course.js | 6 - lms/lms/web_form/course/course.json | 147 -------------------- lms/lms/web_form/course/course.py | 5 - lms/lms/web_form/lesson/__init__.py | 0 lms/lms/web_form/lesson/lesson.js | 97 ------------- lms/lms/web_form/lesson/lesson.json | 91 ------------ lms/lms/web_form/lesson/lesson.py | 5 - lms/patches.txt | 2 +- lms/patches/v0_0/delete_course_web_forms.py | 6 +- lms/public/js/common_functions.js | 4 +- 15 files changed, 5 insertions(+), 463 deletions(-) delete mode 100644 lms/lms/web_form/chapter/__init__.py delete mode 100644 lms/lms/web_form/chapter/chapter.js delete mode 100644 lms/lms/web_form/chapter/chapter.json delete mode 100644 lms/lms/web_form/chapter/chapter.py delete mode 100644 lms/lms/web_form/course/__init__.py delete mode 100644 lms/lms/web_form/course/course.js delete mode 100644 lms/lms/web_form/course/course.json delete mode 100644 lms/lms/web_form/course/course.py delete mode 100644 lms/lms/web_form/lesson/__init__.py delete mode 100644 lms/lms/web_form/lesson/lesson.js delete mode 100644 lms/lms/web_form/lesson/lesson.json delete mode 100644 lms/lms/web_form/lesson/lesson.py diff --git a/lms/lms/web_form/chapter/__init__.py b/lms/lms/web_form/chapter/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lms/lms/web_form/chapter/chapter.js b/lms/lms/web_form/chapter/chapter.js deleted file mode 100644 index da98bb5e..00000000 --- a/lms/lms/web_form/chapter/chapter.js +++ /dev/null @@ -1,11 +0,0 @@ -frappe.ready(function() { - frappe.web_form.after_save = () => { - frappe.show_alert({ - message:__("Chapter has been saved successfully. Go back to the course and add this chapter to the chapters table."), - indicator:'green' - }, 3); - setTimeout(() => { - window.location.href = `/courses/${frappe.web_form.doc.course}`; - }, 3000); - } -}); diff --git a/lms/lms/web_form/chapter/chapter.json b/lms/lms/web_form/chapter/chapter.json deleted file mode 100644 index fc2b8afc..00000000 --- a/lms/lms/web_form/chapter/chapter.json +++ /dev/null @@ -1,89 +0,0 @@ -{ - "accept_payment": 0, - "allow_comments": 0, - "allow_delete": 0, - "allow_edit": 1, - "allow_incomplete": 0, - "allow_multiple": 1, - "allow_print": 0, - "amount": 0.0, - "amount_based_on_field": 0, - "apply_document_permissions": 1, - "button_label": "Save", - "creation": "2022-03-07 18:41:07.058806", - "doc_type": "Course Chapter", - "docstatus": 0, - "doctype": "Web Form", - "idx": 0, - "is_multi_step_form": 0, - "is_standard": 1, - "login_required": 1, - "max_attachment_size": 0, - "modified": "2022-03-14 18:48:01.704325", - "modified_by": "Administrator", - "module": "LMS", - "name": "chapter", - "owner": "Administrator", - "payment_button_label": "Buy Now", - "published": 1, - "route": "chapter", - "route_to_success_link": 0, - "show_attachments": 0, - "show_in_grid": 0, - "show_sidebar": 0, - "sidebar_items": [], - "success_url": "/chapter", - "title": "Chapter", - "web_form_fields": [ - { - "allow_read_on_all_link_options": 0, - "fieldname": "course", - "fieldtype": "Link", - "hidden": 0, - "label": "Course", - "max_length": 0, - "max_value": 0, - "options": "LMS Course", - "read_only": 0, - "reqd": 1, - "show_in_filter": 0 - }, - { - "allow_read_on_all_link_options": 0, - "fieldname": "title", - "fieldtype": "Data", - "hidden": 0, - "label": "Title", - "max_length": 0, - "max_value": 0, - "read_only": 0, - "reqd": 1, - "show_in_filter": 0 - }, - { - "allow_read_on_all_link_options": 0, - "fieldname": "description", - "fieldtype": "Small Text", - "hidden": 0, - "label": "Description", - "max_length": 0, - "max_value": 0, - "read_only": 0, - "reqd": 0, - "show_in_filter": 0 - }, - { - "allow_read_on_all_link_options": 0, - "fieldname": "lessons", - "fieldtype": "Table", - "hidden": 0, - "label": "Lessons", - "max_length": 0, - "max_value": 0, - "options": "Lesson Reference", - "read_only": 0, - "reqd": 0, - "show_in_filter": 0 - } - ] -} \ No newline at end of file diff --git a/lms/lms/web_form/chapter/chapter.py b/lms/lms/web_form/chapter/chapter.py deleted file mode 100644 index e1ada619..00000000 --- a/lms/lms/web_form/chapter/chapter.py +++ /dev/null @@ -1,5 +0,0 @@ -import frappe - -def get_context(context): - # do your magic here - pass diff --git a/lms/lms/web_form/course/__init__.py b/lms/lms/web_form/course/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lms/lms/web_form/course/course.js b/lms/lms/web_form/course/course.js deleted file mode 100644 index ff539e0a..00000000 --- a/lms/lms/web_form/course/course.js +++ /dev/null @@ -1,6 +0,0 @@ -frappe.ready(function() { - frappe.web_form.after_save = () => { - let route = frappe.web_form.doc.name ? `/courses/${frappe.web_form.doc.name}` : `/course`; - window.location.href = route; - } -}); diff --git a/lms/lms/web_form/course/course.json b/lms/lms/web_form/course/course.json deleted file mode 100644 index f12d692e..00000000 --- a/lms/lms/web_form/course/course.json +++ /dev/null @@ -1,147 +0,0 @@ -{ - "accept_payment": 0, - "allow_comments": 0, - "allow_delete": 0, - "allow_edit": 1, - "allow_incomplete": 0, - "allow_multiple": 1, - "allow_print": 0, - "amount": 0.0, - "amount_based_on_field": 0, - "apply_document_permissions": 1, - "button_label": "Save", - "creation": "2022-03-07 14:40:41.262163", - "custom_css": "", - "doc_type": "LMS Course", - "docstatus": 0, - "doctype": "Web Form", - "idx": 0, - "is_multi_step_form": 0, - "is_standard": 1, - "login_required": 1, - "max_attachment_size": 0, - "modified": "2022-03-11 12:32:22.512115", - "modified_by": "Administrator", - "module": "LMS", - "name": "course", - "owner": "Administrator", - "payment_button_label": "Buy Now", - "published": 1, - "route": "course", - "route_to_success_link": 0, - "show_attachments": 0, - "show_in_grid": 0, - "show_sidebar": 0, - "sidebar_items": [], - "success_url": "/course", - "title": "Course", - "web_form_fields": [ - { - "allow_read_on_all_link_options": 0, - "fieldname": "title", - "fieldtype": "Data", - "hidden": 0, - "label": "Title", - "max_length": 0, - "max_value": 0, - "read_only": 0, - "reqd": 1, - "show_in_filter": 0 - }, - { - "allow_read_on_all_link_options": 0, - "fieldname": "tags", - "fieldtype": "Data", - "hidden": 0, - "label": "Tags", - "max_length": 0, - "max_value": 0, - "read_only": 0, - "reqd": 0, - "show_in_filter": 0 - }, - { - "allow_read_on_all_link_options": 0, - "fieldname": "", - "fieldtype": "Column Break", - "hidden": 0, - "max_length": 0, - "max_value": 0, - "read_only": 0, - "reqd": 0, - "show_in_filter": 0 - }, - { - "allow_read_on_all_link_options": 0, - "fieldname": "video_link", - "fieldtype": "Data", - "hidden": 0, - "label": "Video Embed Link", - "max_length": 0, - "max_value": 0, - "read_only": 0, - "reqd": 0, - "show_in_filter": 0 - }, - { - "allow_read_on_all_link_options": 0, - "fieldname": "image", - "fieldtype": "Attach Image", - "hidden": 0, - "label": "Preview Image", - "max_length": 0, - "max_value": 0, - "read_only": 0, - "reqd": 0, - "show_in_filter": 0 - }, - { - "allow_read_on_all_link_options": 0, - "fieldname": "", - "fieldtype": "Section Break", - "hidden": 0, - "max_length": 0, - "max_value": 0, - "read_only": 0, - "reqd": 0, - "show_in_filter": 0 - }, - { - "allow_read_on_all_link_options": 0, - "fieldname": "short_introduction", - "fieldtype": "Small Text", - "hidden": 0, - "label": "Short Introduction", - "max_length": 0, - "max_value": 0, - "read_only": 0, - "reqd": 1, - "show_in_filter": 0 - }, - { - "allow_read_on_all_link_options": 0, - "fieldname": "description", - "fieldtype": "Text", - "hidden": 0, - "label": "Description", - "max_length": 0, - "max_value": 0, - "read_only": 0, - "reqd": 1, - "show_in_filter": 0 - }, - { - "allow_read_on_all_link_options": 0, - "fieldname": "chapters", - "fieldtype": "Table", - "hidden": 0, - "label": "Chapters", - "max_length": 0, - "max_value": 0, - "options": "Chapter Reference", - "read_only": 0, - "reqd": 0, - "show_in_filter": 0 - } - ] -} \ No newline at end of file diff --git a/lms/lms/web_form/course/course.py b/lms/lms/web_form/course/course.py deleted file mode 100644 index e1ada619..00000000 --- a/lms/lms/web_form/course/course.py +++ /dev/null @@ -1,5 +0,0 @@ -import frappe - -def get_context(context): - # do your magic here - pass diff --git a/lms/lms/web_form/lesson/__init__.py b/lms/lms/web_form/lesson/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lms/lms/web_form/lesson/lesson.js b/lms/lms/web_form/lesson/lesson.js deleted file mode 100644 index 82214a05..00000000 --- a/lms/lms/web_form/lesson/lesson.js +++ /dev/null @@ -1,97 +0,0 @@ -frappe.ready(function() { - - frappe.web_form.after_load = () => { - add_file_upload_component(); - fetch_course(); - }; - - frappe.web_form.after_save = () => { - show_success_message(); - }; - - $(document).on("click", ".add-attachment", (e) => { - show_upload_modal(); - }); - - $(document).on("click", ".copy-link", (e) => { - frappe.utils.copy_to_clipboard($(e.currentTarget).data("link")); - $(".attachments").collapse("hide"); - }); - -}); - -const fetch_course = () => { - frappe.call({ - method: "lms.lms.doctype.course_lesson.course_lesson.get_lesson_info", - args: { - "chapter": frappe.web_form.doc.chapter - }, - callback: (data) => { - this.course = data.message; - } - }); -} - -const show_upload_modal = () => { - new frappe.ui.FileUploader({ - folder: "Home/Attachments", - restrictions: { - allowed_file_types: ['image/*'] - }, - on_success: (file_doc) => { - $(".attachments").append(build_attachment_table(file_doc)); - let count = $(".attachment-count").data("count") + 1; - $(".attachment-count").data("count", count); - $(".attachment-count").html(__(`${count} attachments`)); - $(".attachments").removeClass("hide"); - }, - }); -}; - -const show_success_message = () => { - frappe.show_alert({ - message: __(`Lesson has been saved successfully. Go back to the chapter and add this lesson to the lessons table.`), - indicator:'green' - }, 3); - setTimeout(() => { - window.location.href = `/courses/${this.course}`; - }, 3000); -}; - -const add_file_upload_component = () => { - $(get_attachment_controls_html()).insertBefore($(`[data-fieldname="include_in_preview"]`).first()); -}; - -const get_attachment_controls_html = () => { - return ` -
-
- -
- - - - - {{ _("Upload Attachments") }} - -
-
-
-
- `; -}; - -const build_attachment_table = (file_doc) => { - return $(` - - ${file_doc.file_name} - {{ _("Copy Link") }} - - `); -}; diff --git a/lms/lms/web_form/lesson/lesson.json b/lms/lms/web_form/lesson/lesson.json deleted file mode 100644 index 346c4459..00000000 --- a/lms/lms/web_form/lesson/lesson.json +++ /dev/null @@ -1,91 +0,0 @@ -{ - "accept_payment": 0, - "allow_comments": 0, - "allow_delete": 0, - "allow_edit": 1, - "allow_incomplete": 0, - "allow_multiple": 1, - "allow_print": 0, - "amount": 0.0, - "amount_based_on_field": 0, - "apply_document_permissions": 1, - "button_label": "Save", - "creation": "2022-03-07 18:41:42.549831", - "custom_css": "#introduction {\n font-size: var(--text-base);\n}", - "doc_type": "Course Lesson", - "docstatus": 0, - "doctype": "Web Form", - "idx": 0, - "introduction_text": "
\n

Create lessons for your course. For adding content, use markdown syntax. You can add some additional content to the lesson using a special syntax. The table below mentions all types of dynamic content that you can add to the lessons and the syntax for the same.

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Content Type\n \n Syntax \n
Assignment {{ Assignment(\"id-filetype\") }}
Quiz {{ Quiz(\"lms_quiz_name\") }}
YouTube Video {{ YouTubeVideo(\"unique_embed_id\") }}
\n

Note: You can also attach videos from Vimeo by including the iframe embed of the video to the lesson.

\n
", - "is_multi_step_form": 0, - "is_standard": 1, - "login_required": 1, - "max_attachment_size": 0, - "modified": "2022-04-25 10:26:12.691050", - "modified_by": "Administrator", - "module": "LMS", - "name": "lesson", - "owner": "Administrator", - "payment_button_label": "Buy Now", - "published": 1, - "route": "lesson", - "route_to_success_link": 0, - "show_attachments": 0, - "show_in_grid": 0, - "show_sidebar": 0, - "sidebar_items": [], - "success_url": "", - "title": "Lesson", - "web_form_fields": [ - { - "allow_read_on_all_link_options": 0, - "fieldname": "chapter", - "fieldtype": "Link", - "hidden": 0, - "label": "Course Chapter", - "max_length": 0, - "max_value": 0, - "options": "Course Chapter", - "read_only": 0, - "reqd": 1, - "show_in_filter": 0 - }, - { - "allow_read_on_all_link_options": 0, - "fieldname": "title", - "fieldtype": "Data", - "hidden": 0, - "label": "Title", - "max_length": 0, - "max_value": 0, - "read_only": 0, - "reqd": 1, - "show_in_filter": 0 - }, - { - "allow_read_on_all_link_options": 0, - "default": "0", - "fieldname": "include_in_preview", - "fieldtype": "Check", - "hidden": 0, - "label": "Include In Preview", - "max_length": 0, - "max_value": 0, - "read_only": 0, - "reqd": 0, - "show_in_filter": 0 - }, - { - "allow_read_on_all_link_options": 0, - "fieldname": "body", - "fieldtype": "Text", - "hidden": 0, - "label": "Content", - "max_length": 0, - "max_value": 0, - "read_only": 0, - "reqd": 1, - "show_in_filter": 0 - } - ] -} \ No newline at end of file diff --git a/lms/lms/web_form/lesson/lesson.py b/lms/lms/web_form/lesson/lesson.py deleted file mode 100644 index e1ada619..00000000 --- a/lms/lms/web_form/lesson/lesson.py +++ /dev/null @@ -1,5 +0,0 @@ -import frappe - -def get_context(context): - # do your magic here - pass diff --git a/lms/patches.txt b/lms/patches.txt index 8014a7a6..6fe8bbf7 100644 --- a/lms/patches.txt +++ b/lms/patches.txt @@ -29,5 +29,5 @@ execute:frappe.delete_doc("Workspace", "School", ignore_missing=True, force=True lms.patches.v0_0.move_certification_to_certificate lms.patches.v0_0.quiz_submission_member lms.patches.v0_0.delete_old_module_docs #08-07-2022 -lms.patches.v0_0.delete_course_web_forms +lms.patches.v0_0.delete_course_web_forms #21-08-2022 lms.patches.v0_0.create_course_instructor_role diff --git a/lms/patches/v0_0/delete_course_web_forms.py b/lms/patches/v0_0/delete_course_web_forms.py index ab965f62..bd72edea 100644 --- a/lms/patches/v0_0/delete_course_web_forms.py +++ b/lms/patches/v0_0/delete_course_web_forms.py @@ -1,6 +1,6 @@ import frappe def execute(): - frappe.delete_doc("Web Form", "lesson", ignore_missing=True, force=True) - frappe.delete_doc("Web Form", "chapter", ignore_missing=True, force=True) - frappe.delete_doc("Web Form", "course", ignore_missing=True, force=True) + frappe.db.delete("Web Form", "lesson") + frappe.db.delete("Web Form", "chapter") + frappe.db.delete("Web Form", "course") diff --git a/lms/public/js/common_functions.js b/lms/public/js/common_functions.js index abfd3fcb..35b1c0e5 100644 --- a/lms/public/js/common_functions.js +++ b/lms/public/js/common_functions.js @@ -1,7 +1,5 @@ frappe.ready(() => { - frappe.provide("frappe.ui.form"); - setup_vue_and_file_size(); $(".join-batch").click((e) => { @@ -111,7 +109,7 @@ const add_chapter = (e) => { let next_index = $("[data-index]").last().data("index") + 1 || 1; let add_after = $(`.chapter-parent:last`).length ? $(`.chapter-parent:last`) : $("#outline-heading"); - console.log(add_after) + $(`