From da9667e1f7d904bad519cb5e898211e5114a31f3 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Tue, 20 Dec 2022 13:32:30 +0530 Subject: [PATCH] feat: base template and patch for onboarding --- .../doctype/lms_settings/lms_settings.json | 7 ++- lms/lms/page/lms_home/lms_home.js | 6 +- .../course_cards/course_cards.html | 1 - lms/patches.txt | 1 + lms/patches/v0_0/check_onboarding_status.py | 6 ++ lms/templates/lms_base.html | 10 +++ lms/templates/onboarding_header.html | 11 ++-- lms/www/batch/learn.html | 9 +-- lms/www/batch/quiz.html | 5 -- lms/www/batch/quiz_list.html | 5 -- lms/www/classes/class.html | 4 +- lms/www/classes/index.html | 4 +- lms/www/classes/progress.html | 9 +-- lms/www/community/index.html | 63 +++++++++++-------- lms/www/courses/course.html | 9 +-- lms/www/courses/index.html | 10 +-- lms/www/jobs/index.html | 7 +-- lms/www/jobs/job.html | 7 +-- 18 files changed, 82 insertions(+), 92 deletions(-) create mode 100644 lms/patches/v0_0/check_onboarding_status.py create mode 100644 lms/templates/lms_base.html diff --git a/lms/lms/doctype/lms_settings/lms_settings.json b/lms/lms/doctype/lms_settings/lms_settings.json index 11450460..3a2a3ac6 100644 --- a/lms/lms/doctype/lms_settings/lms_settings.json +++ b/lms/lms/doctype/lms_settings/lms_settings.json @@ -143,13 +143,14 @@ "default": "0", "fieldname": "is_onboarding_complete", "fieldtype": "Check", - "label": "Is Onboarding Complete" + "label": "Is Onboarding Complete", + "read_only": 1 } ], "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2022-12-19 18:36:33.987735", + "modified": "2022-12-20 11:44:06.317159", "modified_by": "Administrator", "module": "LMS", "name": "LMS Settings", @@ -170,4 +171,4 @@ "sort_order": "DESC", "states": [], "track_changes": 1 -} +} \ No newline at end of file diff --git a/lms/lms/page/lms_home/lms_home.js b/lms/lms/page/lms_home/lms_home.js index 0ec35174..4521b64d 100644 --- a/lms/lms/page/lms_home/lms_home.js +++ b/lms/lms/page/lms_home/lms_home.js @@ -1,3 +1,3 @@ -frappe.pages['lms-home'].on_page_load = function(wrapper) { - window.location.href = '/courses' -} +frappe.pages["lms-home"].on_page_load = function (wrapper) { + window.location.href = "/courses"; +}; diff --git a/lms/lms/web_template/course_cards/course_cards.html b/lms/lms/web_template/course_cards/course_cards.html index 7d8dc4f1..16aa2b8f 100644 --- a/lms/lms/web_template/course_cards/course_cards.html +++ b/lms/lms/web_template/course_cards/course_cards.html @@ -1,5 +1,4 @@
- {% include "public/icons/symbol-defs.svg" %}

{{ _(title) }}

{% if subtitle %}

{{ _(subtitle) }}

