Skip to content

Commit

Permalink
feat: [ACI-262] credly_badges feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
kyrylo-kh authored and wowkalucky committed Jan 17, 2024
1 parent 2d09429 commit a40642c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
6 changes: 6 additions & 0 deletions credentials/apps/badges/distribution/credly_badges/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
"""
Admin section configuration for credly badges.
"""

from .toggles import is_credly_badges_enabled

if is_credly_badges_enabled():
# TODO: Define registering admin classes here `admin.site.register(...)`
pass
10 changes: 9 additions & 1 deletion credentials/apps/badges/distribution/credly_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_credly_badges_enabled, check_credly_badges_enabled


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

@check_credly_badges_enabled
def ready(self):
"""
Performs initial registrations for checks, signals, etc.
"""
# TODO: from .checks import configuration_checks
31 changes: 30 additions & 1 deletion credentials/apps/badges/distribution/credly_badges/toggles.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
"""
Toggles for credly badges app.
"""
"""

from edx_toggles.toggles import SettingToggle

# .. toggle_name: CREDLY_BADGES_ENABLED
# .. toggle_implementation: DjangoSetting
# .. toggle_default: False
# .. toggle_description: Determines if the Credentials IDA uses credly badges functionality.
# .. toggle_life_expectancy: permanent
# .. toggle_permanent_justification: Credly badges are optional for usage.
# .. toggle_creation_date: 2024-01-16
# .. toggle_use_cases: open_edx
ENABLE_CREDLY_BADGES = SettingToggle('CREDLY_BADGES_ENABLED', default=False, module_name=__name__)


def is_credly_badges_enabled():
"""
Checks if credly badges app enabled.
"""
return ENABLE_CREDLY_BADGES.is_enabled()


def check_credly_badges_enabled(func):
"""
Decorator for checking the applicability of a credly badges app.
"""
def wrapper(*args, **kwargs):
if is_credly_badges_enabled():
return func(*args, **kwargs)
return wrapper

0 comments on commit a40642c

Please sign in to comment.