Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

edx-username-changer plugin settings added #424

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

marslanabdulrauf
Copy link
Contributor

@marslanabdulrauf marslanabdulrauf commented Jan 10, 2025

What are the relevant tickets?

https://github.com/mitodl/hq/issues/6381

Description (What does it do?)

This PR adds plugin settings for edx_username_changer and update docs

src/edx_username_changer/LICENCE.txt Outdated Show resolved Hide resolved
@@ -38,7 +38,7 @@ Configurations
--------------
To configure this plugin, you need to do the following one step:

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove CMS from line 31 as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not if the plugins works well both from LMS and CMS, Check my above comment on BUILD file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove cms from entry_points

docs: update licence year
Copy link
Contributor

@Anas12091101 Anas12091101 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Comment on lines 21 to 24
"lms.djangoapp": [
"edx_username_changer = edx_username_changer.apps:EdxUsernameChangerConfig",
],
"cms.djangoapp": [
"edx_username_changer = edx_username_changer.apps:EdxUsernameChangerConfig",
],
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be removed, The BUILD file translates to the Setup.py file when the bundle is generated. The older code registers the plugin in both LMS, CMS. My previous comment was about registering singles in Apps.py instead.

In response to https://github.com/mitodl/open-edx-plugins/pull/420/files#r1908801121, I would recommend testing the username changer from original repo or PyPI and see if it allows the username changes both from LMS and CMS, I believe it would. In which case we should not remove CMS from here and mention this accordingly in the Readme.

@@ -38,7 +38,7 @@ Configurations
--------------
To configure this plugin, you need to do the following one step:

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not if the plugins works well both from LMS and CMS, Check my above comment on BUILD file.

Comment on lines 10 to 18
env_tokens = getattr(settings, "ENV_TOKENS", {})

# .. setting_name: ENABLE_EDX_USERNAME_CHANGER
# .. setting_default: False
# .. setting_description: Enable/Disable the username changer plugin

settings.ENABLE_EDX_USERNAME_CHANGER = env_tokens.get(
"ENABLE_EDX_USERNAME_CHANGER", False
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using the feature flag from settings.FEATURES. I don't think this plugin will work if the flag is defined here directly in settings instead of FEATURES. The actual usage is done from FEATURES instead. See This.

This makes the settings and their usage inconsistent.

@Anas12091101 I think in your testing you still had the username changer in the features dictionary that's why this would have worked.

Copy link
Contributor

@Anas12091101 Anas12091101 Jan 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked into this and found that ENV_TOKENS are loaded into settings from the lms.env.yml file. We primarily use private.py for setting feature flags. I think we can directly enable the flag with settings.FEATURES["ENABLE_EDX_USERNAME_CHANGER"] = True in our settings instead of using ENV_TOKENS. A similar example can be seen in the ol_openedx_git_auto_export plugin. What do you think, @arslanashraf7?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good to me

Comment on lines 12 to 14
# .. setting_name: ENABLE_EDX_USERNAME_CHANGER
# .. setting_default: False
# .. setting_description: Enable/Disable the username changer plugin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The setting docs look different for feature flags too. An example is ALLOW_PUBLIC_ACCOUNT_CREATION

Copy link
Contributor

@arslanashraf7 arslanashraf7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall. I didn't test the PR myself. I am ok if @Anas12091101 has tested the PR and it works well.

Copy link
Contributor

@Anas12091101 Anas12091101 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some small changes.

# .. toggle_use_case: open_edx
# .. toggle_creation_date: 2025-01-15

settings.FEATURES.ENABLE_EDX_USERNAME_CHANGER = env_tokens.get("FEATURES", {}).get(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
settings.FEATURES.ENABLE_EDX_USERNAME_CHANGER = env_tokens.get("FEATURES", {}).get(
settings.FEATURES["ENABLE_EDX_USERNAME_CHANGER"] = env_tokens.get("FEATURES", {}).get(

"""
Populate devstack settings
"""
settings.FEATURES.ENABLE_EDX_USERNAME_CHANGER = False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
settings.FEATURES.ENABLE_EDX_USERNAME_CHANGER = False
settings.FEATURES["ENABLE_EDX_USERNAME_CHANGER"] = False

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants