have XModuleDescriptor properly ensure category is set

This commit is contained in:
Don Mitchell
2013-08-15 11:04:48 -04:00
committed by Chris Dodge
parent 0acc201a21
commit 03608a8931
2 changed files with 2 additions and 6 deletions

View File

@@ -215,10 +215,6 @@ class VideoDescriptor(VideoFields, TabsEditingDescriptor, EmptyDataRawDescriptor
self._model_data.update(model_data)
del self.data
# I'm not sure how, but in some lifecycles we can loose the .category attribute
# this needs to be investigated
self.category = 'video'
@classmethod
def from_xml(cls, xml_data, system, org=None, course=None):
"""

View File

@@ -467,11 +467,11 @@ class XModuleDescriptor(XModuleFields, HTMLSnippet, ResourceTemplates, XBlock):
self.system = self.runtime
if isinstance(self.location, Location):
self.url_name = self.location.name
if not hasattr(self, 'category'):
if getattr(self, 'category', None) is None:
self.category = self.location.category
elif isinstance(self.location, BlockUsageLocator):
self.url_name = self.location.usage_id
if not hasattr(self, 'category'):
if getattr(self, 'category', None) is None:
raise InsufficientSpecificationError()
else:
raise InsufficientSpecificationError()