From 6d6b3a59fe77ea47c71d84f9877f8570e9771971 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Fri, 12 Apr 2013 15:27:36 -0400 Subject: [PATCH 1/3] violation fixes --- .../contentstore/course_info_model.py | 3 +- .../contentstore/module_info_model.py | 1 - cms/djangoapps/contentstore/utils.py | 12 +- cms/djangoapps/contentstore/views.py | 122 +++++++++--------- .../models/settings/course_details.py | 1 - .../models/settings/course_grading.py | 24 ++-- .../models/settings/course_metadata.py | 16 ++- cms/envs/aws.py | 2 +- cms/envs/common.py | 2 +- .../xmodule/xmodule/contentstore/content.py | 1 + 10 files changed, 89 insertions(+), 95 deletions(-) diff --git a/cms/djangoapps/contentstore/course_info_model.py b/cms/djangoapps/contentstore/course_info_model.py index 589db4ac56..ada3873992 100644 --- a/cms/djangoapps/contentstore/course_info_model.py +++ b/cms/djangoapps/contentstore/course_info_model.py @@ -97,8 +97,7 @@ def update_course_updates(location, update, passed_id=None): if (len(new_html_parsed) == 1): content = new_html_parsed[0].tail else: - content = "\n".join([html.tostring(ele) - for ele in new_html_parsed[1:]]) + content = "\n".join([html.tostring(ele) for ele in new_html_parsed[1:]]) return {"id": passed_id, "date": update['date'], diff --git a/cms/djangoapps/contentstore/module_info_model.py b/cms/djangoapps/contentstore/module_info_model.py index 8ea6add88d..91f722a699 100644 --- a/cms/djangoapps/contentstore/module_info_model.py +++ b/cms/djangoapps/contentstore/module_info_model.py @@ -1,7 +1,6 @@ from static_replace import replace_static_urls from xmodule.modulestore.exceptions import ItemNotFoundError from xmodule.modulestore import Location -from django.http import Http404 def get_module_info(store, location, parent_location=None, rewrite_static_links=False): diff --git a/cms/djangoapps/contentstore/utils.py b/cms/djangoapps/contentstore/utils.py index ec439b3312..a5a3b47bce 100644 --- a/cms/djangoapps/contentstore/utils.py +++ b/cms/djangoapps/contentstore/utils.py @@ -1,4 +1,3 @@ -import logging from django.conf import settings from xmodule.modulestore import Location from xmodule.modulestore.django import modulestore @@ -9,7 +8,7 @@ import copy DIRECT_ONLY_CATEGORIES = ['course', 'chapter', 'sequential', 'about', 'static_tab', 'course_info'] #In order to instantiate an open ended tab automatically, need to have this data -OPEN_ENDED_PANEL = {"name" : "Open Ended Panel", "type" : "open_ended"} +OPEN_ENDED_PANEL = {"name": "Open Ended Panel", "type": "open_ended"} def get_modulestore(location): @@ -87,11 +86,10 @@ def get_lms_link_for_item(location, preview=False, course_id=None): if settings.LMS_BASE is not None: if preview: - lms_base = settings.MITX_FEATURES.get('PREVIEW_LMS_BASE', - 'preview.' + settings.LMS_BASE) + lms_base = settings.MITX_FEATURES.get('PREVIEW_LMS_BASE', 'preview.' + settings.LMS_BASE) else: lms_base = settings.LMS_BASE - + lms_link = "//{lms_base}/courses/{course_id}/jump_to/{location}".format( lms_base=lms_base, course_id=course_id, @@ -193,6 +191,7 @@ class CoursePageNames: CourseOutline = "course_index" Checklists = "checklists" + def add_open_ended_panel_tab(course): """ Used to add the open ended panel tab to a course if it does not exist. @@ -209,6 +208,7 @@ def add_open_ended_panel_tab(course): changed = True return changed, course_tabs + def remove_open_ended_panel_tab(course): """ Used to remove the open ended panel tab from a course if it exists. @@ -221,6 +221,6 @@ def remove_open_ended_panel_tab(course): #Check to see if open ended panel is defined in the course if OPEN_ENDED_PANEL in course_tabs: #Add panel to the tabs if it is not defined - course_tabs = [ct for ct in course_tabs if ct!=OPEN_ENDED_PANEL] + course_tabs = [ct for ct in course_tabs if ct != OPEN_ENDED_PANEL] changed = True return changed, course_tabs diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index 3169b437ed..9765937986 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -14,9 +14,6 @@ from tempfile import mkdtemp from django.core.servers.basehttp import FileWrapper from django.core.files.temp import NamedTemporaryFile -# to install PIL on MacOSX: 'easy_install http://dist.repoze.org/PIL-1.1.6.tar.gz' -from PIL import Image - from django.http import HttpResponse, Http404, HttpResponseBadRequest, HttpResponseForbidden, HttpResponseServerError from django.http import HttpResponseNotFound from django.contrib.auth.decorators import login_required @@ -245,7 +242,7 @@ def edit_subsection(request, location): for field in item.fields if field.name not in ['display_name', 'start', 'due', 'format'] and - field.scope == Scope.settings + field.scope == Scope.settings ) can_view_live = False @@ -257,18 +254,18 @@ def edit_subsection(request, location): break return render_to_response('edit_subsection.html', - {'subsection': item, - 'context_course': course, - 'create_new_unit_template': Location('i4x', 'edx', 'templates', 'vertical', 'Empty'), - 'lms_link': lms_link, - 'preview_link': preview_link, - 'course_graders': json.dumps(CourseGradingModel.fetch(course.location).graders), - 'parent_location': course.location, - 'parent_item': parent, - 'policy_metadata': policy_metadata, - 'subsection_units': subsection_units, - 'can_view_live': can_view_live - }) + {'subsection': item, + 'context_course': course, + 'create_new_unit_template': Location('i4x', 'edx', 'templates', 'vertical', 'Empty'), + 'lms_link': lms_link, + 'preview_link': preview_link, + 'course_graders': json.dumps(CourseGradingModel.fetch(course.location).graders), + 'parent_location': course.location, + 'parent_item': parent, + 'policy_metadata': policy_metadata, + 'subsection_units': subsection_units, + 'can_view_live': can_view_live + }) @login_required @@ -347,7 +344,7 @@ def edit_unit(request, location): index = index + 1 preview_lms_base = settings.MITX_FEATURES.get('PREVIEW_LMS_BASE', - 'preview.' + settings.LMS_BASE) + 'preview.' + settings.LMS_BASE) preview_lms_link = '//{preview_lms_base}/courses/{org}/{course}/{course_name}/courseware/{section}/{subsection}/{index}'.format( preview_lms_base=preview_lms_base, @@ -623,7 +620,6 @@ def delete_item(request): store = get_modulestore(item_loc) - # @TODO: this probably leaves draft items dangling. My preferance would be for the semantic to be # if item.location.revision=None, then delete both draft and published version # if caller wants to only delete the draft than the caller should put item.location.revision='draft' @@ -665,7 +661,7 @@ def save_item(request): if not has_access(request.user, item_location): raise PermissionDenied() - store = get_modulestore(Location(item_location)); + store = get_modulestore(Location(item_location)) if request.POST.get('data') is not None: data = request.POST['data'] @@ -800,7 +796,7 @@ def upload_asset(request, org, course, coursename): # Does the course actually exist?!? Get anything from it to prove its existance try: - item = modulestore().get_item(location) + modulestore().get_item(location) except: # no return it as a Bad Request response logging.error('Could not find course' + location) @@ -834,24 +830,22 @@ def upload_asset(request, org, course, coursename): readback = contentstore().find(content.location) response_payload = {'displayname': content.name, - 'uploadDate': get_default_time_display(readback.last_modified_at.timetuple()), - '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, - 'msg': 'Upload completed' - } + 'uploadDate': get_default_time_display(readback.last_modified_at.timetuple()), + '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, + 'msg': 'Upload completed' + } response = HttpResponse(json.dumps(response_payload)) response['asset_url'] = StaticContent.get_url_path_from_location(content.location) return response - -''' -This view will return all CMS users who are editors for the specified course -''' @login_required @ensure_csrf_cookie def manage_users(request, location): - + ''' + This view will return all CMS users who are editors for the specified course + ''' # 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): raise PermissionDenied() @@ -878,14 +872,14 @@ def create_json_response(errmsg=None): return resp -''' -This POST-back view will add a user - specified by email - to the list of editors for -the specified course -''' @expect_json @login_required @ensure_csrf_cookie def add_user(request, location): + ''' + This POST-back view will add a user - specified by email - to the list of editors for + the specified course + ''' email = request.POST["email"] if email == '': @@ -911,14 +905,15 @@ def add_user(request, location): return create_json_response() -''' -This POST-back view will remove a user - specified by email - from the list of editors for -the specified course -''' @expect_json @login_required @ensure_csrf_cookie def remove_user(request, location): + ''' + This POST-back view will remove a user - specified by email - from the list of editors for + the specified course + ''' + email = request.POST["email"] # check that logged in user has admin permissions on this course @@ -993,13 +988,12 @@ def reorder_static_tabs(request): for tab in course.tabs: if tab['type'] == 'static_tab': reordered_tabs.append({'type': 'static_tab', - 'name': tab_items[static_tab_idx].display_name, - 'url_slug': tab_items[static_tab_idx].location.name}) + 'name': tab_items[static_tab_idx].display_name, + 'url_slug': tab_items[static_tab_idx].location.name}) static_tab_idx += 1 else: reordered_tabs.append(tab) - # OK, re-assemble the static tabs in the new order course.tabs = reordered_tabs modulestore('direct').update_metadata(course.location, own_metadata(course)) @@ -1011,7 +1005,6 @@ def reorder_static_tabs(request): def edit_tabs(request, org, course, coursename): location = ['i4x', org, course, 'course', coursename] course_item = modulestore().get_item(location) - static_tabs_loc = Location('i4x', org, course, 'static_tab', None) # check that logged in user has permissions to this item if not has_access(request.user, location): @@ -1040,7 +1033,7 @@ def edit_tabs(request, org, course, coursename): 'active_tab': 'pages', 'context_course': course_item, 'components': components - }) + }) def not_found(request): @@ -1102,21 +1095,21 @@ def course_info_updates(request, org, course, provided_id=None): if request.method == 'GET': return HttpResponse(json.dumps(get_course_updates(location)), - mimetype="application/json") + mimetype="application/json") elif real_method == 'DELETE': try: return HttpResponse(json.dumps(delete_course_update(location, - request.POST, provided_id)), mimetype="application/json") + request.POST, provided_id)), mimetype="application/json") except: return HttpResponseBadRequest("Failed to delete", - content_type="text/plain") + content_type="text/plain") elif request.method == 'POST': try: return HttpResponse(json.dumps(update_course_updates(location, - request.POST, provided_id)), mimetype="application/json") + request.POST, provided_id)), mimetype="application/json") except: return HttpResponseBadRequest("Failed to save", - content_type="text/plain") + content_type="text/plain") @expect_json @@ -1184,7 +1177,7 @@ def course_config_graders_page(request, org, course, name): return render_to_response('settings_graders.html', { 'context_course': course_module, - 'course_location' : location, + 'course_location': location, 'course_details': json.dumps(course_details, cls=CourseSettingsEncoder) }) @@ -1203,8 +1196,8 @@ def course_config_advanced_page(request, org, course, name): return render_to_response('settings_advanced.html', { 'context_course': course_module, - 'course_location' : location, - 'advanced_dict' : json.dumps(CourseMetadata.fetch(location)), + 'course_location': location, + 'advanced_dict': json.dumps(CourseMetadata.fetch(location)), }) @@ -1225,7 +1218,8 @@ def course_settings_updates(request, org, course, name, section): manager = CourseDetails elif section == 'grading': manager = CourseGradingModel - else: return + else: + return if request.method == 'GET': # Cannot just do a get w/o knowing the course name :-( @@ -1320,6 +1314,7 @@ def course_advanced_updates(request, org, course, name): response_json = json.dumps(CourseMetadata.update_from_json(location, request_body, filter_tabs=filter_tabs)) return HttpResponse(response_json, mimetype="application/json") + @ensure_csrf_cookie @login_required def get_checklists(request, org, course, name): @@ -1345,10 +1340,10 @@ def get_checklists(request, org, course, name): if copied or modified: modulestore.update_metadata(location, own_metadata(course_module)) return render_to_response('checklists.html', - { - 'context_course': course_module, - 'checklists': checklists - }) + { + 'context_course': course_module, + 'checklists': checklists + }) @ensure_csrf_cookie @@ -1433,7 +1428,6 @@ def asset_index(request, org, course, name): # sort in reverse upload date order assets = sorted(assets, key=lambda asset: asset['uploadDate'], reverse=True) - thumbnails = contentstore().get_all_content_thumbnails_for_course(course_reference) asset_display = [] for asset in assets: id = asset['_id'] @@ -1527,10 +1521,10 @@ def initialize_course_tabs(course): # This logic is repeated in xmodule/modulestore/tests/factories.py # so if you change anything here, you need to also change it there. course.tabs = [{"type": "courseware"}, - {"type": "course_info", "name": "Course Info"}, - {"type": "discussion", "name": "Discussion"}, - {"type": "wiki", "name": "Wiki"}, - {"type": "progress", "name": "Progress"}] + {"type": "course_info", "name": "Course Info"}, + {"type": "discussion", "name": "Discussion"}, + {"type": "wiki", "name": "Wiki"}, + {"type": "progress", "name": "Progress"}] modulestore('direct').update_metadata(course.location.url(), own_metadata(course)) @@ -1586,8 +1580,10 @@ def import_course(request, org, course, name): shutil.move(r / fname, course_dir) module_store, course_items = import_from_xml(modulestore('direct'), settings.GITHUB_REPO_ROOT, - [course_subdir], load_error_modules=False, static_content_store=contentstore(), - target_location_namespace=Location(location), draft_store=modulestore()) + [course_subdir], load_error_modules=False, + static_content_store=contentstore(), + target_location_namespace=Location(location), + draft_store=modulestore()) # we can blow this away when we're done importing. shutil.rmtree(course_dir) diff --git a/cms/djangoapps/models/settings/course_details.py b/cms/djangoapps/models/settings/course_details.py index 876000c7fe..0dbb47b31b 100644 --- a/cms/djangoapps/models/settings/course_details.py +++ b/cms/djangoapps/models/settings/course_details.py @@ -174,7 +174,6 @@ class CourseDetails(object): return result - # TODO move to a more general util? Is there a better way to do the isinstance model check? class CourseSettingsEncoder(json.JSONEncoder): def default(self, obj): diff --git a/cms/djangoapps/models/settings/course_grading.py b/cms/djangoapps/models/settings/course_grading.py index ee9b4ac0eb..4ea9f2f5db 100644 --- a/cms/djangoapps/models/settings/course_grading.py +++ b/cms/djangoapps/models/settings/course_grading.py @@ -45,14 +45,13 @@ class CourseGradingModel(object): # return empty model else: - return { - "id": index, + return {"id": index, "type": "", "min_count": 0, "drop_count": 0, "short_label": None, "weight": 0 - } + } @staticmethod def fetch_cutoffs(course_location): @@ -95,7 +94,6 @@ class CourseGradingModel(object): return CourseGradingModel.fetch(course_location) - @staticmethod def update_grader_from_json(course_location, grader): """ @@ -137,7 +135,6 @@ class CourseGradingModel(object): return cutoffs - @staticmethod def update_grace_period_from_json(course_location, graceperiodjson): """ @@ -210,8 +207,7 @@ class CourseGradingModel(object): location = Location(location) descriptor = get_modulestore(location).get_item(location) - return { - "graderType": descriptor.lms.format if descriptor.lms.format is not None else 'Not Graded', + return {"graderType": descriptor.lms.format if descriptor.lms.format is not None else 'Not Graded', "location": location, "id": 99 # just an arbitrary value to } @@ -231,7 +227,6 @@ class CourseGradingModel(object): get_modulestore(location).update_metadata(location, descriptor._model_data._kvs._metadata) - @staticmethod def convert_set_grace_period(descriptor): # 5 hours 59 minutes 59 seconds => converted to iso format @@ -262,13 +257,12 @@ class CourseGradingModel(object): @staticmethod def parse_grader(json_grader): # manual to clear out kruft - result = { - "type": json_grader["type"], - "min_count": int(json_grader.get('min_count', 0)), - "drop_count": int(json_grader.get('drop_count', 0)), - "short_label": json_grader.get('short_label', None), - "weight": float(json_grader.get('weight', 0)) / 100.0 - } + result = {"type": json_grader["type"], + "min_count": int(json_grader.get('min_count', 0)), + "drop_count": int(json_grader.get('drop_count', 0)), + "short_label": json_grader.get('short_label', None), + "weight": float(json_grader.get('weight', 0)) / 100.0 + } return result diff --git a/cms/djangoapps/models/settings/course_metadata.py b/cms/djangoapps/models/settings/course_metadata.py index 70f69315ff..4429e35692 100644 --- a/cms/djangoapps/models/settings/course_metadata.py +++ b/cms/djangoapps/models/settings/course_metadata.py @@ -6,6 +6,7 @@ from xblock.core import Scope from xmodule.course_module import CourseDescriptor import copy + class CourseMetadata(object): ''' For CRUD operations on metadata fields which do not have specific editors @@ -13,8 +14,13 @@ class CourseMetadata(object): The objects have no predefined attrs but instead are obj encodings of the editable metadata. ''' - FILTERED_LIST = XModuleDescriptor.system_metadata_fields + ['start', 'end', - 'enrollment_start', 'enrollment_end', 'tabs', 'graceperiod', 'checklists'] + FILTERED_LIST = XModuleDescriptor.system_metadata_fields + ['start', + 'end', + 'enrollment_start', + 'enrollment_end', + 'tabs', + 'graceperiod', + 'checklists'] @classmethod def fetch(cls, course_location): @@ -48,7 +54,7 @@ class CourseMetadata(object): descriptor = get_modulestore(course_location).get_item(course_location) dirty = False - + #Copy the filtered list to avoid permanently changing the class attribute filtered_list = copy.copy(cls.FILTERED_LIST) #Don't filter on the tab attribute if filter_tabs is False @@ -71,7 +77,7 @@ class CourseMetadata(object): if dirty: get_modulestore(course_location).update_metadata(course_location, - own_metadata(descriptor)) + own_metadata(descriptor)) # Could just generate and return a course obj w/o doing any db reads, # but I put the reads in as a means to confirm it persisted correctly @@ -92,6 +98,6 @@ class CourseMetadata(object): delattr(descriptor.lms, key) get_modulestore(course_location).update_metadata(course_location, - own_metadata(descriptor)) + own_metadata(descriptor)) return cls.fetch(course_location) diff --git a/cms/envs/aws.py b/cms/envs/aws.py index edf67badfe..59ad8b835e 100644 --- a/cms/envs/aws.py +++ b/cms/envs/aws.py @@ -67,4 +67,4 @@ MODULESTORE = AUTH_TOKENS['MODULESTORE'] CONTENTSTORE = AUTH_TOKENS['CONTENTSTORE'] # Datadog for events! -DATADOG_API = AUTH_TOKENS.get("DATADOG_API") \ No newline at end of file +DATADOG_API = AUTH_TOKENS.get("DATADOG_API") diff --git a/cms/envs/common.py b/cms/envs/common.py index 37cfeea7a1..ca08a56a70 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -167,7 +167,7 @@ STATICFILES_DIRS = [ PROJECT_ROOT / "static", # This is how you would use the textbook images locally -# ("book", ENV_ROOT / "book_images") +# ("book", ENV_ROOT / "book_images") ] # Locale/Internationalization diff --git a/common/lib/xmodule/xmodule/contentstore/content.py b/common/lib/xmodule/xmodule/contentstore/content.py index 9dc4b1367b..428d38a50d 100644 --- a/common/lib/xmodule/xmodule/contentstore/content.py +++ b/common/lib/xmodule/xmodule/contentstore/content.py @@ -9,6 +9,7 @@ import StringIO from xmodule.modulestore import Location from .django import contentstore +# to install PIL on MacOSX: 'easy_install http://dist.repoze.org/PIL-1.1.6.tar.gz' from PIL import Image From 8ece663284b6628daabb9cf47cbb19eeaba382d1 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Fri, 12 Apr 2013 15:45:27 -0400 Subject: [PATCH 2/3] more drive by violation fixes --- common/lib/xmodule/xmodule/abtest_module.py | 2 +- .../lib/xmodule/xmodule/annotatable_module.py | 4 +--- .../xmodule/combined_open_ended_module.py | 10 ++++----- .../lib/xmodule/xmodule/conditional_module.py | 17 +++++++-------- .../xmodule/xmodule/contentstore/content.py | 9 ++++---- .../xmodule/xmodule/contentstore/django.py | 1 - .../lib/xmodule/xmodule/contentstore/mongo.py | 12 +++++------ common/lib/xmodule/xmodule/course_module.py | 10 +-------- .../lib/xmodule/xmodule/discussion_module.py | 10 ++++----- common/lib/xmodule/xmodule/error_module.py | 4 ++-- common/lib/xmodule/xmodule/exceptions.py | 2 ++ common/lib/xmodule/xmodule/fields.py | 2 ++ common/lib/xmodule/xmodule/foldit_module.py | 5 ++--- .../lib/xmodule/xmodule/modulestore/django.py | 3 +-- .../xmodule/modulestore/inheritance.py | 3 ++- .../lib/xmodule/xmodule/modulestore/mongo.py | 21 +++++++++---------- .../lib/xmodule/xmodule/modulestore/search.py | 4 ++-- .../xmodule/modulestore/store_utilities.py | 19 ++++++++--------- common/lib/xmodule/xmodule/modulestore/xml.py | 19 ++++++----------- .../xmodule/modulestore/xml_importer.py | 2 +- common/lib/xmodule/xmodule/util/decorators.py | 1 + 21 files changed, 69 insertions(+), 91 deletions(-) diff --git a/common/lib/xmodule/xmodule/abtest_module.py b/common/lib/xmodule/xmodule/abtest_module.py index e84de270b2..196154df78 100644 --- a/common/lib/xmodule/xmodule/abtest_module.py +++ b/common/lib/xmodule/xmodule/abtest_module.py @@ -6,7 +6,7 @@ from xmodule.x_module import XModule from xmodule.raw_module import RawDescriptor from xmodule.xml_module import XmlDescriptor from xmodule.exceptions import InvalidDefinitionError -from xblock.core import String, Scope, Object, BlockScope +from xblock.core import String, Scope, Object DEFAULT = "_DEFAULT_GROUP" diff --git a/common/lib/xmodule/xmodule/annotatable_module.py b/common/lib/xmodule/xmodule/annotatable_module.py index 3e5108ed3a..e0de97bb36 100644 --- a/common/lib/xmodule/xmodule/annotatable_module.py +++ b/common/lib/xmodule/xmodule/annotatable_module.py @@ -1,11 +1,10 @@ import logging from lxml import etree -from pkg_resources import resource_string, resource_listdir +from pkg_resources import resource_string from xmodule.x_module import XModule from xmodule.raw_module import RawDescriptor -from xmodule.contentstore.content import StaticContent from xblock.core import Scope, String log = logging.getLogger(__name__) @@ -25,7 +24,6 @@ class AnnotatableModule(AnnotatableFields, XModule): css = {'scss': [resource_string(__name__, 'css/annotatable/display.scss')]} icon_class = 'annotatable' - def __init__(self, *args, **kwargs): XModule.__init__(self, *args, **kwargs) diff --git a/common/lib/xmodule/xmodule/combined_open_ended_module.py b/common/lib/xmodule/xmodule/combined_open_ended_module.py index 29d1270893..d762b6f1e2 100644 --- a/common/lib/xmodule/xmodule/combined_open_ended_module.py +++ b/common/lib/xmodule/xmodule/combined_open_ended_module.py @@ -106,10 +106,10 @@ class CombinedOpenEndedModule(CombinedOpenEndedFields, XModule): icon_class = 'problem' js = {'coffee': - [resource_string(__name__, 'js/src/combinedopenended/display.coffee'), - resource_string(__name__, 'js/src/collapsible.coffee'), - resource_string(__name__, 'js/src/javascript_loader.coffee'), - ]} + [resource_string(__name__, 'js/src/combinedopenended/display.coffee'), + resource_string(__name__, 'js/src/collapsible.coffee'), + resource_string(__name__, 'js/src/javascript_loader.coffee'), + ]} js_module_name = "CombinedOpenEnded" css = {'scss': [resource_string(__name__, 'css/combinedopenended/display.scss')]} @@ -219,5 +219,5 @@ class CombinedOpenEndedDescriptor(CombinedOpenEndedFields, RawDescriptor): stores_state = True has_score = True - always_recalculate_grades=True + always_recalculate_grades = True template_dir_name = "combinedopenended" diff --git a/common/lib/xmodule/xmodule/conditional_module.py b/common/lib/xmodule/xmodule/conditional_module.py index 2433a143ed..590be213bd 100644 --- a/common/lib/xmodule/xmodule/conditional_module.py +++ b/common/lib/xmodule/xmodule/conditional_module.py @@ -10,7 +10,7 @@ from pkg_resources import resource_string from xmodule.x_module import XModule from xmodule.modulestore import Location from xmodule.seq_module import SequenceDescriptor -from xblock.core import String, Scope, List +from xblock.core import Scope, List from xmodule.modulestore.exceptions import ItemNotFoundError @@ -60,8 +60,7 @@ class ConditionalModule(ConditionalFields, XModule): js = {'coffee': [resource_string(__name__, 'js/src/javascript_loader.coffee'), resource_string(__name__, 'js/src/conditional/display.coffee'), resource_string(__name__, 'js/src/collapsible.coffee'), - - ]} + ]} js_module_name = "Conditional" css = {'scss': [resource_string(__name__, 'css/capa/display.scss')]} @@ -82,12 +81,11 @@ class ConditionalModule(ConditionalFields, XModule): xml_value = self.descriptor.xml_attributes.get(xml_attr) if xml_value: return xml_value, attr_name - raise Exception('Error in conditional module: unknown condition "%s"' - % xml_attr) + raise Exception('Error in conditional module: unknown condition "%s"' % xml_attr) def is_condition_satisfied(self): self.required_modules = [self.system.get_module(descriptor) for - descriptor in self.descriptor.get_required_module_descriptors()] + descriptor in self.descriptor.get_required_module_descriptors()] xml_value, attr_name = self._get_condition() @@ -111,7 +109,7 @@ class ConditionalModule(ConditionalFields, XModule): def get_html(self): # Calculate html ids of dependencies self.required_html_ids = [descriptor.location.html_id() for - descriptor in self.descriptor.get_required_module_descriptors()] + descriptor in self.descriptor.get_required_module_descriptors()] return self.system.render_template('conditional_ajax.html', { 'element_id': self.location.html_id(), @@ -130,7 +128,7 @@ class ConditionalModule(ConditionalFields, XModule): context = {'module': self, 'message': message} html = self.system.render_template('conditional_module.html', - context) + context) return json.dumps({'html': [html], 'message': bool(message)}) html = [child.get_html() for child in self.get_display_items()] @@ -145,7 +143,7 @@ class ConditionalModule(ConditionalFields, XModule): class_priority = ['video', 'problem'] child_classes = [self.system.get_module(child_descriptor).get_icon_class() - for child_descriptor in self.descriptor.get_children()] + for child_descriptor in self.descriptor.get_children()] for c in class_priority: if c in child_classes: new_class = c @@ -163,7 +161,6 @@ class ConditionalDescriptor(ConditionalFields, SequenceDescriptor): stores_state = True has_score = False - @staticmethod def parse_sources(xml_element, system, return_descriptor=False): """Parse xml_element 'sources' attr and: diff --git a/common/lib/xmodule/xmodule/contentstore/content.py b/common/lib/xmodule/xmodule/contentstore/content.py index 428d38a50d..64069ce9fa 100644 --- a/common/lib/xmodule/xmodule/contentstore/content.py +++ b/common/lib/xmodule/xmodule/contentstore/content.py @@ -60,8 +60,9 @@ class StaticContent(object): @staticmethod def get_id_from_location(location): return {'tag': location.tag, 'org': location.org, 'course': location.course, - 'category': location.category, 'name': location.name, - 'revision': location.revision} + 'category': location.category, 'name': location.name, + 'revision': location.revision} + @staticmethod def get_location_from_path(path): # remove leading / character if it is there one @@ -80,8 +81,6 @@ class StaticContent(object): return StaticContent.get_url_path_from_location(loc) - - class ContentStore(object): ''' Abstraction for all ContentStore providers (e.g. MongoDB) @@ -120,7 +119,7 @@ class ContentStore(object): thumbnail_name = StaticContent.generate_thumbnail_name(content.location.name) thumbnail_file_location = StaticContent.compute_location(content.location.org, content.location.course, - thumbnail_name, is_thumbnail=True) + thumbnail_name, is_thumbnail=True) # if we're uploading an image, then let's generate a thumbnail so that we can # serve it up when needed without having to rescale on the fly diff --git a/common/lib/xmodule/xmodule/contentstore/django.py b/common/lib/xmodule/xmodule/contentstore/django.py index ec0397a348..83a2508d96 100644 --- a/common/lib/xmodule/xmodule/contentstore/django.py +++ b/common/lib/xmodule/xmodule/contentstore/django.py @@ -1,6 +1,5 @@ from __future__ import absolute_import from importlib import import_module -from os import environ from django.conf import settings diff --git a/common/lib/xmodule/xmodule/contentstore/mongo.py b/common/lib/xmodule/xmodule/contentstore/mongo.py index 68cc6d73d3..58fadb7957 100644 --- a/common/lib/xmodule/xmodule/contentstore/mongo.py +++ b/common/lib/xmodule/xmodule/contentstore/mongo.py @@ -6,7 +6,6 @@ from gridfs.errors import NoFile from xmodule.modulestore.mongo import location_to_query, Location from xmodule.contentstore.content import XASSET_LOCATION_TAG -import sys import logging from .content import StaticContent, ContentStore @@ -26,7 +25,6 @@ class MongoContentStore(ContentStore): self.fs = gridfs.GridFS(_db) self.fs_files = _db["fs.files"] # the underlying collection GridFS uses - def save(self, content): id = content.get_id() @@ -34,7 +32,8 @@ class MongoContentStore(ContentStore): self.delete(id) with self.fs.new_file(_id=id, filename=content.get_url_path(), content_type=content.content_type, - displayname=content.name, thumbnail_location=content.thumbnail_location, import_path=content.import_path) as fp: + displayname=content.name, thumbnail_location=content.thumbnail_location, + import_path=content.import_path) as fp: fp.write(content.data) @@ -49,8 +48,9 @@ class MongoContentStore(ContentStore): try: with self.fs.get(id) as fp: return StaticContent(location, fp.displayname, fp.content_type, fp.read(), - fp.uploadDate, thumbnail_location=fp.thumbnail_location if hasattr(fp, 'thumbnail_location') else None, - import_path=fp.import_path if hasattr(fp, 'import_path') else None) + fp.uploadDate, + thumbnail_location=fp.thumbnail_location if hasattr(fp, 'thumbnail_location') else None, + import_path=fp.import_path if hasattr(fp, 'import_path') else None) except NoFile: raise NotFoundError() @@ -102,7 +102,7 @@ class MongoContentStore(ContentStore): ] ''' course_filter = Location(XASSET_LOCATION_TAG, category="asset" if not get_thumbnails else "thumbnail", - course=location.course, org=location.org) + course=location.course, org=location.org) # 'borrow' the function 'location_to_query' from the Mongo modulestore implementation items = self.fs_files.find(location_to_query(course_filter)) return list(items) diff --git a/common/lib/xmodule/xmodule/course_module.py b/common/lib/xmodule/xmodule/course_module.py index 7f73be601a..5d3f576119 100644 --- a/common/lib/xmodule/xmodule/course_module.py +++ b/common/lib/xmodule/xmodule/course_module.py @@ -211,7 +211,6 @@ class CourseDescriptor(CourseFields, SequenceDescriptor): template_dir_name = 'course' - def __init__(self, *args, **kwargs): super(CourseDescriptor, self).__init__(*args, **kwargs) @@ -421,7 +420,6 @@ class CourseDescriptor(CourseFields, SequenceDescriptor): policy['GRADE_CUTOFFS'] = value self.grading_policy = policy - @property def lowest_passing_grade(self): return min(self._grading_policy['GRADE_CUTOFFS'].values()) @@ -460,7 +458,6 @@ class CourseDescriptor(CourseFields, SequenceDescriptor): else: return self.cohort_config.get("auto_cohort_groups", []) - @property def top_level_discussion_topic_ids(self): """ @@ -469,7 +466,6 @@ class CourseDescriptor(CourseFields, SequenceDescriptor): topics = self.discussion_topics return [d["id"] for d in topics.values()] - @property def cohorted_discussions(self): """ @@ -483,8 +479,6 @@ class CourseDescriptor(CourseFields, SequenceDescriptor): return set(config.get("cohorted_discussions", [])) - - @property def is_newish(self): """ @@ -585,7 +579,6 @@ class CourseDescriptor(CourseFields, SequenceDescriptor): yield module_descriptor for c in self.get_children(): - sections = [] for s in c.get_children(): if s.lms.graded: xmoduledescriptors = list(yield_descriptor_descendents(s)) @@ -601,8 +594,7 @@ class CourseDescriptor(CourseFields, SequenceDescriptor): all_descriptors.append(s) return {'graded_sections': graded_sections, - 'all_descriptors': all_descriptors, } - + 'all_descriptors': all_descriptors, } @staticmethod def make_id(org, course, url_name): diff --git a/common/lib/xmodule/xmodule/discussion_module.py b/common/lib/xmodule/xmodule/discussion_module.py index a0a5207e16..8968e221b2 100644 --- a/common/lib/xmodule/xmodule/discussion_module.py +++ b/common/lib/xmodule/xmodule/discussion_module.py @@ -1,5 +1,4 @@ -from lxml import etree -from pkg_resources import resource_string, resource_listdir +from pkg_resources import resource_string from xmodule.x_module import XModule from xmodule.raw_module import RawDescriptor @@ -16,12 +15,11 @@ class DiscussionFields(object): class DiscussionModule(DiscussionFields, XModule): js = {'coffee': - [resource_string(__name__, 'js/src/time.coffee'), - resource_string(__name__, 'js/src/discussion/display.coffee')] - } + [resource_string(__name__, 'js/src/time.coffee'), + resource_string(__name__, 'js/src/discussion/display.coffee')] + } js_module_name = "InlineDiscussion" - def get_html(self): context = { 'discussion_id': self.discussion_id, diff --git a/common/lib/xmodule/xmodule/error_module.py b/common/lib/xmodule/xmodule/error_module.py index d2135302da..ebb61b36f2 100644 --- a/common/lib/xmodule/xmodule/error_module.py +++ b/common/lib/xmodule/xmodule/error_module.py @@ -38,7 +38,7 @@ class ErrorModule(ErrorFields, XModule): 'staff_access': True, 'data': self.contents, 'error': self.error_msg, - }) + }) class NonStaffErrorModule(ErrorFields, XModule): @@ -51,7 +51,7 @@ class NonStaffErrorModule(ErrorFields, XModule): 'staff_access': False, 'data': "", 'error': "", - }) + }) class ErrorDescriptor(ErrorFields, JSONEditingDescriptor): diff --git a/common/lib/xmodule/xmodule/exceptions.py b/common/lib/xmodule/xmodule/exceptions.py index d38fbb12bb..faf0aafcd8 100644 --- a/common/lib/xmodule/xmodule/exceptions.py +++ b/common/lib/xmodule/xmodule/exceptions.py @@ -1,9 +1,11 @@ class InvalidDefinitionError(Exception): pass + class NotFoundError(Exception): pass + class ProcessingError(Exception): ''' An error occurred while processing a request to the XModule. diff --git a/common/lib/xmodule/xmodule/fields.py b/common/lib/xmodule/xmodule/fields.py index ea857933fc..bb85714252 100644 --- a/common/lib/xmodule/xmodule/fields.py +++ b/common/lib/xmodule/xmodule/fields.py @@ -51,6 +51,8 @@ class Date(ModelType): TIMEDELTA_REGEX = re.compile(r'^((?P\d+?) day(?:s?))?(\s)?((?P\d+?) hour(?:s?))?(\s)?((?P\d+?) minute(?:s)?)?(\s)?((?P\d+?) second(?:s)?)?$') + + class Timedelta(ModelType): def from_json(self, time_str): """ diff --git a/common/lib/xmodule/xmodule/foldit_module.py b/common/lib/xmodule/xmodule/foldit_module.py index 1851a4adc2..d5afc15bc7 100644 --- a/common/lib/xmodule/xmodule/foldit_module.py +++ b/common/lib/xmodule/xmodule/foldit_module.py @@ -107,7 +107,7 @@ class FolditModule(FolditFields, XModule): 'show_leader': showleader, 'folditbasic': self.get_basicpuzzles_html(), 'folditchallenge': self.get_challenge_html() - } + } return self.system.render_template('foldit.html', context) @@ -124,7 +124,7 @@ class FolditModule(FolditFields, XModule): 'success': self.is_complete(), 'goal_level': goal_level, 'completed': self.completed_puzzles(), - } + } return self.system.render_template('folditbasic.html', context) def get_challenge_html(self): @@ -149,7 +149,6 @@ class FolditModule(FolditFields, XModule): return 1 - class FolditDescriptor(FolditFields, XmlDescriptor, EditingDescriptor): """ Module for adding Foldit problems to courses diff --git a/common/lib/xmodule/xmodule/modulestore/django.py b/common/lib/xmodule/xmodule/modulestore/django.py index b0a65273c7..a2e2a4a5a5 100644 --- a/common/lib/xmodule/xmodule/modulestore/django.py +++ b/common/lib/xmodule/xmodule/modulestore/django.py @@ -6,7 +6,6 @@ Passes settings.MODULESTORE as kwargs to MongoModuleStore from __future__ import absolute_import from importlib import import_module -from os import environ from django.conf import settings @@ -38,7 +37,7 @@ def modulestore(name='default'): for key in FUNCTION_KEYS: if key in options: options[key] = load_function(options[key]) - + _MODULESTORES[name] = class_( **options ) diff --git a/common/lib/xmodule/xmodule/modulestore/inheritance.py b/common/lib/xmodule/xmodule/modulestore/inheritance.py index 927f01d543..62b351999d 100644 --- a/common/lib/xmodule/xmodule/modulestore/inheritance.py +++ b/common/lib/xmodule/xmodule/modulestore/inheritance.py @@ -9,9 +9,10 @@ INHERITABLE_METADATA = ( # intended to be set per-course, but can be overridden in for specific # elements. Can be a float. 'days_early_for_beta', - 'giturl' # for git edit link + 'giturl' # for git edit link ) + def compute_inherited_metadata(descriptor): """Given a descriptor, traverse all of its descendants and do metadata inheritance. Should be called on a CourseDescriptor after importing a diff --git a/common/lib/xmodule/xmodule/modulestore/mongo.py b/common/lib/xmodule/xmodule/modulestore/mongo.py index dd51be3bf6..28ea1f2659 100644 --- a/common/lib/xmodule/xmodule/modulestore/mongo.py +++ b/common/lib/xmodule/xmodule/modulestore/mongo.py @@ -7,7 +7,6 @@ from collections import namedtuple from fs.osfs import OSFS from itertools import repeat from path import path -from datetime import datetime from operator import attrgetter from uuid import uuid4 @@ -31,11 +30,13 @@ log = logging.getLogger(__name__) # there is only one revision for each item. Once we start versioning inside the CMS, # that assumption will have to change + def get_course_id_no_run(location): ''' ''' return "/".join([location.org, location.course]) + class MongoKeyValueStore(KeyValueStore): """ A KeyValueStore that maps keyed data access to one of the 3 data areas @@ -130,8 +131,8 @@ class CachingDescriptorSystem(MakoDescriptorSystem): render_template: a function for rendering templates, as per MakoDescriptorSystem """ - super(CachingDescriptorSystem, self).__init__( - self.load_item, resources_fs, error_tracker, render_template) + super(CachingDescriptorSystem, self).__init__(self.load_item, resources_fs, + error_tracker, render_template) self.modulestore = modulestore self.module_data = module_data self.default_class = default_class @@ -140,7 +141,6 @@ class CachingDescriptorSystem(MakoDescriptorSystem): self.course_id = None self.cached_metadata = cached_metadata - def load_item(self, location): """ Return an XModule instance for the specified location @@ -223,7 +223,7 @@ class MongoModuleStore(ModuleStoreBase): def __init__(self, host, db, collection, fs_root, render_template, port=27017, default_class=None, error_tracker=null_error_tracker, - user=None, password=None, request_cache=None, + user=None, password=None, request_cache=None, metadata_inheritance_cache_subsystem=None, **kwargs): ModuleStoreBase.__init__(self) @@ -468,7 +468,7 @@ class MongoModuleStore(ModuleStoreBase): # if we are loading a course object, if we're not prefetching children (depth != 0) then don't # bother with the metadata inheritance return [self._load_item(item, data_cache, - apply_cached_metadata=(item['location']['category']!='course' or depth !=0)) for item in items] + apply_cached_metadata=(item['location']['category'] != 'course' or depth != 0)) for item in items] def get_courses(self): ''' @@ -710,10 +710,9 @@ class MongoModuleStore(ModuleStoreBase): course.tabs = [tab for tab in existing_tabs if tab.get('url_slug') != location.name] self.update_metadata(course.location, own_metadata(course)) - self.collection.remove({'_id': Location(location).dict()}, - # Must include this to avoid the django debug toolbar (which defines the deprecated "safe=False") - # from overriding our default value set in the init method. - safe=self.collection.safe) + # Must include this to avoid the django debug toolbar (which defines the deprecated "safe=False") + # from overriding our default value set in the init method. + self.collection.remove({'_id': Location(location).dict()}, safe=self.collection.safe) # recompute (and update) the metadata inheritance tree which is cached self.refresh_cached_metadata_inheritance_tree(Location(location)) self.fire_updated_modulestore_signal(get_course_id_no_run(Location(location)), Location(location)) @@ -724,7 +723,7 @@ class MongoModuleStore(ModuleStoreBase): ''' location = Location.ensure_fully_specified(location) items = self.collection.find({'definition.children': location.url()}, - {'_id': True}) + {'_id': True}) return [i['_id'] for i in items] def get_errored_courses(self): diff --git a/common/lib/xmodule/xmodule/modulestore/search.py b/common/lib/xmodule/xmodule/modulestore/search.py index b56b612592..25ebc7e89c 100644 --- a/common/lib/xmodule/xmodule/modulestore/search.py +++ b/common/lib/xmodule/xmodule/modulestore/search.py @@ -3,7 +3,7 @@ from itertools import repeat from xmodule.course_module import CourseDescriptor from .exceptions import (ItemNotFoundError, NoPathToItem) -from . import ModuleStore, Location +from . import Location def path_to_location(modulestore, course_id, location): @@ -106,7 +106,7 @@ def path_to_location(modulestore, course_id, location): position_list = [] for path_index in range(2, n - 1): category = path[path_index].category - if category == 'sequential' or category == 'videosequence': + if category == 'sequential' or category == 'videosequence': section_desc = modulestore.get_instance(course_id, path[path_index]) child_locs = [c.location for c in section_desc.get_children()] # positions are 1-indexed, and should be strings to be consistent with diff --git a/common/lib/xmodule/xmodule/modulestore/store_utilities.py b/common/lib/xmodule/xmodule/modulestore/store_utilities.py index 2935069090..e90613d0da 100644 --- a/common/lib/xmodule/xmodule/modulestore/store_utilities.py +++ b/common/lib/xmodule/xmodule/modulestore/store_utilities.py @@ -1,4 +1,3 @@ -import logging from xmodule.contentstore.content import StaticContent from xmodule.modulestore import Location from xmodule.modulestore.mongo import MongoModuleStore @@ -33,11 +32,11 @@ def clone_course(modulestore, contentstore, source_location, dest_location, dele if original_loc.category != 'course': module.location = module.location._replace(tag=dest_location.tag, org=dest_location.org, - course=dest_location.course) + course=dest_location.course) else: # on the course module we also have to update the module name module.location = module.location._replace(tag=dest_location.tag, org=dest_location.org, - course=dest_location.course, name=dest_location.name) + course=dest_location.course, name=dest_location.name) print "Cloning module {0} to {1}....".format(original_loc, module.location) @@ -49,9 +48,9 @@ def clone_course(modulestore, contentstore, source_location, dest_location, dele for child_loc_url in module.children: child_loc = Location(child_loc_url) child_loc = child_loc._replace( - tag=dest_location.tag, - org=dest_location.org, - course=dest_location.course + tag=dest_location.tag, + org=dest_location.org, + course=dest_location.course ) new_children.append(child_loc.url()) @@ -67,7 +66,7 @@ def clone_course(modulestore, contentstore, source_location, dest_location, dele thumb_loc = Location(thumb["_id"]) content = contentstore.find(thumb_loc) content.location = content.location._replace(org=dest_location.org, - course=dest_location.course) + course=dest_location.course) print "Cloning thumbnail {0} to {1}".format(thumb_loc, content.location) @@ -80,12 +79,12 @@ def clone_course(modulestore, contentstore, source_location, dest_location, dele asset_loc = Location(asset["_id"]) content = contentstore.find(asset_loc) content.location = content.location._replace(org=dest_location.org, - course=dest_location.course) + course=dest_location.course) # be sure to update the pointer to the thumbnail if content.thumbnail_location is not None: content.thumbnail_location = content.thumbnail_location._replace(org=dest_location.org, - course=dest_location.course) + course=dest_location.course) print "Cloning asset {0} to {1}".format(asset_loc, content.location) @@ -94,7 +93,7 @@ def clone_course(modulestore, contentstore, source_location, dest_location, dele return True -def delete_course(modulestore, contentstore, source_location, commit = False): +def delete_course(modulestore, contentstore, source_location, commit=False): # first check to see if the modulestore is Mongo backed if not isinstance(modulestore, MongoModuleStore): raise Exception("Expected a MongoModuleStore in the runtime. Aborting....") diff --git a/common/lib/xmodule/xmodule/modulestore/xml.py b/common/lib/xmodule/xmodule/modulestore/xml.py index 677f8b7d6a..114a3281c6 100644 --- a/common/lib/xmodule/xmodule/modulestore/xml.py +++ b/common/lib/xmodule/xmodule/modulestore/xml.py @@ -75,7 +75,7 @@ class ImportSystem(XMLParsingSystem, MakoDescriptorSystem): # tags that really need unique names--they store (or should store) state. need_uniq_names = ('problem', 'sequential', 'video', 'course', 'chapter', - 'videosequence', 'poll_question', 'timelimit') + 'videosequence', 'poll_question', 'timelimit') attr = xml_data.attrib tag = xml_data.tag @@ -169,7 +169,6 @@ class ImportSystem(XMLParsingSystem, MakoDescriptorSystem): # Didn't load properly. Fall back on loading as an error # descriptor. This should never error due to formatting. - msg = "Error loading from xml. " + str(err)[:200] log.warning(msg) # Normally, we don't want lots of exception traces in our logs from common @@ -367,7 +366,7 @@ class XMLModuleStore(ModuleStoreBase): if org is None: msg = ("No 'org' attribute set for course in {dir}. " - "Using default 'edx'".format(dir=course_dir)) + "Using default 'edx'".format(dir=course_dir)) log.warning(msg) tracker(msg) org = 'edx' @@ -376,10 +375,10 @@ class XMLModuleStore(ModuleStoreBase): if course is None: msg = ("No 'course' attribute set for course in {dir}." - " Using default '{default}'".format( - dir=course_dir, - default=course_dir - )) + " Using default '{default}'".format(dir=course_dir, + default=course_dir + ) + ) log.warning(msg) tracker(msg) course = course_dir @@ -445,7 +444,6 @@ class XMLModuleStore(ModuleStoreBase): log.debug('========> Done with course import from {0}'.format(course_dir)) return course_descriptor - def load_extra_content(self, system, course_descriptor, category, base_dir, course_dir, url_name): self._load_extra_content(system, course_descriptor, category, base_dir, course_dir) @@ -453,7 +451,6 @@ class XMLModuleStore(ModuleStoreBase): if os.path.isdir(base_dir / url_name): self._load_extra_content(system, course_descriptor, category, base_dir / url_name, course_dir) - def _load_extra_content(self, system, course_descriptor, category, path, course_dir): for filepath in glob.glob(path / '*'): @@ -480,7 +477,6 @@ class XMLModuleStore(ModuleStoreBase): logging.exception("Failed to load {0}. Skipping... Exception: {1}".format(filepath, str(e))) system.error_tracker("ERROR: " + str(e)) - def get_instance(self, course_id, location, depth=0): """ Returns an XModuleDescriptor instance for the item at @@ -542,7 +538,6 @@ class XMLModuleStore(ModuleStoreBase): return items - def get_courses(self, depth=0): """ Returns a list of course descriptors. If there were errors on loading, @@ -567,7 +562,6 @@ class XMLModuleStore(ModuleStoreBase): """ raise NotImplementedError("XMLModuleStores are read-only") - def update_children(self, location, children): """ Set the children for the item specified by the location to @@ -578,7 +572,6 @@ class XMLModuleStore(ModuleStoreBase): """ raise NotImplementedError("XMLModuleStores are read-only") - def update_metadata(self, location, metadata): """ Set the metadata for the item specified by the location to diff --git a/common/lib/xmodule/xmodule/modulestore/xml_importer.py b/common/lib/xmodule/xmodule/modulestore/xml_importer.py index 2dea75ef57..6355204d07 100644 --- a/common/lib/xmodule/xmodule/modulestore/xml_importer.py +++ b/common/lib/xmodule/xmodule/modulestore/xml_importer.py @@ -316,7 +316,7 @@ def import_module(module, store, course_data_path, static_content_store, allow_n # Note the dropped element closing tag. This causes the LMS to fail when rendering modules - that's # no good, so we have to do this kludge if isinstance(module_data, str) or isinstance(module_data, unicode): # some module 'data' fields are non strings which blows up the link traversal code - lxml_rewrite_links(module_data, lambda link: verify_content_links(module, course_data_path, static_content_store, link, remap_dict)) + lxml_rewrite_links(module_data, lambda link: verify_content_links(module, course_data_path, static_content_store, link, remap_dict)) for key in remap_dict.keys(): module_data = module_data.replace(key, remap_dict[key]) diff --git a/common/lib/xmodule/xmodule/util/decorators.py b/common/lib/xmodule/xmodule/util/decorators.py index 0b9b301244..e827b74ef1 100644 --- a/common/lib/xmodule/xmodule/util/decorators.py +++ b/common/lib/xmodule/xmodule/util/decorators.py @@ -28,6 +28,7 @@ def lazyproperty(fn): """ attr_name = '_lazy_' + fn.__name__ + @property def _lazyprop(self): if not hasattr(self, attr_name): From 3ca2bf462786b6d2bc3590a2731b892259bfc578 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Fri, 12 Apr 2013 15:51:47 -0400 Subject: [PATCH 3/3] move lines together --- cms/djangoapps/contentstore/views.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index 9765937986..b7af8047f6 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -241,8 +241,7 @@ def edit_subsection(request, location): (field.name, field.read_from(item)) for field in item.fields - if field.name not in ['display_name', 'start', 'due', 'format'] and - field.scope == Scope.settings + if field.name not in ['display_name', 'start', 'due', 'format'] and field.scope == Scope.settings ) can_view_live = False