Skip to content

Commit

Permalink
fix: remove badges_enabled parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
mfarhan943 committed Aug 22, 2023
1 parent 0f16c5a commit 99b1a8c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
5 changes: 4 additions & 1 deletion lms/djangoapps/badges/events/course_complete.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ def course_badge_check(user, course_key):
badgr_flag = get_value_from_django_settings_override('BADGR_FLAG', False, site)
badge_class = get_completion_badge(course_key, user)

if not badgr_flag or not badge_class:
if not badgr_flag:
return

if not badge_class:
# We're not configured to make a badge for this course mode.
return
if BadgeAssertion.objects.filter(user=user, badge_class=badge_class):
Expand Down
5 changes: 2 additions & 3 deletions lms/djangoapps/badges/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ def wrapped(*args, **kwargs):
return wrapped


def badges_enabled(site=None):
def badges_enabled():
"""
returns a boolean indicating whether or not openbadges are enabled.
"""
from openedx.features.edly.utils import get_value_from_django_settings_override
return get_value_from_django_settings_override('BADGR_FLAG', False, site)
return settings.FEATURES.get('ENABLE_OPENBADGES', False)


def deserialize_count_specs(text):
Expand Down
8 changes: 7 additions & 1 deletion lms/djangoapps/certificates/views/webview.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,12 +419,18 @@ def _update_badge_context(context, course, user):
Updates context with badge info.
"""
from figures.sites import get_site_for_course
from openedx.features.edly.utils import get_value_from_django_settings_override

badge = None
course_key = course.location.course_key
site = get_site_for_course(course_key)
badgr_flag = get_value_from_django_settings_override('BADGR_FLAG', False, site)

if badges_enabled(site) and course.issue_badges:
if not badgr_flag:
context['badge'] = badge
return

if badges_enabled() and course.issue_badges:
completion_badge = get_completion_badge(course.location.course_key, user)
if completion_badge is not None:
badges = completion_badge.get_for_user(user)
Expand Down
2 changes: 1 addition & 1 deletion openedx/core/djangoapps/user_api/accounts/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def to_representation(self, user):
except ObjectDoesNotExist:
account_recovery = None

accomplishments_shared = badges_enabled(self.context.get('request').site)
accomplishments_shared = badges_enabled()

data = {
"username": user.username,
Expand Down
2 changes: 1 addition & 1 deletion openedx/features/learner_profile/views/learner_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def learner_profile_context(request, profile_username, user_is_staff):
)
context['achievements_fragment'] = achievements_fragment

if badges_enabled(request.site):
if badges_enabled():
context['data']['badges_api_url'] = reverse("badges_api:user_assertions", kwargs={'username': profile_username})

return context

0 comments on commit 99b1a8c

Please sign in to comment.