From 864473f9b5e1a3a0cfce63f588b7defe7b7c1049 Mon Sep 17 00:00:00 2001 From: Muhammad Faraz Maqsood Date: Tue, 21 Jan 2025 17:33:51 +0500 Subject: [PATCH 1/2] feat: add env variable to enable/disable programs This commit includes: - This aligns with the frontend, which now also utilizes this environment variable. To view the frontend related changes, click here: https://github.com/openedx/frontend-app-learner-dashboard/pull/506/files. - Additionally, it automates the enabling of programs in the "programapiconfig" model on the LMS admin panel through init tasks. - Update the documentation accordingly. --- README.rst | 34 ++++++++++++++----- .../patches/mfe-lms-common-settings | 1 + tutordiscovery/plugin.py | 3 ++ .../templates/discovery/tasks/lms/init | 5 +++ 4 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 tutordiscovery/patches/mfe-lms-common-settings diff --git a/README.rst b/README.rst index fb57c4d..3048853 100644 --- a/README.rst +++ b/README.rst @@ -121,19 +121,30 @@ This last step should be performed every time you create new or make changes to Show Programs Tab ~~~~~~~~~~~~~~~~~ -To make the ``Programs`` tab work in the LMS dashboard, users will need to manually create an entry -in the ``Programs api config`` model in the LMS Admin Panel. Go to http://local.openedx.io/admin/programs/programsapiconfig/. -Add ``Marketing path`` equal to ``/programs`` and enable it. Then Programs tab will be shown on the LMS -where users can view their registered programs. It will show like in the below picture. +By default, the **Programs** tab is available in the LMS dashboard. Users can enable or disable this tab as needed. +To Disable Programs, run the following command: + +.. code-block:: bash + + tutor config save --set ENABLE_PROGRAMS=False + +To Enable Programs, run the following command: + +.. code-block:: bash + + tutor config save --set ENABLE_PROGRAMS=True + +Only programs in which learners are registered will appear on this page. If a learner is enrolled in any course that is part of a program, that program will be displayed here. .. image:: https://github.com/overhangio/tutor-discovery/assets/122095701/e0224011-adc0-41e4-a104-af4cb0c24b82 :alt: Programs Tab on LMS dashboard -In the above image, the user can see explore programs button which is pointing to ``http://localhost:8080/programs`` by default. -This link does not exist. So, users can change this link to their custom-built marketing site URL to show all programs there. -This can be done by modifying the ``Site Configurations`` model in the LMS Admin Panel. Go to -http://local.openedx.io/admin/site_configuration/siteconfiguration/. Open the respective LMS site configuration and add the below -dictionary in ``site values`` field like the below image: +In the image above, the **Explore Programs** button points to http://localhost:8080/programs by default. This link does not exist, so users can change it to their custom-built marketing site URL to display all programs. +To Modify the Link: + +1. Go to the **Site Configurations** model in the LMS Admin Panel: `http://local.openedx.io/admin/site_configuration/siteconfiguration/` +2. Open the respective LMS site configuration. +3. Add the following dictionary in the **site values** field like in the below image: .. code-block:: python @@ -144,6 +155,11 @@ dictionary in ``site values`` field like the below image: .. image:: https://github.com/overhangio/tutor-discovery/assets/122095701/2d588ea9-a830-40b6-9845-8fab56d7cb5a :alt: Add Custom Site for Explore Programs +By following above instructions, this link (https://custom-marketing-site-here.com) will be replaced by http://localhost:8080. Additionally, users can also replace "/programs" by following these below steps: + +1. Go to: `http://local.openedx.io/admin/programs/programsapiconfig/` +2. Add **Marketing path** equal to "/programs" or your desired marketing site path and enable it. + Install extra requirements ~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tutordiscovery/patches/mfe-lms-common-settings b/tutordiscovery/patches/mfe-lms-common-settings new file mode 100644 index 0000000..220ad93 --- /dev/null +++ b/tutordiscovery/patches/mfe-lms-common-settings @@ -0,0 +1 @@ +MFE_CONFIG["ENABLE_PROGRAMS"] = {{ ENABLE_PROGRAMS }} diff --git a/tutordiscovery/plugin.py b/tutordiscovery/plugin.py index bb47323..a1a58fc 100644 --- a/tutordiscovery/plugin.py +++ b/tutordiscovery/plugin.py @@ -50,6 +50,9 @@ "OAUTH2_SECRET": "{{ 8|random_string }}", "OAUTH2_SECRET_SSO": "{{ 8|random_string }}", }, + "overrides": { + "ENABLE_PROGRAMS": True, + }, } # Initialization tasks diff --git a/tutordiscovery/templates/discovery/tasks/lms/init b/tutordiscovery/templates/discovery/tasks/lms/init index b65d75b..16db4f9 100644 --- a/tutordiscovery/templates/discovery/tasks/lms/init +++ b/tutordiscovery/templates/discovery/tasks/lms/init @@ -6,6 +6,11 @@ "from django.contrib.auth import get_user_model;\ get_user_model().objects.filter(username='lms_catalog_service_user').exclude(email='lms_catalog_service_user@openedx').update(email='lms_catalog_service_user@openedx')" +./manage.py lms shell -c \ + "from openedx.core.djangoapps.programs.models import ProgramsApiConfig;\ + ProgramsApiConfig.current().enabled or \ + ProgramsApiConfig.objects.create(marketing_path='/programs', enabled=True)" + ./manage.py lms manage_user discovery discovery@openedx --staff --superuser --unusable-password ./manage.py lms manage_user lms_catalog_service_user lms_catalog_service_user@openedx --staff --unusable-password From 5dcb6bc09b32c8a4bd25fa89b764ebcbd1c6e035 Mon Sep 17 00:00:00 2001 From: Muhammad Faraz Maqsood Date: Tue, 21 Jan 2025 17:34:27 +0500 Subject: [PATCH 2/2] docs: add changelog entry --- ...46_faraz.maqsood_faraz_add_setting_variable_for_programs.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelog.d/20250121_170746_faraz.maqsood_faraz_add_setting_variable_for_programs.md diff --git a/changelog.d/20250121_170746_faraz.maqsood_faraz_add_setting_variable_for_programs.md b/changelog.d/20250121_170746_faraz.maqsood_faraz_add_setting_variable_for_programs.md new file mode 100644 index 0000000..fea5981 --- /dev/null +++ b/changelog.d/20250121_170746_faraz.maqsood_faraz_add_setting_variable_for_programs.md @@ -0,0 +1,3 @@ +- [Feature] Introduced a new environment variable to enable or disable programs. (by @Faraz32123) + - This aligns with the frontend, which now also utilizes this environment variable. To view the frontend related changes, click here: https://github.com/openedx/frontend-app-learner-dashboard/pull/506/files. + - Additionally, it automates the enabling of programs in the "programapiconfig" model on the LMS admin panel through init tasks.