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

feat: [ACI-222] feature flag for badges #52

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 4 additions & 4 deletions credentials/apps/badges/apps.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from django.apps import AppConfig

from .toggles import is_badges_enabled
from .toggles import check_badges_enabled


class BadgesConfig(AppConfig):
name = "credentials.apps.badges"
verbose_name = "Badges"

@check_badges_enabled
def ready(self):
"""
Performs initial registrations for checks, signals, etc.
"""
if is_badges_enabled():
from . import signals # pylint: disable=unused-import,import-outside-toplevel
from . checks import badges_checks # pylint: disable=unused-import,import-outside-toplevel
from . import signals # pylint: disable=unused-import,import-outside-toplevel
from . checks import badges_checks # pylint: disable=unused-import,import-outside-toplevel
26 changes: 25 additions & 1 deletion credentials/apps/badges/toggles.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,31 @@
"""


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.
"""
return True
def wrapper(*args, **kwargs):
if is_badges_enabled():
return func(*args, **kwargs)
return wrapper
7 changes: 6 additions & 1 deletion credentials/apps/badges/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
"""
URLs for badges.
"""
urlpatterns = []

from .toggles import is_badges_enabled

urlpatterns = [] if not is_badges_enabled else [
# Define urls here
]
Loading