diff --git a/src/edx_username_changer/BUILD b/src/edx_username_changer/BUILD index b0b8ec28..77e1995a 100644 --- a/src/edx_username_changer/BUILD +++ b/src/edx_username_changer/BUILD @@ -1,5 +1,6 @@ python_sources( name="edx_username_changer_source", + dependencies=["src/edx_username_changer/settings:edx_username_changer_settings"], ) python_distribution( diff --git a/src/edx_username_changer/LICENCE b/src/edx_username_changer/LICENCE.txt similarity index 97% rename from src/edx_username_changer/LICENCE rename to src/edx_username_changer/LICENCE.txt index 83284fb7..a303c009 100644 --- a/src/edx_username_changer/LICENCE +++ b/src/edx_username_changer/LICENCE.txt @@ -1,4 +1,4 @@ -Copyright (C) 2022 MIT Open Learning +Copyright (C) 2025 MIT Open Learning All rights reserved. diff --git a/src/edx_username_changer/README.rst b/src/edx_username_changer/README.rst index e928806b..63c14bb8 100644 --- a/src/edx_username_changer/README.rst +++ b/src/edx_username_changer/README.rst @@ -28,7 +28,7 @@ Follow these steps in a terminal on your machine: 1. Navigate to ``open-edx-plugins`` directory 2. Run ``./pants package ::``. This will create a "dist" directory inside "open-edx-plugins" directory with ".whl" & ".tar.gz" format packages for all plugins in the src directory -3. Move/copy any of the ".whl" or ".tar.gz" files for this plugin that were generated in the above step to the machine/container running Open edX (NOTE: If running devstack via Docker, you can use ``docker cp`` to copy these files into your LMS or CMS containers) +3. Move/copy any of the ".whl" or ".tar.gz" files for this plugin that were generated in the above step to the machine/container running Open edX (NOTE: If running devstack via Docker, you can use ``docker cp`` to copy these files into your LMS containers) 4. Run a shell in the machine/container running Open edX, and install this plugin using pip @@ -36,14 +36,24 @@ Follow these steps in a terminal on your machine: Configurations -------------- -To configure this plugin, you need to do the following one step: +To configure this plugin, you need to do one of the following steps: -1. Add/Enable a feature flag (ENABLE_EDX_USERNAME_CHANGER) into your environment variables (through ``private.py`` in LMS or CMS, depending upon where you are installing the plugin) +1. Add/Enable a feature flag (ENABLE_EDX_USERNAME_CHANGER) into your environment variables (through ``private.py`` in LMS) .. code-block:: FEATURES["ENABLE_EDX_USERNAME_CHANGER"] = True +2. Add/Enable a feature flag (ENABLE_EDX_USERNAME_CHANGER) into your environment variables (through ``lms.env.yml`` file) + +.. code-block:: + + FEATURES: + ... + ENABLE_EDX_USERNAME_CHANGER: True + ... + + How to use ---------- Its usage is as simple as changing the username of a user account through django's admin panel. Here are the steps (for clarity): diff --git a/src/edx_username_changer/settings/BUILD b/src/edx_username_changer/settings/BUILD new file mode 100644 index 00000000..e067bd0d --- /dev/null +++ b/src/edx_username_changer/settings/BUILD @@ -0,0 +1 @@ +python_sources(name="edx_username_changer_settings") diff --git a/src/edx_username_changer/settings/common.py b/src/edx_username_changer/settings/common.py new file mode 100644 index 00000000..66ab30ec --- /dev/null +++ b/src/edx_username_changer/settings/common.py @@ -0,0 +1,21 @@ +# noqa: INP001 + +"""Settings to provide to edX""" + + +def plugin_settings(settings): + """ + Populate common settings + """ + env_tokens = getattr(settings, "ENV_TOKENS", {}) + + # .. toggle_name: FEATURES['ENABLE_EDX_USERNAME_CHANGER'] + # .. toggle_implementation: DjangoSetting + # .. toggle_default: False + # .. toggle_description: Enable the username changer feature + # .. toggle_use_case: open_edx + # .. toggle_creation_date: 2025-01-15 + + settings.FEATURES["ENABLE_EDX_USERNAME_CHANGER"] = env_tokens.get( + "FEATURES", {} + ).get("ENABLE_EDX_USERNAME_CHANGER", False) diff --git a/src/edx_username_changer/settings/devstack.py b/src/edx_username_changer/settings/devstack.py new file mode 100644 index 00000000..82726975 --- /dev/null +++ b/src/edx_username_changer/settings/devstack.py @@ -0,0 +1,10 @@ +# noqa: INP001 + +"""Settings to provide to edX""" + + +def plugin_settings(settings): + """ + Populate devstack settings + """ + settings.FEATURES["ENABLE_EDX_USERNAME_CHANGER"] = False