From 134a04ca58221e38b4fd4c20f39b9b9a9ae6771e Mon Sep 17 00:00:00 2001 From: Afzal Wali Date: Thu, 11 Jan 2018 18:27:12 +0500 Subject: [PATCH] WL-1289 Made the certificates section on the user profile page site aware. Only the certificates earned that the user earned on that site will be visible. --- .../learner_profile/views/learner_achievements.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/openedx/features/learner_profile/views/learner_achievements.py b/openedx/features/learner_profile/views/learner_achievements.py index 059d6a1fc6..d9e8d647b3 100644 --- a/openedx/features/learner_profile/views/learner_achievements.py +++ b/openedx/features/learner_profile/views/learner_achievements.py @@ -3,6 +3,7 @@ Views to render a learner's achievements. """ from django.template.loader import render_to_string +from student.views import get_org_black_and_whitelist_for_site from lms.djangoapps.certificates import api as certificate_api from openedx.core.djangoapps.certificates.api import certificates_viewable_for_course from openedx.core.djangoapps.content.course_overviews.models import CourseOverview @@ -41,6 +42,16 @@ class LearnerAchievementsFragmentView(EdxFragmentView): course_key = course_certificate['course_key'] try: course_overview = CourseOverview.get_from_id(course_key) + site_org_whitelist, site_org_blacklist = get_org_black_and_whitelist_for_site(request.user) + + # Filter out anything that is not in the whitelist. + if site_org_whitelist and course_overview.location.org not in site_org_whitelist: + continue + + # Conversely, filter out any enrollments in the blacklist. + elif site_org_blacklist and course_overview.location.org in site_org_blacklist: + continue + course_certificate['course'] = course_overview if certificates_viewable_for_course(course_overview): passing_certificates.append(course_certificate)