Commit 9ae83338 by Calen Pennington

Whitespace cleanup

parent 95f2c9e2
...@@ -132,7 +132,7 @@ def has_access(user, location, role=STAFF_ROLE_NAME): ...@@ -132,7 +132,7 @@ def has_access(user, location, role=STAFF_ROLE_NAME):
Return True if user allowed to access this piece of data Return True if user allowed to access this piece of data
Note that the CMS permissions model is with respect to courses Note that the CMS permissions model is with respect to courses
There is a super-admin permissions if user.is_staff is set There is a super-admin permissions if user.is_staff is set
Also, since we're unifying the user database between LMS and CAS, Also, since we're unifying the user database between LMS and CAS,
I'm presuming that the course instructor (formally known as admin) I'm presuming that the course instructor (formally known as admin)
will not be in both INSTRUCTOR and STAFF groups, so we have to cascade our queries here as INSTRUCTOR will not be in both INSTRUCTOR and STAFF groups, so we have to cascade our queries here as INSTRUCTOR
has all the rights that STAFF do has all the rights that STAFF do
...@@ -154,7 +154,7 @@ def course_index(request, org, course, name): ...@@ -154,7 +154,7 @@ def course_index(request, org, course, name):
org, course, name: Attributes of the Location for the item to edit org, course, name: Attributes of the Location for the item to edit
""" """
location = ['i4x', org, course, 'course', name] location = ['i4x', org, course, 'course', name]
# check that logged in user has permissions to this item # check that logged in user has permissions to this item
if not has_access(request.user, location): if not has_access(request.user, location):
raise PermissionDenied() raise PermissionDenied()
...@@ -213,7 +213,7 @@ def edit_subsection(request, location): ...@@ -213,7 +213,7 @@ def edit_subsection(request, location):
# remove all metadata from the generic dictionary that is presented in a more normalized UI # remove all metadata from the generic dictionary that is presented in a more normalized UI
policy_metadata = dict((key,value) for key, value in item.metadata.iteritems() policy_metadata = dict((key,value) for key, value in item.metadata.iteritems()
if key not in ['display_name', 'start', 'due', 'format'] and key not in item.system_metadata_fields) if key not in ['display_name', 'start', 'due', 'format'] and key not in item.system_metadata_fields)
can_view_live = False can_view_live = False
...@@ -292,7 +292,7 @@ def edit_unit(request, location): ...@@ -292,7 +292,7 @@ def edit_unit(request, location):
containing_section = modulestore().get_item(containing_section_locs[0]) containing_section = modulestore().get_item(containing_section_locs[0])
# cdodge hack. We're having trouble previewing drafts via jump_to redirect # cdodge hack. We're having trouble previewing drafts via jump_to redirect
# so let's generate the link url here # so let's generate the link url here
# need to figure out where this item is in the list of children as the preview will need this # need to figure out where this item is in the list of children as the preview will need this
index =1 index =1
...@@ -303,12 +303,12 @@ def edit_unit(request, location): ...@@ -303,12 +303,12 @@ def edit_unit(request, location):
preview_lms_link = '//{preview}{lms_base}/courses/{org}/{course}/{course_name}/courseware/{section}/{subsection}/{index}'.format( preview_lms_link = '//{preview}{lms_base}/courses/{org}/{course}/{course_name}/courseware/{section}/{subsection}/{index}'.format(
preview='preview.', preview='preview.',
lms_base=settings.LMS_BASE, lms_base=settings.LMS_BASE,
org=course.location.org, org=course.location.org,
course=course.location.course, course=course.location.course,
course_name=course.location.name, course_name=course.location.name,
section=containing_section.location.name, section=containing_section.location.name,
subsection=containing_subsection.location.name, subsection=containing_subsection.location.name,
index=index) index=index)
unit_state = compute_unit_state(item) unit_state = compute_unit_state(item)
...@@ -359,14 +359,14 @@ def assignment_type_update(request, org, course, category, name): ...@@ -359,14 +359,14 @@ def assignment_type_update(request, org, course, category, name):
location = Location(['i4x', org, course, category, name]) location = Location(['i4x', org, course, category, name])
if not has_access(request.user, location): if not has_access(request.user, location):
raise HttpResponseForbidden() raise HttpResponseForbidden()
if request.method == 'GET': if request.method == 'GET':
return HttpResponse(json.dumps(CourseGradingModel.get_section_grader_type(location)), return HttpResponse(json.dumps(CourseGradingModel.get_section_grader_type(location)),
mimetype="application/json") mimetype="application/json")
elif request.method == 'POST': # post or put, doesn't matter. elif request.method == 'POST': # post or put, doesn't matter.
return HttpResponse(json.dumps(CourseGradingModel.update_section_grader_type(location, request.POST)), return HttpResponse(json.dumps(CourseGradingModel.update_section_grader_type(location, request.POST)),
mimetype="application/json") mimetype="application/json")
def user_author_string(user): def user_author_string(user):
'''Get an author string for commits by this user. Format: '''Get an author string for commits by this user. Format:
...@@ -511,20 +511,20 @@ def load_preview_module(request, preview_id, descriptor, instance_state, shared_ ...@@ -511,20 +511,20 @@ def load_preview_module(request, preview_id, descriptor, instance_state, shared_
error_msg=exc_info_to_str(sys.exc_info()) error_msg=exc_info_to_str(sys.exc_info())
).xmodule_constructor(system)(None, None) ).xmodule_constructor(system)(None, None)
# cdodge: Special case # cdodge: Special case
if module.location.category == 'static_tab': if module.location.category == 'static_tab':
module.get_html = wrap_xmodule( module.get_html = wrap_xmodule(
module.get_html, module.get_html,
module, module,
"xmodule_tab_display.html", "xmodule_tab_display.html",
) )
else: else:
module.get_html = wrap_xmodule( module.get_html = wrap_xmodule(
module.get_html, module.get_html,
module, module,
"xmodule_display.html", "xmodule_display.html",
) )
module.get_html = replace_static_urls( module.get_html = replace_static_urls(
module.get_html, module.get_html,
'/static/' + module.metadata.get('data_dir', module.location.course), '/static/' + module.metadata.get('data_dir', module.location.course),
...@@ -555,7 +555,7 @@ def _xmodule_recurse(item, action): ...@@ -555,7 +555,7 @@ def _xmodule_recurse(item, action):
_xmodule_recurse(child, action) _xmodule_recurse(child, action)
action(item) action(item)
@login_required @login_required
@expect_json @expect_json
...@@ -590,7 +590,7 @@ def delete_item(request): ...@@ -590,7 +590,7 @@ def delete_item(request):
# delete_item on a vertical tries to delete the draft version leaving the # delete_item on a vertical tries to delete the draft version leaving the
# requested delete to never occur # requested delete to never occur
if item.location.revision is None and item.location.category=='vertical' and delete_all_versions: if item.location.revision is None and item.location.category=='vertical' and delete_all_versions:
modulestore('direct').delete_item(item.location) modulestore('direct').delete_item(item.location)
return HttpResponse() return HttpResponse()
...@@ -609,7 +609,7 @@ def save_item(request): ...@@ -609,7 +609,7 @@ def save_item(request):
if request.POST.get('data') is not None: if request.POST.get('data') is not None:
data = request.POST['data'] data = request.POST['data']
store.update_item(item_location, data) store.update_item(item_location, data)
# cdodge: note calling request.POST.get('children') will return None if children is an empty array # cdodge: note calling request.POST.get('children') will return None if children is an empty array
# so it lead to a bug whereby the last component to be deleted in the UI was not actually # so it lead to a bug whereby the last component to be deleted in the UI was not actually
# deleting the children object from the children collection # deleting the children object from the children collection
...@@ -699,7 +699,7 @@ def unpublish_unit(request): ...@@ -699,7 +699,7 @@ def unpublish_unit(request):
def clone_item(request): def clone_item(request):
parent_location = Location(request.POST['parent_location']) parent_location = Location(request.POST['parent_location'])
template = Location(request.POST['template']) template = Location(request.POST['template'])
display_name = request.POST.get('display_name') display_name = request.POST.get('display_name')
if not has_access(request.user, parent_location): if not has_access(request.user, parent_location):
...@@ -739,9 +739,9 @@ def upload_asset(request, org, course, coursename): ...@@ -739,9 +739,9 @@ def upload_asset(request, org, course, coursename):
location = ['i4x', org, course, 'course', coursename] location = ['i4x', org, course, 'course', coursename]
if not has_access(request.user, location): if not has_access(request.user, location):
return HttpResponseForbidden() return HttpResponseForbidden()
# Does the course actually exist?!? Get anything from it to prove its existance # Does the course actually exist?!? Get anything from it to prove its existance
try: try:
item = modulestore().get_item(location) item = modulestore().get_item(location)
except: except:
...@@ -775,9 +775,9 @@ def upload_asset(request, org, course, coursename): ...@@ -775,9 +775,9 @@ def upload_asset(request, org, course, coursename):
# readback the saved content - we need the database timestamp # readback the saved content - we need the database timestamp
readback = contentstore().find(content.location) readback = contentstore().find(content.location)
response_payload = {'displayname' : content.name, response_payload = {'displayname' : content.name,
'uploadDate' : get_date_display(readback.last_modified_at), 'uploadDate' : get_date_display(readback.last_modified_at),
'url' : StaticContent.get_url_path_from_location(content.location), 'url' : StaticContent.get_url_path_from_location(content.location),
'thumb_url' : StaticContent.get_url_path_from_location(thumbnail_location) if thumbnail_content is not None else None, 'thumb_url' : StaticContent.get_url_path_from_location(thumbnail_location) if thumbnail_content is not None else None,
'msg' : 'Upload completed' 'msg' : 'Upload completed'
...@@ -793,7 +793,7 @@ This view will return all CMS users who are editors for the specified course ...@@ -793,7 +793,7 @@ This view will return all CMS users who are editors for the specified course
@login_required @login_required
@ensure_csrf_cookie @ensure_csrf_cookie
def manage_users(request, location): def manage_users(request, location):
# check that logged in user has permissions to this item # check that logged in user has permissions to this item
if not has_access(request.user, location, role=INSTRUCTOR_ROLE_NAME) and not has_access(request.user, location, role=STAFF_ROLE_NAME): if not has_access(request.user, location, role=INSTRUCTOR_ROLE_NAME) and not has_access(request.user, location, role=STAFF_ROLE_NAME):
raise PermissionDenied() raise PermissionDenied()
...@@ -809,7 +809,7 @@ def manage_users(request, location): ...@@ -809,7 +809,7 @@ def manage_users(request, location):
'allow_actions' : has_access(request.user, location, role=INSTRUCTOR_ROLE_NAME), 'allow_actions' : has_access(request.user, location, role=INSTRUCTOR_ROLE_NAME),
'request_user_id' : request.user.id 'request_user_id' : request.user.id
}) })
def create_json_response(errmsg = None): def create_json_response(errmsg = None):
if errmsg is not None: if errmsg is not None:
...@@ -831,13 +831,13 @@ def add_user(request, location): ...@@ -831,13 +831,13 @@ def add_user(request, location):
if email=='': if email=='':
return create_json_response('Please specify an email address.') return create_json_response('Please specify an email address.')
# check that logged in user has admin permissions to this course # check that logged in user has admin permissions to this course
if not has_access(request.user, location, role=INSTRUCTOR_ROLE_NAME): if not has_access(request.user, location, role=INSTRUCTOR_ROLE_NAME):
raise PermissionDenied() raise PermissionDenied()
user = get_user_by_email(email) user = get_user_by_email(email)
# user doesn't exist?!? Return error. # user doesn't exist?!? Return error.
if user is None: if user is None:
return create_json_response('Could not find user by email address \'{0}\'.'.format(email)) return create_json_response('Could not find user by email address \'{0}\'.'.format(email))
...@@ -860,7 +860,7 @@ the specified course ...@@ -860,7 +860,7 @@ the specified course
@ensure_csrf_cookie @ensure_csrf_cookie
def remove_user(request, location): def remove_user(request, location):
email = request.POST["email"] email = request.POST["email"]
# check that logged in user has admin permissions on this course # check that logged in user has admin permissions on this course
if not has_access(request.user, location, role=INSTRUCTOR_ROLE_NAME): if not has_access(request.user, location, role=INSTRUCTOR_ROLE_NAME):
raise PermissionDenied() raise PermissionDenied()
...@@ -887,7 +887,7 @@ def landing(request, org, course, coursename): ...@@ -887,7 +887,7 @@ def landing(request, org, course, coursename):
def static_pages(request, org, course, coursename): def static_pages(request, org, course, coursename):
location = ['i4x', org, course, 'course', coursename] location = ['i4x', org, course, 'course', coursename]
# check that logged in user has permissions to this item # check that logged in user has permissions to this item
if not has_access(request.user, location): if not has_access(request.user, location):
raise PermissionDenied() raise PermissionDenied()
...@@ -906,7 +906,7 @@ def edit_static(request, org, course, coursename): ...@@ -906,7 +906,7 @@ def edit_static(request, org, course, coursename):
@login_required @login_required
@ensure_csrf_cookie @ensure_csrf_cookie
def edit_tabs(request, org, course, coursename): def edit_tabs(request, org, course, coursename):
location = ['i4x', org, course, 'course', coursename] location = ['i4x', org, course, 'course', coursename]
course_item = modulestore().get_item(location) course_item = modulestore().get_item(location)
static_tabs_loc = Location('i4x', org, course, 'static_tab', None) static_tabs_loc = Location('i4x', org, course, 'static_tab', None)
...@@ -928,7 +928,7 @@ def edit_tabs(request, org, course, coursename): ...@@ -928,7 +928,7 @@ def edit_tabs(request, org, course, coursename):
return render_to_response('edit-tabs.html', { return render_to_response('edit-tabs.html', {
'active_tab': 'pages', 'active_tab': 'pages',
'context_course':course_item, 'context_course':course_item,
'components': components 'components': components
}) })
...@@ -949,13 +949,13 @@ def course_info(request, org, course, name, provided_id=None): ...@@ -949,13 +949,13 @@ def course_info(request, org, course, name, provided_id=None):
org, course, name: Attributes of the Location for the item to edit org, course, name: Attributes of the Location for the item to edit
""" """
location = ['i4x', org, course, 'course', name] location = ['i4x', org, course, 'course', name]
# check that logged in user has permissions to this item # check that logged in user has permissions to this item
if not has_access(request.user, location): if not has_access(request.user, location):
raise PermissionDenied() raise PermissionDenied()
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 = ['i4x', org, course, 'course_info', "updates"]
...@@ -966,7 +966,7 @@ def course_info(request, org, course, name, provided_id=None): ...@@ -966,7 +966,7 @@ def course_info(request, org, course, name, provided_id=None):
'course_updates' : json.dumps(get_course_updates(location)), 'course_updates' : json.dumps(get_course_updates(location)),
'handouts_location': Location(['i4x', org, course, 'course_info', 'handouts']).url() 'handouts_location': Location(['i4x', org, course, 'course_info', 'handouts']).url()
}) })
@expect_json @expect_json
@login_required @login_required
@ensure_csrf_cookie @ensure_csrf_cookie
...@@ -980,7 +980,7 @@ def course_info_updates(request, org, course, provided_id=None): ...@@ -980,7 +980,7 @@ def course_info_updates(request, org, course, provided_id=None):
# ??? No way to check for access permission afaik # ??? No way to check for access permission afaik
# get current updates # get current updates
location = ['i4x', org, course, 'course_info', "updates"] location = ['i4x', org, course, 'course_info', "updates"]
# Hmmm, provided_id is coming as empty string on create whereas I believe it used to be None :-( # Hmmm, provided_id is coming as empty string on create whereas I believe it used to be None :-(
# Possibly due to my removing the seemingly redundant pattern in urls.py # Possibly due to my removing the seemingly redundant pattern in urls.py
if provided_id == '': if provided_id == '':
...@@ -995,7 +995,7 @@ def course_info_updates(request, org, course, provided_id=None): ...@@ -995,7 +995,7 @@ def course_info_updates(request, org, course, provided_id=None):
real_method = request.META['HTTP_X_HTTP_METHOD_OVERRIDE'] real_method = request.META['HTTP_X_HTTP_METHOD_OVERRIDE']
else: else:
real_method = request.method real_method = request.method
if request.method == 'GET': if request.method == 'GET':
return HttpResponse(json.dumps(get_course_updates(location)), mimetype="application/json") return HttpResponse(json.dumps(get_course_updates(location)), mimetype="application/json")
elif real_method == 'DELETE': # coming as POST need to pull from Request Header X-HTTP-Method-Override DELETE elif real_method == 'DELETE': # coming as POST need to pull from Request Header X-HTTP-Method-Override DELETE
...@@ -1012,7 +1012,7 @@ def course_info_updates(request, org, course, provided_id=None): ...@@ -1012,7 +1012,7 @@ def course_info_updates(request, org, course, provided_id=None):
@ensure_csrf_cookie @ensure_csrf_cookie
def module_info(request, module_location): def module_info(request, module_location):
location = Location(module_location) location = Location(module_location)
# check that logged in user has permissions to this item # check that logged in user has permissions to this item
if not has_access(request.user, location): if not has_access(request.user, location):
raise PermissionDenied() raise PermissionDenied()
...@@ -1025,10 +1025,10 @@ def module_info(request, module_location): ...@@ -1025,10 +1025,10 @@ def module_info(request, module_location):
rewrite_static_links = request.GET.get('rewrite_url_links','True') in ['True', 'true'] rewrite_static_links = request.GET.get('rewrite_url_links','True') in ['True', 'true']
logging.debug('rewrite_static_links = {0} {1}'.format(request.GET.get('rewrite_url_links','False'), rewrite_static_links)) logging.debug('rewrite_static_links = {0} {1}'.format(request.GET.get('rewrite_url_links','False'), rewrite_static_links))
# check that logged in user has permissions to this item # check that logged in user has permissions to this item
if not has_access(request.user, location): if not has_access(request.user, location):
raise PermissionDenied() raise PermissionDenied()
if real_method == 'GET': if real_method == 'GET':
return HttpResponse(json.dumps(get_module_info(get_modulestore(location), location, rewrite_static_links=rewrite_static_links)), mimetype="application/json") return HttpResponse(json.dumps(get_module_info(get_modulestore(location), location, rewrite_static_links=rewrite_static_links)), mimetype="application/json")
...@@ -1046,20 +1046,20 @@ def get_course_settings(request, org, course, name): ...@@ -1046,20 +1046,20 @@ def get_course_settings(request, org, course, name):
org, course, name: Attributes of the Location for the item to edit org, course, name: Attributes of the Location for the item to edit
""" """
location = ['i4x', org, course, 'course', name] location = ['i4x', org, course, 'course', name]
# check that logged in user has permissions to this item # check that logged in user has permissions to this item
if not has_access(request.user, location): if not has_access(request.user, location):
raise PermissionDenied() raise PermissionDenied()
course_module = modulestore().get_item(location) course_module = modulestore().get_item(location)
course_details = CourseDetails.fetch(location) course_details = CourseDetails.fetch(location)
return render_to_response('settings.html', { return render_to_response('settings.html', {
'active_tab': 'settings', 'active_tab': 'settings',
'context_course': course_module, 'context_course': course_module,
'course_details' : json.dumps(course_details, cls=CourseSettingsEncoder) 'course_details' : json.dumps(course_details, cls=CourseSettingsEncoder)
}) })
@expect_json @expect_json
@login_required @login_required
@ensure_csrf_cookie @ensure_csrf_cookie
...@@ -1082,13 +1082,13 @@ def course_settings_updates(request, org, course, name, section): ...@@ -1082,13 +1082,13 @@ def course_settings_updates(request, org, course, name, section):
elif section == 'grading': elif section == 'grading':
manager = CourseGradingModel manager = CourseGradingModel
else: return else: return
if request.method == 'GET': if request.method == 'GET':
# Cannot just do a get w/o knowing the course name :-( # Cannot just do a get w/o knowing the course name :-(
return HttpResponse(json.dumps(manager.fetch(Location(['i4x', org, course, 'course',name])), cls=CourseSettingsEncoder), return HttpResponse(json.dumps(manager.fetch(Location(['i4x', org, course, 'course',name])), cls=CourseSettingsEncoder),
mimetype="application/json") mimetype="application/json")
elif request.method == 'POST': # post or put, doesn't matter. elif request.method == 'POST': # post or put, doesn't matter.
return HttpResponse(json.dumps(manager.update_from_json(request.POST), cls=CourseSettingsEncoder), return HttpResponse(json.dumps(manager.update_from_json(request.POST), cls=CourseSettingsEncoder),
mimetype="application/json") mimetype="application/json")
@expect_json @expect_json
...@@ -1101,7 +1101,7 @@ def course_grader_updates(request, org, course, name, grader_index=None): ...@@ -1101,7 +1101,7 @@ def course_grader_updates(request, org, course, name, grader_index=None):
org, course: Attributes of the Location for the item to edit org, course: Attributes of the Location for the item to edit
""" """
location = ['i4x', org, course, 'course', name] location = ['i4x', org, course, 'course', name]
# check that logged in user has permissions to this item # check that logged in user has permissions to this item
...@@ -1112,13 +1112,13 @@ def course_grader_updates(request, org, course, name, grader_index=None): ...@@ -1112,13 +1112,13 @@ def course_grader_updates(request, org, course, name, grader_index=None):
real_method = request.META['HTTP_X_HTTP_METHOD_OVERRIDE'] real_method = request.META['HTTP_X_HTTP_METHOD_OVERRIDE']
else: else:
real_method = request.method real_method = request.method
if real_method == 'GET': if real_method == 'GET':
# Cannot just do a get w/o knowing the course name :-( # Cannot just do a get w/o knowing the course name :-(
return HttpResponse(json.dumps(CourseGradingModel.fetch_grader(Location(['i4x', org, course, 'course',name]), grader_index)), return HttpResponse(json.dumps(CourseGradingModel.fetch_grader(Location(['i4x', org, course, 'course',name]), grader_index)),
mimetype="application/json") mimetype="application/json")
elif real_method == "DELETE": elif real_method == "DELETE":
# ??? Shoudl this return anything? Perhaps success fail? # ??? Shoudl this return anything? Perhaps success fail?
CourseGradingModel.delete_grader(Location(['i4x', org, course, 'course',name]), grader_index) CourseGradingModel.delete_grader(Location(['i4x', org, course, 'course',name]), grader_index)
return HttpResponse() return HttpResponse()
elif request.method == 'POST': # post or put, doesn't matter. elif request.method == 'POST': # post or put, doesn't matter.
...@@ -1135,7 +1135,7 @@ def asset_index(request, org, course, name): ...@@ -1135,7 +1135,7 @@ def asset_index(request, org, course, name):
org, course, name: Attributes of the Location for the item to edit org, course, name: Attributes of the Location for the item to edit
""" """
location = ['i4x', org, course, 'course', name] location = ['i4x', org, course, 'course', name]
# check that logged in user has permissions to this item # check that logged in user has permissions to this item
if not has_access(request.user, location): if not has_access(request.user, location):
raise PermissionDenied() raise PermissionDenied()
...@@ -1148,7 +1148,7 @@ def asset_index(request, org, course, name): ...@@ -1148,7 +1148,7 @@ def asset_index(request, org, course, name):
}) })
course_module = modulestore().get_item(location) course_module = modulestore().get_item(location)
course_reference = StaticContent.compute_location(org, course, name) course_reference = StaticContent.compute_location(org, course, name)
assets = contentstore().get_all_content_for_course(course_reference) assets = contentstore().get_all_content_for_course(course_reference)
...@@ -1162,15 +1162,15 @@ def asset_index(request, org, course, name): ...@@ -1162,15 +1162,15 @@ def asset_index(request, org, course, name):
display_info = {} display_info = {}
display_info['displayname'] = asset['displayname'] display_info['displayname'] = asset['displayname']
display_info['uploadDate'] = get_date_display(asset['uploadDate']) display_info['uploadDate'] = get_date_display(asset['uploadDate'])
asset_location = StaticContent.compute_location(id['org'], id['course'], id['name']) asset_location = StaticContent.compute_location(id['org'], id['course'], id['name'])
display_info['url'] = StaticContent.get_url_path_from_location(asset_location) display_info['url'] = StaticContent.get_url_path_from_location(asset_location)
# note, due to the schema change we may not have a 'thumbnail_location' in the result set # note, due to the schema change we may not have a 'thumbnail_location' in the result set
_thumbnail_location = asset.get('thumbnail_location', None) _thumbnail_location = asset.get('thumbnail_location', None)
thumbnail_location = Location(_thumbnail_location) if _thumbnail_location is not None else None thumbnail_location = Location(_thumbnail_location) if _thumbnail_location is not None else None
display_info['thumb_url'] = StaticContent.get_url_path_from_location(thumbnail_location) if thumbnail_location is not None else None display_info['thumb_url'] = StaticContent.get_url_path_from_location(thumbnail_location) if thumbnail_location is not None else None
asset_display.append(display_info) asset_display.append(display_info)
return render_to_response('asset_index.html', { return render_to_response('asset_index.html', {
...@@ -1189,9 +1189,9 @@ def edge(request): ...@@ -1189,9 +1189,9 @@ def edge(request):
@expect_json @expect_json
def create_new_course(request): def create_new_course(request):
template = Location(request.POST['template']) template = Location(request.POST['template'])
org = request.POST.get('org') org = request.POST.get('org')
number = request.POST.get('number') number = request.POST.get('number')
display_name = request.POST.get('display_name') display_name = request.POST.get('display_name')
try: try:
dest_location = Location('i4x', org, number, 'course', Location.clean(display_name)) dest_location = Location('i4x', org, number, 'course', Location.clean(display_name))
...@@ -1237,13 +1237,13 @@ def initialize_course_tabs(course): ...@@ -1237,13 +1237,13 @@ def initialize_course_tabs(course):
# at least a list populated with the minimal times # at least a list populated with the minimal times
# @TODO: I don't like the fact that the presentation tier is away of these data related constraints, let's find a better # @TODO: I don't like the fact that the presentation tier is away of these data related constraints, let's find a better
# place for this. Also rather than using a simple list of dictionaries a nice class model would be helpful here # place for this. Also rather than using a simple list of dictionaries a nice class model would be helpful here
course.tabs = [{"type": "courseware"}, course.tabs = [{"type": "courseware"},
{"type": "course_info", "name": "Course Info"}, {"type": "course_info", "name": "Course Info"},
{"type": "discussion", "name": "Discussion"}, {"type": "discussion", "name": "Discussion"},
{"type": "wiki", "name": "Wiki"}, {"type": "wiki", "name": "Wiki"},
{"type": "progress", "name": "Progress"}] {"type": "progress", "name": "Progress"}]
modulestore('direct').update_metadata(course.location.url(), course.own_metadata) modulestore('direct').update_metadata(course.location.url(), course.own_metadata)
@ensure_csrf_cookie @ensure_csrf_cookie
@login_required @login_required
...@@ -1337,7 +1337,7 @@ def generate_export_course(request, org, course, name): ...@@ -1337,7 +1337,7 @@ def generate_export_course(request, org, course, name):
root_dir = path(mkdtemp()) root_dir = path(mkdtemp())
# export out to a tempdir # export out to a tempdir
logging.debug('root = {0}'.format(root_dir)) logging.debug('root = {0}'.format(root_dir))
export_to_xml(modulestore('direct'), contentstore(), loc, root_dir, name) export_to_xml(modulestore('direct'), contentstore(), loc, root_dir, name)
...@@ -1349,7 +1349,7 @@ def generate_export_course(request, org, course, name): ...@@ -1349,7 +1349,7 @@ def generate_export_course(request, org, course, name):
tf.close() tf.close()
# remove temp dir # remove temp dir
shutil.rmtree(root_dir/name) shutil.rmtree(root_dir/name)
wrapper = FileWrapper(export_file) wrapper = FileWrapper(export_file)
response = HttpResponse(wrapper, content_type='application/x-tgz') response = HttpResponse(wrapper, content_type='application/x-tgz')
......
...@@ -668,18 +668,18 @@ class CapaDescriptor(RawDescriptor): ...@@ -668,18 +668,18 @@ class CapaDescriptor(RawDescriptor):
# TODO (vshnayder): do problems have any other metadata? Do they # TODO (vshnayder): do problems have any other metadata? Do they
# actually use type and points? # actually use type and points?
metadata_attributes = RawDescriptor.metadata_attributes + ('type', 'points') metadata_attributes = RawDescriptor.metadata_attributes + ('type', 'points')
def get_context(self): def get_context(self):
_context = RawDescriptor.get_context(self) _context = RawDescriptor.get_context(self)
_context.update({'markdown': self.metadata.get('markdown', '')}) _context.update({'markdown': self.metadata.get('markdown', '')})
return _context return _context
@property @property
def editable_metadata_fields(self): def editable_metadata_fields(self):
"""Remove metadata from the editable fields since it has its own editor""" """Remove metadata from the editable fields since it has its own editor"""
subset = super(CapaDescriptor,self).editable_metadata_fields subset = super(CapaDescriptor,self).editable_metadata_fields
if 'markdown' in subset: if 'markdown' in subset:
subset.remove('markdown') subset.remove('markdown')
return subset return subset
......
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