diff --git a/common/lib/xmodule/xmodule/modulestore/mongo/base.py b/common/lib/xmodule/xmodule/modulestore/mongo/base.py index bedba5d65d..066197f4b2 100644 --- a/common/lib/xmodule/xmodule/modulestore/mongo/base.py +++ b/common/lib/xmodule/xmodule/modulestore/mongo/base.py @@ -225,6 +225,8 @@ class CachingDescriptorSystem(MakoDescriptorSystem): non_draft_loc = location.replace(revision=None) metadata_to_inherit = self.cached_metadata.get(non_draft_loc.url(), {}) inherit_metadata(module, metadata_to_inherit) + # decache any computed pending field settings + module.save() return module except: log.warning("Failed to load descriptor", exc_info=True) @@ -630,6 +632,8 @@ class MongoModuleStore(ModuleStoreBase): definition_data = {} dbmodel = self._create_new_model_data(location.category, location, definition_data, metadata) xmodule = xblock_class(system, dbmodel) + # decache any pending field settings from init + xmodule.save() return xmodule def save_xmodule(self, xmodule): diff --git a/common/lib/xmodule/xmodule/modulestore/split_mongo/caching_descriptor_system.py b/common/lib/xmodule/xmodule/modulestore/split_mongo/caching_descriptor_system.py index 1591757490..c9ef04420b 100644 --- a/common/lib/xmodule/xmodule/modulestore/split_mongo/caching_descriptor_system.py +++ b/common/lib/xmodule/xmodule/modulestore/split_mongo/caching_descriptor_system.py @@ -116,4 +116,6 @@ class CachingDescriptorSystem(MakoDescriptorSystem): module.previous_version = json_data.get('previous_version') module.update_version = json_data.get('update_version') module.definition_locator = self.modulestore.definition_locator(definition) + # decache any pending field settings + module.save() return module diff --git a/common/lib/xmodule/xmodule/x_module.py b/common/lib/xmodule/xmodule/x_module.py index 47642e9f90..5c8324e2ee 100644 --- a/common/lib/xmodule/xmodule/x_module.py +++ b/common/lib/xmodule/xmodule/x_module.py @@ -537,11 +537,14 @@ class XModuleDescriptor(XModuleFields, HTMLSnippet, ResourceTemplates, XBlock): system: Module system """ - return self.module_class( + # save any field changes + module = self.module_class( system, self, system.xblock_model_data(self), ) + module.save() + return module def has_dynamic_children(self): """ @@ -614,6 +617,9 @@ class XModuleDescriptor(XModuleFields, HTMLSnippet, ResourceTemplates, XBlock): new_block = system.xblock_from_json(cls, usage_id, json_data) if parent_xblock is not None: parent_xblock.children.append(new_block) + # decache pending children field settings (Note, truly persisting at this point would break b/c + # persistence assumes children is a list of ids not actual xblocks) + parent_xblock.save() return new_block @classmethod diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index dacd495da2..caa8967476 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -1,6 +1,5 @@ import json import logging -import re import sys from functools import partial @@ -13,7 +12,6 @@ from django.http import Http404 from django.http import HttpResponse from django.views.decorators.csrf import csrf_exempt -import pyparsing from requests.auth import HTTPBasicAuth from statsd import statsd @@ -599,14 +597,14 @@ def _check_files_limits(files): # Check number of files submitted if len(inputfiles) > settings.MAX_FILEUPLOADS_PER_INPUT: - msg = 'Submission aborted! Maximum %d files may be submitted at once' %\ + msg = 'Submission aborted! Maximum %d files may be submitted at once' % \ settings.MAX_FILEUPLOADS_PER_INPUT return msg # Check file sizes for inputfile in inputfiles: - if inputfile.size > settings.STUDENT_FILEUPLOAD_MAX_SIZE: # Bytes - msg = 'Submission aborted! Your file "%s" is too large (max size: %d MB)' %\ + if inputfile.size > settings.STUDENT_FILEUPLOAD_MAX_SIZE: # Bytes + msg = 'Submission aborted! Your file "%s" is too large (max size: %d MB)' % \ (inputfile.name, settings.STUDENT_FILEUPLOAD_MAX_SIZE / (1000 ** 2)) return msg