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.
fix: update Badges backends configuration
- Loading branch information
1 parent
a40642c
commit f28dd63
Showing
18 changed files
with
92 additions
and
87 deletions.
There are no files selected for viewing
Empty file.
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
Badges distribution conventional hooks. | ||
""" | ||
|
||
from typing import Any | ||
from django.apps import AppConfig | ||
|
||
|
||
class BadgesBackendConfig(AppConfig): | ||
""" | ||
Extended application config with additional Badge-specific logic. | ||
""" | ||
|
||
# TODO: move backend conditional configuration here. | ||
# - `plugin_app` check; | ||
# - `is_enabled` check; |
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
29 changes: 29 additions & 0 deletions
29
credentials/apps/badges/distribution/credly/credly_badges/toggles.py
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 @@ | ||
""" | ||
Credly Badges app toggles. | ||
""" | ||
|
||
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 |
1 change: 0 additions & 1 deletion
1
credentials/apps/badges/distribution/credly/requirements/base.in
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,2 +1 @@ | ||
# Main requirements of the plugin application. | ||
-c constraints.txt |
9 changes: 0 additions & 9 deletions
9
credentials/apps/badges/distribution/credly/requirements/constraints.txt
This file was deleted.
Oops, something went wrong.
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
6 changes: 0 additions & 6 deletions
6
credentials/apps/badges/distribution/credly_badges/settings/base.py
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
credentials/apps/badges/distribution/credly_badges/settings/production.py
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
credentials/apps/badges/distribution/credly_badges/settings/test.py
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
credentials/apps/badges/distribution/credly_badges/toggles.py
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
credentials/apps/badges/distribution/credly_badges/utils.py
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
""" | ||
Toggles for credly badges app. | ||
""" | ||
|
||
from django.conf import settings | ||
|
||
|
||
def is_backend_enabled(): | ||
""" | ||
Checks if Credly Badges app enabled. | ||
""" | ||
return "credly_badges" in settings.BADGES_CONFIG.get("backends", []) | ||
|
||
|
||
def if_backend_enabled(func): | ||
""" | ||
Intercept action if Credly Badges backend is not activated. | ||
""" | ||
def wrapper(*args, **kwargs): | ||
if is_backend_enabled(): | ||
return func(*args, **kwargs) | ||
return wrapper |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -585,3 +585,10 @@ | |
}, | ||
}, | ||
} | ||
|
||
# Badges Settings | ||
BADGES_CONFIG = { | ||
"backends": [ | ||
"credly_badges", | ||
] | ||
} |
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 |
---|---|---|
|
@@ -54,7 +54,6 @@ xss-utils | |
# Badges app baked-in backend plugins: | ||
-e credentials/apps/badges/distribution/credly | ||
|
||
|
||
# TODO Install in configuration | ||
git+https://github.com/openedx/[email protected]#egg=edx_credentials_themes==0.3.22 | ||
git+https://github.com/raccoongang/[email protected]#egg=openedx_events |