diff --git a/lms/hooks.py b/lms/hooks.py index 8ebc9931..db6a33de 100644 --- a/lms/hooks.py +++ b/lms/hooks.py @@ -156,6 +156,7 @@ website_route_rules = [ website_redirects = [ {"source": "/update-profile", "target": "/edit-profile"}, + {"source": "/dashboard", "target": "/users"}, ] update_website_context = [ diff --git a/lms/lms/doctype/lms_course/lms_course.py b/lms/lms/doctype/lms_course/lms_course.py index 4de53314..e5080bcd 100644 --- a/lms/lms/doctype/lms_course/lms_course.py +++ b/lms/lms/doctype/lms_course/lms_course.py @@ -12,11 +12,13 @@ from lms.lms.utils import get_chapters class LMSCourse(Document): + def validate(self): self.validate_instructors() self.validate_status() self.image = validate_image(self.image) + def validate_instructors(self): if self.is_new() and not self.instructors: frappe.get_doc({ diff --git a/lms/lms/doctype/lms_settings/lms_settings.json b/lms/lms/doctype/lms_settings/lms_settings.json index 5e0fbbe9..2341f8b1 100644 --- a/lms/lms/doctype/lms_settings/lms_settings.json +++ b/lms/lms/doctype/lms_settings/lms_settings.json @@ -5,11 +5,10 @@ "editable_grid": 1, "engine": "InnoDB", "field_order": [ - "show_search", - "force_profile_completion", - "portal_course_creation", - "column_break_2", "search_placeholder", + "portal_course_creation", + "force_profile_completion", + "column_break_2", "custom_certificate_template", "livecode_url", "signup_settings_section", @@ -55,13 +54,6 @@ "fieldtype": "Column Break" }, { - "default": "0", - "fieldname": "show_search", - "fieldtype": "Check", - "label": "Show Search on Website" - }, - { - "depends_on": "show_search", "fieldname": "search_placeholder", "fieldtype": "Data", "label": "Course List Search Bar Placeholder" @@ -150,7 +142,7 @@ "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2022-08-22 10:02:59.988499", + "modified": "2022-10-11 16:26:15.898514", "modified_by": "Administrator", "module": "LMS", "name": "LMS Settings", diff --git a/lms/patches.txt b/lms/patches.txt index 8ea2108a..24fe4bcf 100644 --- a/lms/patches.txt +++ b/lms/patches.txt @@ -32,3 +32,4 @@ lms.patches.v0_0.delete_old_module_docs #08-07-2022 lms.patches.v0_0.delete_course_web_forms #21-08-2022 lms.patches.v0_0.create_course_instructor_role #29-08-2022 lms.patches.v0_0.create_course_moderator_role +lms.patches.v0_0.set_dashboard #11-10-2022 diff --git a/lms/patches/v0_0/set_dashboard.py b/lms/patches/v0_0/set_dashboard.py new file mode 100644 index 00000000..9c24c4e5 --- /dev/null +++ b/lms/patches/v0_0/set_dashboard.py @@ -0,0 +1,4 @@ +import frappe + +def execute(): + frappe.db.set_value("Portal Settings", None, "default_portal_home", "/users") diff --git a/lms/public/css/style.css b/lms/public/css/style.css index 8d8a6e5a..6a6846a5 100644 --- a/lms/public/css/style.css +++ b/lms/public/css/style.css @@ -50,7 +50,7 @@ input[type=checkbox] { .course-card-pills { background: #ffffff; margin-left: 0; - margin-right: 1rem; + margin-right: 0.5rem; border-radius: var(--border-radius); padding: 3.5px 8px; font-size: 11px; diff --git a/lms/templates/certificates_section.html b/lms/templates/certificates_section.html index 16935676..20f02149 100644 --- a/lms/templates/certificates_section.html +++ b/lms/templates/certificates_section.html @@ -5,7 +5,7 @@ {% for certificate in certificates %} {% set course = frappe.db.get_value("LMS Course", certificate.course, ["title", "name", "image"], as_dict=True) %} -
+
{{ course.title }}
diff --git a/lms/templates/course_list.html b/lms/templates/course_list.html index 347c4283..d0bab41d 100644 --- a/lms/templates/course_list.html +++ b/lms/templates/course_list.html @@ -1,12 +1,18 @@
{% if courses | length %} -
- {{ title }} -
{% for course in courses %} {{ widgets.CourseCard(course=course, read_only=False) }} {% endfor %}
+ + {% else %} +
+ +
+
{{ _("No {0}").format(title) }}
+
{{ _("There are no {0} on this site.").format(title.lower()) }}
+
+
{% endif %}
diff --git a/lms/templates/search_course/search_course.html b/lms/templates/search_course/search_course.html index 6cd4f673..3de74cb2 100644 --- a/lms/templates/search_course/search_course.html +++ b/lms/templates/search_course/search_course.html @@ -1,13 +1,7 @@ {% set search_placeholder = frappe.db.get_single_value("LMS Settings", "search_placeholder") %} {% set portal_course_creation = frappe.db.get_single_value("LMS Settings", "portal_course_creation") %} -
- - {% if portal_course_creation == "Anyone" or has_course_instructor_role() %} - {{ _("Create a Course") }} - {% endif %} -
- +
×
diff --git a/lms/www/courses/index.html b/lms/www/courses/index.html index 21a50117..8ae83339 100644 --- a/lms/www/courses/index.html +++ b/lms/www/courses/index.html @@ -26,19 +26,95 @@
{% else %} - {% include "lms/templates/search_course/search_course.html" %} -
- {% set courses = live_courses %} - {% set title = _("Live Courses ({0})").format(courses | length) %} - {% set classes = "live-courses" %} - {% include "lms/templates/course_list.html" %} + + +
+ {{ _("All Courses") }} +
+ + {% if show_creators_section %} + + {% endif %} + + + +
+ +
+
+ {% set courses = live_courses %} + {% set title = _("Live Courses") %} + {% set classes = "live-courses" %} + {% include "lms/templates/course_list.html" %} +
+ +
+ {% set courses = upcoming_courses %} + {% set title = _("Upcoming Courses") %} + {% set classes = "upcoming-courses" %} + {% include "lms/templates/course_list.html" %} +
+ + {% if frappe.session.user != "Guest" %} +
+ {% include "lms/lms/web_template/courses_enrolled/courses_enrolled.html" %} +
+ {% endif %} + + {% if show_creators_section %} +
+ {% include "lms/templates/courses_created.html" %} +
+ {% endif %} + + {% if show_review_section %} +
+ {% include "lms/templates/courses_under_review.html" %} +
+ {% endif %} + +
- {% set courses = upcoming_courses %} - {% set title = _("Upcoming Courses ({0})").format(courses | length) %} - {% set classes = "upcoming-courses mt-10" %} - {% include "lms/templates/course_list.html" %} -
{% endif %}
diff --git a/lms/www/courses/index.py b/lms/www/courses/index.py index ce03c98a..3a92b724 100644 --- a/lms/www/courses/index.py +++ b/lms/www/courses/index.py @@ -1,18 +1,22 @@ import frappe from frappe import _ -from lms.lms.utils import check_profile_restriction, get_restriction_details +from lms.lms.utils import has_course_instructor_role, has_course_moderator_role, check_profile_restriction, get_restriction_details def get_context(context): context.no_cache = 1 context.live_courses, context.upcoming_courses = get_courses() context.restriction = check_profile_restriction() + portal_course_creation = frappe.db.get_single_value("LMS Settings", "portal_course_creation") + context.show_creators_section = frappe.session.user != "Guest" and \ + (portal_course_creation == "Anyone" or has_course_instructor_role()) + context.show_review_section = has_course_moderator_role() and frappe.session.user != "Gurst" if context.restriction: context.restriction_details = get_restriction_details() context.metatags = { - "title": _("All Live Courses"), + "title": _("Courses List"), "image": frappe.db.get_single_value("Website Settings", "banner_image"), "description": "This page lists all the courses published on our website", "keywords": "All Courses, Courses, Learn" diff --git a/lms/www/dashboard/__init__.py b/lms/www/dashboard/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lms/www/dashboard/index.html b/lms/www/dashboard/index.html deleted file mode 100644 index 9188faa2..00000000 --- a/lms/www/dashboard/index.html +++ /dev/null @@ -1,75 +0,0 @@ -{% extends "templates/base.html" %} -{% block title %} -{{ _("Dashboard")}} -{% endblock %} - - -{% block content %} - -
-
- - {% if show_creators_section %} - - {{ _("Create a Course") }} - - {% endif %} - - - -
- -
-
- {% include "lms/lms/web_template/courses_enrolled/courses_enrolled.html" %} -
- - {% if show_creators_section %} -
- {% include "lms/templates/courses_created.html" %} -
- {% endif %} - - {% if show_review_section %} -
- {% include "lms/templates/courses_under_review.html" %} -
- {% endif %} - -
- {% include "lms/templates/notifications.html" %} -
- -
-
-
- - - -{% endblock %} diff --git a/lms/www/dashboard/index.py b/lms/www/dashboard/index.py deleted file mode 100644 index df19be65..00000000 --- a/lms/www/dashboard/index.py +++ /dev/null @@ -1,24 +0,0 @@ -import frappe -from datetime import datetime -from lms.lms.utils import has_course_instructor_role, has_course_moderator_role, get_lesson_index - - -def get_context(context): - context.no_cache = 1 - portal_course_creation = frappe.db.get_single_value("LMS Settings", "portal_course_creation") - context.show_creators_section = portal_course_creation == "Anyone" or has_course_instructor_role() - context.show_review_section = has_course_moderator_role() - context.notifications = get_notifications() - - -def get_notifications(): - notifications = frappe.get_all("Notification Log", { - "document_type": "Course Lesson", - "for_user": frappe.session.user - }, ["subject", "creation", "from_user", "document_name"]) - - for notification in notifications: - course = frappe.db.get_value("Course Lesson", notification.document_name, "course") - notification.url = "/courses/{0}/learn/{1}".format(course, get_lesson_index(notification.document_name)) - - return notifications diff --git a/lms/www/profiles/profile.html b/lms/www/profiles/profile.html index 539da3c8..1a979f51 100644 --- a/lms/www/profiles/profile.html +++ b/lms/www/profiles/profile.html @@ -23,6 +23,14 @@ + {% if not read_only %} + + {% endif %} + {% if courses_created | length %} {% endif %} + {% if not read_only %} + + {% endif %} + {% if has_course_moderator_role() %}
+ {% if not read_only %} +
+ {% include "lms/lms/web_template/courses_enrolled/courses_enrolled.html" %} +
+ {% endif %} + {% if courses_created | length %} {% set only_published = True %}
@@ -78,6 +99,12 @@
{% endif %} + {% if not read_only %} +
+ {% include "lms/templates/notifications.html" %} +
+ {% endif %} +
{{ RoleSettings(member) }}
@@ -117,7 +144,7 @@ {% if frappe.session.user == member.email %}
- {{ _("Visit Dashboard") }} + {{ _("Course List") }} {{ _("Edit Profile") }}
{% endif %} @@ -176,7 +203,7 @@
{{ _("Role Settings") }}
-
+