diff --git a/lms/hooks.py b/lms/hooks.py index 6d5b87f1..c6e34284 100644 --- a/lms/hooks.py +++ b/lms/hooks.py @@ -60,6 +60,7 @@ web_include_js = ["website.bundle.js"] # ------------ # before_install = "lms.install.before_install" +after_sync = "lms.install.after_sync" after_uninstall = "lms.install.after_uninstall" @@ -135,28 +136,28 @@ fixtures = ["Custom Field", "Function", "Industry"] # Add all simple route rules here website_route_rules = [ - {"from_route": "/sketches/", "to_route": "sketches/sketch"}, - {"from_route": "/courses/", "to_route": "courses/course"}, - {"from_route": "/courses//", "to_route": "courses/certificate"}, - {"from_route": "/courses//learn", "to_route": "batch/learn"}, - {"from_route": "/courses//learn/.", "to_route": "batch/learn"}, + {"from_route": "/sketches/", "to_route": "sketches/sketch"}, + {"from_route": "/courses/", "to_route": "courses/course"}, + {"from_route": "/courses//", "to_route": "courses/certificate"}, + {"from_route": "/courses//learn", "to_route": "batch/learn"}, + {"from_route": "/courses//learn/.", "to_route": "batch/learn"}, {"from_route": "/quizzes", "to_route": "batch/quiz_list"}, {"from_route": "/quizzes/", "to_route": "batch/quiz"}, - {"from_route": "/courses//progress", "to_route": "batch/progress"}, - {"from_route": "/courses//join", "to_route": "batch/join"}, - {"from_route": "/courses//manage", "to_route": "cohorts"}, - {"from_route": "/courses//cohorts/", "to_route": "cohorts/cohort"}, - {"from_route": "/courses//cohorts//", "to_route": "cohorts/cohort"}, - {"from_route": "/courses//subgroups//", "to_route": "cohorts/subgroup"}, - {"from_route": "/courses//subgroups///", "to_route": "cohorts/subgroup"}, - {"from_route": "/courses//join///", "to_route": "cohorts/join"}, - {"from_route": "/users", "to_route": "profiles/profile"}, + {"from_route": "/courses//progress", "to_route": "batch/progress"}, + {"from_route": "/courses//join", "to_route": "batch/join"}, + {"from_route": "/courses//manage", "to_route": "cohorts"}, + {"from_route": "/courses//cohorts/", "to_route": "cohorts/cohort"}, + {"from_route": "/courses//cohorts//", "to_route": "cohorts/cohort"}, + {"from_route": "/courses//subgroups//", "to_route": "cohorts/subgroup"}, + {"from_route": "/courses//subgroups///", "to_route": "cohorts/subgroup"}, + {"from_route": "/courses//join///", "to_route": "cohorts/join"}, + {"from_route": "/users", "to_route": "profiles/profile"}, {"from_route": "/jobs/", "to_route": "jobs/job"} ] website_redirects = [ - {"source": "/update-profile", "target": "/edit-profile"}, - {"source": "/dashboard", "target": "/users"}, + {"source": "/update-profile", "target": "/edit-profile"}, + {"source": "/dashboard", "target": "/courses"}, ] update_website_context = [ diff --git a/lms/install.py b/lms/install.py index 1f25e20c..417c62c2 100644 --- a/lms/install.py +++ b/lms/install.py @@ -1,15 +1,58 @@ import frappe +from frappe.desk.page.setup_wizard.setup_wizard import add_all_roles_to + + +def after_sync(): + create_lms_roles() + set_default_home() + add_all_roles_to("Administrator") + def after_uninstall(): delete_custom_fields() + +def create_lms_roles(): + create_instructor_role() + create_moderator_role() + + +def set_default_home(): + frappe.db.set_value("Portal Settings", None, "default_portal_home", "/courses") + + +def create_instructor_role(): + if not frappe.db.exists("Role", "Course Instructor"): + role = frappe.get_doc({ + "doctype": "Role", + "role_name": "Course Instructor", + "home_page": "", + "desk_access": 0 + }) + role.save(ignore_permissions=True) + + +def create_moderator_role(): + if not frappe.db.exists("Role", "Course Moderator"): + role = frappe.get_doc({ + "doctype": "Role", + "role_name": "Course Moderator", + "home_page": "", + "desk_access": 0 + }) + role.save(ignore_permissions=True) + + def delete_custom_fields(): - fields = [ "user_category", "headline", "college", "city", "verify_terms", "country", "preferred_location", - "preferred_functions", "preferred_industries", "work_environment_column", "time", "role", "carrer_preference_details", - "skill", "certification_details", "internship", "branch", "github", "medium", "linkedin", "profession", "looking_for_job", - "work_environment", "dream_companies", "career_preference_column", "attire", "collaboration", "location_preference", - "company_type", "skill_details", "certification", "education", "work_experience", "education_details", "hide_private", - "work_experience_details", "profile_complete", "cover_image" + fields = [ "user_category", "headline", "college", "city", "verify_terms", "country", + "preferred_location", "preferred_functions", "preferred_industries", + "work_environment_column", "time", "role", "carrer_preference_details", + "skill", "certification_details", "internship", "branch", "github", + "medium", "linkedin", "profession", "looking_for_job", "cover_image" + "work_environment", "dream_companies", "career_preference_column", + "attire", "collaboration", "location_preference", "company_type", + "skill_details", "certification", "education", "work_experience", + "education_details", "hide_private", "work_experience_details", "profile_complete" ] for field in fields: diff --git a/lms/lms/dashboard_chart/course_enrollments/course_enrollments.json b/lms/lms/dashboard_chart/course_enrollments/course_enrollments.json index 6c8ed3e3..b084b91e 100644 --- a/lms/lms/dashboard_chart/course_enrollments/course_enrollments.json +++ b/lms/lms/dashboard_chart/course_enrollments/course_enrollments.json @@ -2,23 +2,26 @@ "based_on": "creation", "chart_name": "Course Enrollments", "chart_type": "Count", + "color": "#4463F0", "creation": "2021-09-30 12:23:09.414853", + "custom_options": "{\"type\": \"line\", \"axisOptions\": {\"xIsSeries\": 1}, \"lineOptions\": {\"regionFill\": 1}}", "docstatus": 0, "doctype": "Dashboard Chart", "document_type": "LMS Batch Membership", "dynamic_filters_json": "[]", "filters_json": "[]", "group_by_type": "Count", - "idx": 0, + "idx": 1, "is_public": 1, "is_standard": 1, - "last_synced_on": "2021-10-17 13:32:21.745498", - "modified": "2021-10-21 17:31:06.997133", + "last_synced_on": "2022-10-20 10:46:56.859520", + "modified": "2022-10-20 11:30:26.863008", "modified_by": "Administrator", "module": "LMS", "name": "Course Enrollments", "number_of_groups": 0, "owner": "basawaraj@erpnext.com", + "roles": [], "source": "", "time_interval": "Daily", "timeseries": 1, diff --git a/lms/lms/dashboard_chart/new_signups/new_signups.json b/lms/lms/dashboard_chart/new_signups/new_signups.json index a72c7438..0ddf4562 100644 --- a/lms/lms/dashboard_chart/new_signups/new_signups.json +++ b/lms/lms/dashboard_chart/new_signups/new_signups.json @@ -4,6 +4,7 @@ "chart_type": "Count", "color": "#4463F0", "creation": "2021-09-28 18:57:50.047656", + "custom_options": "{\"type\": \"line\", \"axisOptions\": {\"xIsSeries\": 1}, \"lineOptions\": {\"regionFill\": 1}}", "docstatus": 0, "doctype": "Dashboard Chart", "document_type": "User", @@ -13,8 +14,8 @@ "idx": 1, "is_public": 1, "is_standard": 1, - "last_synced_on": "2022-10-14 15:57:47.583435", - "modified": "2022-10-14 17:20:21.880532", + "last_synced_on": "2022-10-20 10:46:56.849265", + "modified": "2022-10-20 11:31:17.184897", "modified_by": "Administrator", "module": "LMS", "name": "New Signups", diff --git a/lms/lms/doctype/lms_course/lms_course.py b/lms/lms/doctype/lms_course/lms_course.py index 44de5bae..3b4e7e41 100644 --- a/lms/lms/doctype/lms_course/lms_course.py +++ b/lms/lms/doctype/lms_course/lms_course.py @@ -137,7 +137,10 @@ class LMSCourse(Document): def get_cohorts(self): - return frappe.get_all("Cohort", {"course": self.name}, ["name", "slug"], order_by="creation") + return frappe.get_all("Cohort", + {"course": self.name}, + ["name", "slug", "title", "begin_date", "end_date"], + order_by="creation") def get_cohort(self, cohort_slug): diff --git a/lms/lms/web_template/lms_statistics/lms_statistics.html b/lms/lms/web_template/lms_statistics/lms_statistics.html index c4d7f36b..3c8f50f2 100644 --- a/lms/lms/web_template/lms_statistics/lms_statistics.html +++ b/lms/lms/web_template/lms_statistics/lms_statistics.html @@ -1 +1,15 @@ -{% include "lms/templates/statistics.html" %} +{% if title %} +

