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 %}
- {% for course in courses %}
+ {% for course in live_courses %}
{{ widgets.CourseCard(course=course, read_only=False) }}
{% endfor %}
+ {% endif %}
+
+ {% if upcoming_courses | length %}
+
+
+ {% 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