Commit 4ec3683c by Chris Dodge

clean up some pylint violations

parent 26f44245
...@@ -10,7 +10,7 @@ class CourseMetadata(object): ...@@ -10,7 +10,7 @@ class CourseMetadata(object):
''' '''
# __new_advanced_key__ is used by client not server; so, could argue against it being here # __new_advanced_key__ is used by client not server; so, could argue against it being here
FILTERED_LIST = XModuleDescriptor.system_metadata_fields + ['start', 'end', 'enrollment_start', 'enrollment_end', 'tabs', 'graceperiod', '__new_advanced_key__'] FILTERED_LIST = XModuleDescriptor.system_metadata_fields + ['start', 'end', 'enrollment_start', 'enrollment_end', 'tabs', 'graceperiod', '__new_advanced_key__']
@classmethod @classmethod
def fetch(cls, course_location): def fetch(cls, course_location):
""" """
...@@ -18,17 +18,17 @@ class CourseMetadata(object): ...@@ -18,17 +18,17 @@ class CourseMetadata(object):
""" """
if not isinstance(course_location, Location): if not isinstance(course_location, Location):
course_location = Location(course_location) course_location = Location(course_location)
course = {} course = {}
descriptor = get_modulestore(course_location).get_item(course_location) descriptor = get_modulestore(course_location).get_item(course_location)
for k, v in descriptor.metadata.iteritems(): for k, v in descriptor.metadata.iteritems():
if k not in cls.FILTERED_LIST: if k not in cls.FILTERED_LIST:
course[k] = v course[k] = v
return course return course
@classmethod @classmethod
def update_from_json(cls, course_location, jsondict): def update_from_json(cls, course_location, jsondict):
""" """
...@@ -37,7 +37,7 @@ class CourseMetadata(object): ...@@ -37,7 +37,7 @@ class CourseMetadata(object):
Ensures none of the fields are in the blacklist. Ensures none of the fields are in the blacklist.
""" """
descriptor = get_modulestore(course_location).get_item(course_location) descriptor = get_modulestore(course_location).get_item(course_location)
dirty = False dirty = False
for k, v in jsondict.iteritems(): for k, v in jsondict.iteritems():
...@@ -45,26 +45,26 @@ class CourseMetadata(object): ...@@ -45,26 +45,26 @@ class CourseMetadata(object):
if k not in cls.FILTERED_LIST and (k not in descriptor.metadata or descriptor.metadata[k] != v): if k not in cls.FILTERED_LIST and (k not in descriptor.metadata or descriptor.metadata[k] != v):
dirty = True dirty = True
descriptor.metadata[k] = v descriptor.metadata[k] = v
if dirty: if dirty:
get_modulestore(course_location).update_metadata(course_location, descriptor.metadata) get_modulestore(course_location).update_metadata(course_location, descriptor.metadata)
# 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 # 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 # it persisted correctly
return cls.fetch(course_location) return cls.fetch(course_location)
@classmethod @classmethod
def delete_key(cls, course_location, payload): def delete_key(cls, course_location, payload):
''' '''
Remove the given metadata key(s) from the course. payload can be a single key or [key..] Remove the given metadata key(s) from the course. payload can be a single key or [key..]
''' '''
descriptor = get_modulestore(course_location).get_item(course_location) descriptor = get_modulestore(course_location).get_item(course_location)
for key in payload['deleteKeys']: for key in payload['deleteKeys']:
if key in descriptor.metadata: if key in descriptor.metadata:
del descriptor.metadata[key] del descriptor.metadata[key]
get_modulestore(course_location).update_metadata(course_location, descriptor.metadata) get_modulestore(course_location).update_metadata(course_location, descriptor.metadata)
return cls.fetch(course_location) return cls.fetch(course_location)
\ No newline at end of file
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