forked from openedx/credentials
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [ACI-222] feature flag for badges
- Loading branch information
Showing
3 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
""" | ||
Admin section configuration. | ||
""" | ||
|
||
from .toggles import is_badges_enabled | ||
|
||
if is_badges_enabled(): | ||
# TODO: Define registering admin classes here `admin.site.register(...)` | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,32 @@ | ||
""" | ||
Toggles for badges app. | ||
""" | ||
|
||
from edx_toggles.toggles import SettingToggle | ||
|
||
# .. toggle_name: BADGES_ENABLED | ||
# .. toggle_implementation: DjangoSetting | ||
# .. toggle_default: False | ||
# .. toggle_description: Determines if the Credentials IDA uses badges functionality. | ||
# .. toggle_life_expectancy: permanent | ||
# .. toggle_permanent_justification: Badges are optional for usage. | ||
# .. toggle_creation_date: 2024-01-12 | ||
# .. toggle_use_cases: open_edx | ||
ENABLE_BADGES = SettingToggle('BADGES_ENABLED', default=False, module_name=__name__) | ||
|
||
|
||
def is_badges_enabled(): | ||
""" | ||
Checks if badges app enabled. | ||
""" | ||
return ENABLE_BADGES.is_enabled() | ||
|
||
|
||
def check_badges_enabled(func): | ||
""" | ||
Decorator for checking the applicability of a badges app. | ||
""" | ||
def wrapper(*args, **kwargs): | ||
if is_badges_enabled(): | ||
return func(*args, **kwargs) | ||
return wrapper |