From 5c4691d4128d9ddf9b4ad8b41a49e62b531a5dca Mon Sep 17 00:00:00 2001 From: qtw97 Date: Mon, 8 Jan 2024 16:14:17 -0500 Subject: [PATCH] feat: search bar --- lms/envs/common.py | 6 + lms/templates/course.html | 422 ++++++++++++++++++++++++++++++++++---- 2 files changed, 383 insertions(+), 45 deletions(-) diff --git a/lms/envs/common.py b/lms/envs/common.py index c5cbe633f387..d68430340a8f 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -678,6 +678,12 @@ # Teams feature 'ENABLE_TEAMS': True, + + # Filter feature of the filter bar + 'ENABLE_FILTER': False, + + # Sort by feature of the filter bar + 'ENABLE_SORTBY': False, # Show video bumper in LMS 'ENABLE_VIDEO_BUMPER': False, diff --git a/lms/templates/course.html b/lms/templates/course.html index db765a62abc2..fd1656bc44f1 100644 --- a/lms/templates/course.html +++ b/lms/templates/course.html @@ -1,50 +1,382 @@ -<%def name="online_help_token()"><% return "course" %> -<%namespace name='static' file='static_content.html'/> +<%page expression_filter="h"/> <%! -from django.utils.translation import gettext as _ -from django.urls import reverse -from six import text_type + import json + from django.utils.translation import ugettext as _ + from openedx.core.djangolib.js_utils import js_escaped_string, dump_js_escaped_json %> -<%page args="course" expression_filter="h"/> -
- -
-
- ${course.display_name_with_default} ${course.display_number_with_default} - +<%inherit file="../main.html" /> +<% + course_discovery_enabled = settings.FEATURES.get('ENABLE_COURSE_DISCOVERY') + filter_enabled = settings.FEATURES.get('ENABLE_FILTER') + sortby_enabled = settings.FEATURES.get('ENABLE_SORTBY') +%> + +<%namespace name='static' file='../static_content.html'/> + +% if course_discovery_enabled: +<%block name="header_extras"> + % for template_name in ["course_card", "filter_bar", "filter", "facet", "facet_option"]: + + % endfor + <%static:require_module module_name="js/discovery/discovery_factory" class_name="DiscoveryFactory"> + DiscoveryFactory( + ${course_discovery_meanings | n, dump_js_escaped_json}, + getParameterByName('search_query'), + "${user_language | n, js_escaped_string}", + "${user_timezone | n, js_escaped_string}" + ); + + +% endif + + +<%block name="pagetitle">${_("Courses")} + +
+
+
+ % if course_discovery_enabled: +
+ +
-
- -
-
    -
  • ${course.display_org_with_default}
  • -
  • ${course.display_number_with_default}
  • - % if course.advertised_start is not None: -
  • ${_("Starts")}:
  • - % else: -
  • ${_("Starts")}:
  • + + + + + + + +
    +
      + %for course in courses: +
    • + <%include file="../course.html" args="course=course" /> +
    • + %endfor +
    +
    + + % if course_discovery_enabled: + % endif -
-
-
-
-<%static:require_module_async module_name="js/dateutil_factory" class_name="DateUtilFactory"> - DateUtilFactory.transform(iterationKey=".localized_datetime"); - + + + + + + \ No newline at end of file