fix-setattr-and-getattr
This commit is contained in:
@@ -605,8 +605,8 @@ class MongoModuleStore(ModuleStoreBase):
|
||||
)
|
||||
xblock_class = XModuleDescriptor.load_class(location.category, self.default_class)
|
||||
if definition_data is None:
|
||||
if hasattr(xblock_class, 'data') and getattr(xblock_class, 'data').default is not None:
|
||||
definition_data = getattr(xblock_class, 'data').default
|
||||
if hasattr(xblock_class, 'data') and xblock_class.data.default is not None:
|
||||
definition_data = xblock_class.data.default
|
||||
else:
|
||||
definition_data = {}
|
||||
dbmodel = self._create_new_field_data(location.category, location, definition_data, metadata)
|
||||
|
||||
@@ -41,7 +41,7 @@ def wrap_draft(item):
|
||||
draft, and `False` otherwise. Sets the item's location to the
|
||||
non-draft location in either case
|
||||
"""
|
||||
setattr(item, 'is_draft', item.location.revision == DRAFT)
|
||||
item.is_draft = (item.location.revision == DRAFT)
|
||||
item.scope_ids = item.scope_ids._replace(usage_id=item.location.replace(revision=None))
|
||||
return item
|
||||
|
||||
|
||||
@@ -190,7 +190,7 @@ class ImportSystem(XMLParsingSystem, MakoDescriptorSystem):
|
||||
err_msg
|
||||
)
|
||||
|
||||
setattr(descriptor, 'data_dir', course_dir)
|
||||
descriptor.data_dir = course_dir
|
||||
|
||||
xmlstore.modules[course_id][descriptor.location] = descriptor
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ class ConditionalModuleTest(LogicTest):
|
||||
"Make shure that ajax request works correctly"
|
||||
# Mock is_condition_satisfied
|
||||
self.xmodule.is_condition_satisfied = lambda: True
|
||||
setattr(self.xmodule.descriptor, 'get_children', lambda: [])
|
||||
self.xmodule.descriptor.get_children = lambda: []
|
||||
|
||||
response = self.ajax_request('No', {})
|
||||
html = response['html']
|
||||
|
||||
@@ -342,7 +342,7 @@ class ResourceTemplates(object):
|
||||
@classmethod
|
||||
def get_template_dir(cls):
|
||||
if getattr(cls, 'template_dir_name', None):
|
||||
dirname = os.path.join('templates', getattr(cls, 'template_dir_name'))
|
||||
dirname = os.path.join('templates', cls.template_dir_name)
|
||||
if not resource_isdir(__name__, dirname):
|
||||
log.warning("No resource directory {dir} found when loading {cls_name} templates".format(
|
||||
dir=dirname,
|
||||
|
||||
@@ -208,7 +208,7 @@ def instructor_dashboard(request, course_id):
|
||||
|
||||
if settings.MITX_FEATURES['ENABLE_MANUAL_GIT_RELOAD']:
|
||||
if 'GIT pull' in action:
|
||||
data_dir = getattr(course, 'data_dir')
|
||||
data_dir = course.data_dir
|
||||
log.debug('git pull {0}'.format(data_dir))
|
||||
gdir = settings.DATA_DIR / data_dir
|
||||
if not os.path.exists(gdir):
|
||||
@@ -222,7 +222,7 @@ def instructor_dashboard(request, course_id):
|
||||
if 'Reload course' in action:
|
||||
log.debug('reloading {0} ({1})'.format(course_id, course))
|
||||
try:
|
||||
data_dir = getattr(course, 'data_dir')
|
||||
data_dir = course.data_dir
|
||||
modulestore().try_load_course(data_dir)
|
||||
msg += "<br/><p>Course reloaded from {0}</p>".format(data_dir)
|
||||
track.views.server_track(request, "reload", {"directory": data_dir}, page="idashboard")
|
||||
|
||||
@@ -45,8 +45,8 @@ def get_commit_id(course):
|
||||
|
||||
def set_commit_id(course, commit_id):
|
||||
#course.metadata['GIT_COMMIT_ID'] = commit_id
|
||||
setattr(course, 'GIT_COMMIT_ID', commit_id)
|
||||
# setattr(def_ms.courses[reload_dir], 'GIT_COMMIT_ID', new_commit_id)
|
||||
course.GIT_COMMIT_ID = commit_id
|
||||
# def_ms.courses[reload_dir].GIT_COMMIT_ID = new_commit_id
|
||||
|
||||
|
||||
def manage_modulestores(request, reload_dir=None, commit_id=None):
|
||||
|
||||
Reference in New Issue
Block a user