From ebc3cf1cbf0ec598c0266a12484a0025e365a217 Mon Sep 17 00:00:00 2001 From: pateljannat Date: Thu, 30 Sep 2021 18:31:41 +0530 Subject: [PATCH 1/2] feat: live and upcoming course headers --- community/www/courses/index.html | 19 +++++++++++++++++-- community/www/courses/index.py | 16 +++++++++++----- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/community/www/courses/index.html b/community/www/courses/index.html index 991108e5..07d5b5e7 100644 --- a/community/www/courses/index.html +++ b/community/www/courses/index.html @@ -9,14 +9,29 @@ {% block content %}
+ + {% if live_courses | length %}
- {{ 'All Courses' }} + {{ _('Live Courses') }}
- {% for course in courses %} + {% for course in live_courses %} {{ widgets.CourseCard(course=course, read_only=False) }} {% endfor %}
+ {% endif %} + + {% if upcoming_courses | length %} +
+ {{ _('Upcoming Courses') }} +
+
+ {% for course in upcoming_courses %} + {{ widgets.CourseCard(course=course, read_only=False) }} + {% endfor %} +
+ {% endif %} +
{% endblock %} diff --git a/community/www/courses/index.py b/community/www/courses/index.py index 6cc72787..f4981077 100644 --- a/community/www/courses/index.py +++ b/community/www/courses/index.py @@ -2,7 +2,7 @@ import frappe def get_context(context): context.no_cache = 1 - context.courses = get_courses() + context.live_courses, context.upcoming_courses = get_courses() context.metatags = { "title": "All Courses", "image": frappe.db.get_single_value("Website Settings", "banner_image"), @@ -11,8 +11,14 @@ def get_context(context): } def get_courses(): - course_names = frappe.get_all("LMS Course", filters={"is_published": True}, order_by="upcoming", pluck="name") - courses = [] + course_names = frappe.get_all("LMS Course", + filters={"is_published": True}, + fields=["name", "upcoming"]) + + live_courses, upcoming_courses = [], [] for course in course_names: - courses.append(frappe.get_doc("LMS Course", course)) - return courses + if course.upcoming: + upcoming_courses.append(frappe.get_doc("LMS Course", course.name)) + else: + live_courses.append(frappe.get_doc("LMS Course", course.name)) + return live_courses, upcoming_courses From 44e8efd39b11900ad2911ab1883915099585d208 Mon Sep 17 00:00:00 2001 From: pateljannat Date: Sat, 2 Oct 2021 13:12:04 +0530 Subject: [PATCH 2/2] fix: relaod doctypes in patch --- community/patches.txt | 2 +- .../patches/v0_0/rename_chapter_and_lesson_doctype.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/community/patches.txt b/community/patches.txt index e6d2fcb5..7e0ffe99 100644 --- a/community/patches.txt +++ b/community/patches.txt @@ -12,4 +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 #29-09-2021 +community.patches.v0_0.rename_chapter_and_lesson_doctype #30-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 index 4dd3bdca..119e1e4f 100644 --- a/community/patches/v0_0/rename_chapter_and_lesson_doctype.py +++ b/community/patches/v0_0/rename_chapter_and_lesson_doctype.py @@ -3,6 +3,14 @@ import frappe def execute(): frappe.reload_doc("lms", "doctype", "course_chapter") frappe.reload_doc("lms", "doctype", "course_lesson") + frappe.reload_doc("lms", "doctype", "chapter_reference") + frappe.reload_doc("lms", "doctype", "lesson_reference") + frappe.reload_doc("lms", "doctype", "exercise") + frappe.reload_doc("lms", "doctype", "exercise_submission") + frappe.reload_doc("lms", "doctype", "lms_batch_membership") + frappe.reload_doc("lms", "doctype", "lms_course") + frappe.reload_doc("lms", "doctype", "lms_course_progress") + frappe.reload_doc("lms", "doctype", "lms_quiz") if not frappe.db.count("Course Chapter"): move_chapters()