diff --git a/lms/djangoapps/badges/events/course_complete.py b/lms/djangoapps/badges/events/course_complete.py index 9f30e58c726d..2d1049049177 100644 --- a/lms/djangoapps/badges/events/course_complete.py +++ b/lms/djangoapps/badges/events/course_complete.py @@ -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): diff --git a/lms/djangoapps/badges/utils.py b/lms/djangoapps/badges/utils.py index ba5877c8d93a..e6ade5f5368c 100644 --- a/lms/djangoapps/badges/utils.py +++ b/lms/djangoapps/badges/utils.py @@ -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): diff --git a/lms/djangoapps/certificates/views/webview.py b/lms/djangoapps/certificates/views/webview.py index 1f6a8cd7f7db..fac41396c68d 100644 --- a/lms/djangoapps/certificates/views/webview.py +++ b/lms/djangoapps/certificates/views/webview.py @@ -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) diff --git a/openedx/core/djangoapps/user_api/accounts/serializers.py b/openedx/core/djangoapps/user_api/accounts/serializers.py index a7117b761c7e..4c8a701c81ab 100644 --- a/openedx/core/djangoapps/user_api/accounts/serializers.py +++ b/openedx/core/djangoapps/user_api/accounts/serializers.py @@ -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, diff --git a/openedx/features/learner_profile/views/learner_profile.py b/openedx/features/learner_profile/views/learner_profile.py index e7557287c831..f4e91337eda7 100644 --- a/openedx/features/learner_profile/views/learner_profile.py +++ b/openedx/features/learner_profile/views/learner_profile.py @@ -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