Commit a2524c51 by Don Mitchell Committed by Calen Pennington

Force locations to be Location objects earlier

parent ddfbe598
...@@ -2,12 +2,13 @@ from auth.authz import STAFF_ROLE_NAME, INSTRUCTOR_ROLE_NAME ...@@ -2,12 +2,13 @@ from auth.authz import STAFF_ROLE_NAME, INSTRUCTOR_ROLE_NAME
from auth.authz import is_user_in_course_group_role from auth.authz import is_user_in_course_group_role
from django.core.exceptions import PermissionDenied from django.core.exceptions import PermissionDenied
from ..utils import get_course_location_for_item from ..utils import get_course_location_for_item
from xmodule.modulestore import Location
def get_location_and_verify_access(request, org, course, name): def get_location_and_verify_access(request, org, course, name):
""" """
Create the location tuple verify that the user has permissions Create the location, verify that the user has permissions
to view the location. Returns the location. to view the location. Returns the location as a Location
""" """
location = ['i4x', org, course, 'course', name] location = ['i4x', org, course, 'course', name]
...@@ -15,7 +16,7 @@ def get_location_and_verify_access(request, org, course, name): ...@@ -15,7 +16,7 @@ def get_location_and_verify_access(request, org, course, name):
if not has_access(request.user, location): if not has_access(request.user, location):
raise PermissionDenied() raise PermissionDenied()
return location return Location(location)
def has_access(user, location, role=STAFF_ROLE_NAME): def has_access(user, location, role=STAFF_ROLE_NAME):
......
...@@ -258,7 +258,7 @@ def import_course(request, org, course, name): ...@@ -258,7 +258,7 @@ def import_course(request, org, course, name):
_module_store, course_items = import_from_xml(modulestore('direct'), settings.GITHUB_REPO_ROOT, _module_store, course_items = import_from_xml(modulestore('direct'), settings.GITHUB_REPO_ROOT,
[course_subdir], load_error_modules=False, [course_subdir], load_error_modules=False,
static_content_store=contentstore(), static_content_store=contentstore(),
target_location_namespace=Location(location), target_location_namespace=location,
draft_store=modulestore()) draft_store=modulestore())
# we can blow this away when we're done importing. # we can blow this away when we're done importing.
......
...@@ -153,7 +153,7 @@ def course_info(request, org, course, name, provided_id=None): ...@@ -153,7 +153,7 @@ def course_info(request, org, course, name, provided_id=None):
course_module = modulestore().get_item(location) course_module = modulestore().get_item(location)
# get current updates # get current updates
location = ['i4x', org, course, 'course_info', "updates"] location = Location(['i4x', org, course, 'course_info', "updates"])
return render_to_response('course_info.html', { return render_to_response('course_info.html', {
'active_tab': 'courseinfo-tab', 'active_tab': 'courseinfo-tab',
......
...@@ -74,7 +74,7 @@ class CourseDetails(object): ...@@ -74,7 +74,7 @@ class CourseDetails(object):
Decode the json into CourseDetails and save any changed attrs to the db Decode the json into CourseDetails and save any changed attrs to the db
""" """
# TODO make it an error for this to be undefined & for it to not be retrievable from modulestore # TODO make it an error for this to be undefined & for it to not be retrievable from modulestore
course_location = jsondict['course_location'] course_location = Location(jsondict['course_location'])
# Will probably want to cache the inflight courses because every blur generates an update # Will probably want to cache the inflight courses because every blur generates an update
descriptor = get_modulestore(course_location).get_item(course_location) descriptor = get_modulestore(course_location).get_item(course_location)
......
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