Commit 77654cae by Martyn James Committed by Jonathan Piacenti

Ensure that API calls using anonymous user have the user object containing an…

Ensure that API calls using anonymous user have the user object containing an attribute 'known', set to False
parent f581f4f8
""" Centralized access to LMS courseware app """ """ Centralized access to LMS courseware app """
from django.contrib.auth.models import AnonymousUser
from django.utils import timezone from django.utils import timezone
from courseware import courses, module_render from courseware import courses, module_render
...@@ -11,6 +12,10 @@ from xmodule.modulestore.django import modulestore ...@@ -11,6 +12,10 @@ from xmodule.modulestore.django import modulestore
from xmodule.modulestore.exceptions import ItemNotFoundError from xmodule.modulestore.exceptions import ItemNotFoundError
def _anonymous_known_flag(user):
if isinstance(user, AnonymousUser):
user.known = False
def get_modulestore(): def get_modulestore():
return modulestore() return modulestore()
...@@ -19,6 +24,7 @@ def get_course(request, user, course_id, depth=0, load_content=False): ...@@ -19,6 +24,7 @@ def get_course(request, user, course_id, depth=0, load_content=False):
""" """
Utility method to obtain course components Utility method to obtain course components
""" """
_anonymous_known_flag(user)
course_descriptor = None course_descriptor = None
course_content = None course_content = None
course_key = get_course_key(course_id) course_key = get_course_key(course_id)
...@@ -33,6 +39,7 @@ def get_course_child(request, user, course_key, content_id, load_content=False): ...@@ -33,6 +39,7 @@ def get_course_child(request, user, course_key, content_id, load_content=False):
""" """
Return a course xmodule/xblock to the caller Return a course xmodule/xblock to the caller
""" """
_anonymous_known_flag(user)
child_descriptor = None child_descriptor = None
child_content = None child_content = None
child_key = get_course_child_key(content_id) child_key = get_course_child_key(content_id)
......
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