Commit 9cd26e55 by Carlos Andrés Rocha

List all courses during OAut2/OpenID Connect

Previously, only courses respective to the branded instance were returned.

AN-3610
parent 4e796c57
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
from django.conf import settings from django.conf import settings
import branding
from courseware.access import has_access from courseware.access import has_access
from student.models import anonymous_id_for_user from student.models import anonymous_id_for_user
from student.models import UserProfile from student.models import UserProfile
from user_api.models import UserPreference from user_api.models import UserPreference
from lang_pref import LANGUAGE_KEY from lang_pref import LANGUAGE_KEY
from xmodule.modulestore.django import modulestore
from xmodule.course_module import CourseDescriptor
class OpenIDHandler(object): class OpenIDHandler(object):
...@@ -151,7 +152,7 @@ class CourseAccessHandler(object): ...@@ -151,7 +152,7 @@ class CourseAccessHandler(object):
user = data['user'] user = data['user']
values = set(data.get('values', [])) values = set(data.get('values', []))
courses = branding.get_visible_courses() courses = _get_all_courses()
courses = (c for c in courses if has_access(user, access_type, c)) courses = (c for c in courses if has_access(user, access_type, c))
course_ids = (unicode(c.id) for c in courses) course_ids = (unicode(c.id) for c in courses)
...@@ -186,3 +187,13 @@ class IDTokenHandler(OpenIDHandler, ProfileHandler, CourseAccessHandler): ...@@ -186,3 +187,13 @@ class IDTokenHandler(OpenIDHandler, ProfileHandler, CourseAccessHandler):
class UserInfoHandler(OpenIDHandler, ProfileHandler, CourseAccessHandler): class UserInfoHandler(OpenIDHandler, ProfileHandler, CourseAccessHandler):
""" Configure the UserInfo handler for the LMS. """ """ Configure the UserInfo handler for the LMS. """
pass pass
def _get_all_courses():
"""
Utitilty function to list all available courses.
"""
ms_courses = modulestore().get_courses()
courses = [c for c in ms_courses if isinstance(c, CourseDescriptor)]
return courses
# pylint: disable=missing-docstring # pylint: disable=missing-docstring
from django.conf import settings
from django.test.utils import override_settings from django.test.utils import override_settings
from django.test import TestCase from django.test import TestCase
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment