diff --git a/common/lib/xmodule/xmodule/modulestore/mongo/base.py b/common/lib/xmodule/xmodule/modulestore/mongo/base.py
index 631dca9846..94814264b7 100644
--- a/common/lib/xmodule/xmodule/modulestore/mongo/base.py
+++ b/common/lib/xmodule/xmodule/modulestore/mongo/base.py
@@ -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)
diff --git a/common/lib/xmodule/xmodule/modulestore/mongo/draft.py b/common/lib/xmodule/xmodule/modulestore/mongo/draft.py
index 610f7b1b8a..240f864c7e 100644
--- a/common/lib/xmodule/xmodule/modulestore/mongo/draft.py
+++ b/common/lib/xmodule/xmodule/modulestore/mongo/draft.py
@@ -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
diff --git a/common/lib/xmodule/xmodule/modulestore/xml.py b/common/lib/xmodule/xmodule/modulestore/xml.py
index dd7888179b..27bdc6b2ba 100644
--- a/common/lib/xmodule/xmodule/modulestore/xml.py
+++ b/common/lib/xmodule/xmodule/modulestore/xml.py
@@ -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
diff --git a/common/lib/xmodule/xmodule/tests/test_conditional_logic.py b/common/lib/xmodule/xmodule/tests/test_conditional_logic.py
index 72b9aec0c1..f6a9daaf4f 100644
--- a/common/lib/xmodule/xmodule/tests/test_conditional_logic.py
+++ b/common/lib/xmodule/xmodule/tests/test_conditional_logic.py
@@ -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']
diff --git a/common/lib/xmodule/xmodule/x_module.py b/common/lib/xmodule/xmodule/x_module.py
index edb9e7f640..60dc03feb3 100644
--- a/common/lib/xmodule/xmodule/x_module.py
+++ b/common/lib/xmodule/xmodule/x_module.py
@@ -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,
diff --git a/lms/djangoapps/instructor/views/legacy.py b/lms/djangoapps/instructor/views/legacy.py
index 9e77f55a29..749a7004aa 100644
--- a/lms/djangoapps/instructor/views/legacy.py
+++ b/lms/djangoapps/instructor/views/legacy.py
@@ -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 += "
Course reloaded from {0}
".format(data_dir) track.views.server_track(request, "reload", {"directory": data_dir}, page="idashboard") diff --git a/lms/djangoapps/lms_migration/migrate.py b/lms/djangoapps/lms_migration/migrate.py index 32c6f17500..d028ce8e5a 100644 --- a/lms/djangoapps/lms_migration/migrate.py +++ b/lms/djangoapps/lms_migration/migrate.py @@ -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):