def problem_location(problem_url_name): """ Create an internal location for a test problem. """ if "i4x:" in problem_url_name: return Location.from_deprecated_string(problem_url_name) else: return TEST_COURSE_KEY.make_usage_key('problem', problem_url_name)
def to_python(self, location): """ Deserialize to a UsageKey instance: for now it's a location missing the run """ assert isinstance(location, (NoneType, basestring, Location)) if location == '': return None if isinstance(location, basestring): location = super(UsageKeyField, self).to_python(location) return Location.from_deprecated_string(location) else: return location
def to_python(self, value): if value is self.Empty or value is None: return value assert isinstance(value, (basestring, Location)) if value == '': return None if isinstance(value, basestring): return Location.from_deprecated_string(value) else: return value