diff --git a/lms/patches.txt b/lms/patches.txt index 2f4e6bbc..275ee47a 100644 --- a/lms/patches.txt +++ b/lms/patches.txt @@ -42,3 +42,4 @@ lms.patches.v0_0.quiz_submission_result lms.patches.v0_0.skill_to_user_skill lms.patches.v0_0.rename_instructor_role lms.patches.v0_0.change_course_creation_settings #12-12-2022 +lms.patches.v0_0.check_onboarding_status #21-12-2022 diff --git a/lms/patches/v0_0/check_onboarding_status.py b/lms/patches/v0_0/check_onboarding_status.py new file mode 100644 index 00000000..a57189e0 --- /dev/null +++ b/lms/patches/v0_0/check_onboarding_status.py @@ -0,0 +1,6 @@ +import frappe + +def execute(): + if frappe.db.count("LMS Course") and frappe.db.count("Course Chapter") \ + and frappe.db.count("Course Lesson") and frappe.db.count("LMS Quiz"): + frappe.db.set_value("LMS Settings", None, "is_onboarding_complete", True) diff --git a/lms/templates/lms_base.html b/lms/templates/lms_base.html new file mode 100644 index 00000000..a37775ad --- /dev/null +++ b/lms/templates/lms_base.html @@ -0,0 +1,10 @@ +{% extends "templates/base.html" %} + + +{% block content %} + {% include "public/icons/symbol-defs.svg" %} + {% include "lms/templates/onboarding_header.html" %} + {% block page_content %} + Hello, world! + {% endblock %} +{% endblock %} diff --git a/lms/templates/onboarding_header.html b/lms/templates/onboarding_header.html index fe2fceac..362349c5 100644 --- a/lms/templates/onboarding_header.html +++ b/lms/templates/onboarding_header.html @@ -1,14 +1,13 @@ -{% set is_onboarding_complete = frappe.db.get_single_value("LMS Settings", "is_onboarding_complete") %} - -{% if has_course_moderator_role() and not is_onboarding_complete %} - +{% set onboarding_settings = frappe.db.get_single_value("LMS Settings", "is_onboarding_complete") %} {% set course_created = frappe.db.count("LMS Course") %} -{% set first_course = frappe.db.get_all("LMS Course", order_by="creation", pluck="name")[0] %} {% set chapter_created = frappe.db.count("Course Chapter") %} {% set lesson_created = frappe.db.count("Course Lesson") %} {% set quiz_created = frappe.db.count("LMS Quiz") %} +{% set first_course = frappe.db.get_all("LMS Course", order_by="creation", pluck="name")[0] %} +{% set is_onboarding_complete = onboarding_settings or (course_created and chapter_created and lesson_created and quiz_created) %} +{% if has_course_moderator_role() and not is_onboarding_complete %}
{{ _("Skip") }}
@@ -24,7 +23,7 @@ {{ _("Create a Course") }} - + diff --git a/lms/www/batch/learn.html b/lms/www/batch/learn.html index 4987bbca..19cd430d 100644 --- a/lms/www/batch/learn.html +++ b/lms/www/batch/learn.html @@ -1,29 +1,26 @@ -{% extends "templates/base.html" %} +{% extends "lms/templates/lms_base.html" %} {% from "www/macros/livecode.html" import LiveCodeEditorJS, LiveCodeEditor with context %} -{% block title %} +{% block title %} {% if lesson.title %} {{ lesson.title }} - {{ course.title }} {% else %} {{ _("New Lesson") }} {% endif %} - {% endblock %} {% block head_include %} -{% include "public/icons/symbol-defs.svg" %} {% for ext in page_extensions %} {{ ext.render_header() }} {% endfor %} - {% endblock %} -{% block content %} +{% block page_content %}
{{ BreadCrumb(course, lesson) }} diff --git a/lms/www/batch/quiz.html b/lms/www/batch/quiz.html index 26a2ca7f..12309243 100644 --- a/lms/www/batch/quiz.html +++ b/lms/www/batch/quiz.html @@ -4,11 +4,6 @@ {% endblock %} -{% block head_include %} - {% include "public/icons/symbol-defs.svg" %} -{% endblock %} - - {% block content %}
diff --git a/lms/www/batch/quiz_list.html b/lms/www/batch/quiz_list.html index eecd28c8..b6f4fe3e 100644 --- a/lms/www/batch/quiz_list.html +++ b/lms/www/batch/quiz_list.html @@ -4,11 +4,6 @@ {% endblock %} -{% block head_include %} - {% include "public/icons/symbol-defs.svg" %} -{% endblock %} - - {% block content %}
diff --git a/lms/www/classes/class.html b/lms/www/classes/class.html index 7362d35c..fad13613 100644 --- a/lms/www/classes/class.html +++ b/lms/www/classes/class.html @@ -1,10 +1,10 @@ -{% extends "templates/base.html" %} +{% extends "lms/templates/lms_base.html" %} {% block title %} {{ _(class_info.title) }} {% endblock %} -{% block content %} +{% block page_content %}
{{ BreadCrumb(class_info) }} diff --git a/lms/www/classes/index.html b/lms/www/classes/index.html index 4f20a534..22684ef4 100644 --- a/lms/www/classes/index.html +++ b/lms/www/classes/index.html @@ -1,9 +1,9 @@ -{% extends "templates/base.html" %} +{% extends "lms/templates/lms_base.html" %} {% block title %} {{ _("All Classes") }} {% endblock %} -{% block content %} +{% block page_content %}
{% if has_course_moderator_role() %} diff --git a/lms/www/classes/progress.html b/lms/www/classes/progress.html index 094b5736..3eec51ef 100644 --- a/lms/www/classes/progress.html +++ b/lms/www/classes/progress.html @@ -1,15 +1,10 @@ -{% extends "templates/base.html" %} +{% extends "lms/templates/lms_base.html" %} {% block title %} {{ student.first_name }} 's {{ _("Progress") }} {% endblock %} -{% block head_include %} - {% include "public/icons/symbol-defs.svg" %} -{% endblock %} - - -{% block content %} +{% block page_content %}
{{ BreadCrumb(class_info, student) }} diff --git a/lms/www/community/index.html b/lms/www/community/index.html index f073a39e..3c30bffc 100644 --- a/lms/www/community/index.html +++ b/lms/www/community/index.html @@ -1,35 +1,44 @@ -{% extends "templates/base.html" %} -{% block title %}{{ _('Community') }}{% endblock %} +{% extends "lms/templates/lms_base.html" %} +{% block title %} +{{ _('Community') }} +{% endblock %} -{% block content %} + +{% block page_content %} {% endblock %} diff --git a/lms/www/courses/course.html b/lms/www/courses/course.html index 7b28e66e..98d1e165 100644 --- a/lms/www/courses/course.html +++ b/lms/www/courses/course.html @@ -1,15 +1,10 @@ -{% extends "templates/base.html" %} +{% extends "lms/templates/lms_base.html" %} {% block title %} {{ course.title if course.title else _("New Course") }} {% endblock %} -{% block head_include %} - {% include "public/icons/symbol-defs.svg" %} -{% endblock %} - - -{% block content %} +{% block page_content %}
{{ CourseHomeHeader(course) }} diff --git a/lms/www/courses/index.html b/lms/www/courses/index.html index 59c59ebb..1d618468 100644 --- a/lms/www/courses/index.html +++ b/lms/www/courses/index.html @@ -1,4 +1,4 @@ -{% extends "templates/base.html" %} +{% extends "lms/templates/lms_base.html" %} {% block title %} @@ -6,13 +6,7 @@ {% endblock %} -{% block head_include %} -{% include "public/icons/symbol-defs.svg" %} -{% endblock %} - - -{% block content %} -{% include "lms/templates/onboarding_header.html" %} +{% block page_content %}
{% if restriction %} diff --git a/lms/www/jobs/index.html b/lms/www/jobs/index.html index d1b448fa..1c464a59 100644 --- a/lms/www/jobs/index.html +++ b/lms/www/jobs/index.html @@ -1,11 +1,8 @@ -{% extends "templates/base.html" %} +{% extends "lms/templates/lms_base.html" %} {% block title %}{{ _('Job Openings') }}{% endblock %} -{% block head_include %} -{% include "public/icons/symbol-defs.svg" %} -{% endblock %} -{% block content %} +{% block page_content %}
diff --git a/lms/www/jobs/job.html b/lms/www/jobs/job.html index b64a0962..04d0c267 100644 --- a/lms/www/jobs/job.html +++ b/lms/www/jobs/job.html @@ -1,11 +1,8 @@ -{% extends "templates/base.html" %} +{% extends "lms/templates/lms_base.html" %} {% block title %}{{ _(job.job_title) }}{% endblock %} -{% block head_include %} -{% include "public/icons/symbol-defs.svg" %} -{% endblock %} -{% block content %} +{% block page_content %}