Skip to content

Commit

Permalink
feat: [ACI-222] feature flag for badges
Browse files Browse the repository at this point in the history
  • Loading branch information
kyrylo-kh committed Jan 12, 2024
1 parent 27f397b commit 9438bd3
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
6 changes: 6 additions & 0 deletions credentials/apps/badges/admin.py
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
10 changes: 9 additions & 1 deletion credentials/apps/badges/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
SettingsType,
PROJECT_TYPE,
)
from .toggles import is_badges_enabled, check_badges_enabled


class BadgesConfig(AppConfig):
Expand All @@ -26,4 +27,11 @@ class BadgesConfig(AppConfig):
SettingsType.TEST: {PluginSettings.RELATIVE_PATH: 'settings.test'},
},
}
}
} if is_badges_enabled() else {}

@check_badges_enabled
def ready(self):
"""
Performs initial registrations for checks, signals, etc.
"""
# TODO: from .checks import configuration_checks
29 changes: 29 additions & 0 deletions credentials/apps/badges/toggles.py
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

0 comments on commit 9438bd3

Please sign in to comment.