+ {{ _(title) }} +

+{% endif %} + +{% if subtitle %} +

+ {{ _(subtitle) }} +

+{%- endif -%} + +
+ {% include "lms/templates/statistics.html" %} +
diff --git a/lms/lms/web_template/lms_statistics/lms_statistics.json b/lms/lms/web_template/lms_statistics/lms_statistics.json index 825ee411..7ef14a88 100644 --- a/lms/lms/web_template/lms_statistics/lms_statistics.json +++ b/lms/lms/web_template/lms_statistics/lms_statistics.json @@ -4,6 +4,22 @@ "docstatus": 0, "doctype": "Web Template", "fields": [ + { + "__islocal": 1, + "__unsaved": 1, + "fieldname": "title", + "fieldtype": "Data", + "label": "Title", + "reqd": 0 + }, + { + "__islocal": 1, + "__unsaved": 1, + "fieldname": "subtitle", + "fieldtype": "Text", + "label": "Subtitle", + "reqd": 0 + }, { "fieldname": "published_courses", "fieldtype": "Check", @@ -24,10 +40,10 @@ } ], "idx": 0, - "modified": "2022-09-28 17:44:37.982923", + "modified": "2022-10-20 20:10:48.490785", "modified_by": "Administrator", "module": "LMS", - "name": "Dashboard Stats", + "name": "LMS Statistics", "owner": "Administrator", "standard": 1, "template": "", diff --git a/lms/lms/widgets/CourseOutline.html b/lms/lms/widgets/CourseOutline.html index 17ce8c43..56eef3a4 100644 --- a/lms/lms/widgets/CourseOutline.html +++ b/lms/lms/widgets/CourseOutline.html @@ -1,6 +1,8 @@ +{% set chapters = get_chapters(course.name) %} + +{% if course.edit_mode or chapters | length %}
- {% set chapters = get_chapters(course.name) %} {% if course.edit_mode and course.name %} @@ -110,9 +112,14 @@ {% endif %}
+{% endif %} + +{% if chapters | length %} {{ widgets.NoPreviewModal(course=course, membership=membership) }} +{% endif %} +