Commit bbf508ca by Ned Batchelder

fix-setattr-and-getattr

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