def get_track_zh(self, obj): _value = obj.transcripts.get('zh', '') if _value: cleaned_value = AssetLocator.clean_keeping_underscores(_value) if self.course_key.deprecated: value = '/c4x/%s/%s/asset/%s' % (self.course_key.org, self.course_key.course, cleaned_value) else: value = '/asset-v1:%s+%s+%s+type@asset+block@%s' % ( self.course_key.org, self.course_key.course, self.course_key.run, cleaned_value) return _normalizeUrl(value) else: return ''
def compute_location(course_key, path, revision=None, is_thumbnail=False): """ Constructs a location object for static content. - course_key: the course that this asset belongs to - path: is the name of the static asset - revision: is the object's revision information - is_thumbnail: is whether or not we want the thumbnail version of this asset """ path = path.replace('/', '_') return course_key.make_asset_key( 'asset' if not is_thumbnail else 'thumbnail', AssetLocator.clean_keeping_underscores(path)).for_branch(None)
def compute_location(course_key, path, revision=None, is_thumbnail=False): """ Constructs a location object for static content. - course_key: the course that this asset belongs to - path: is the name of the static asset - revision: is the object's revision information - is_thumbnail: is whether or not we want the thumbnail version of this asset """ path = path.replace('/', '_') return course_key.make_asset_key( 'asset' if not is_thumbnail else 'thumbnail', AssetLocator.clean_keeping_underscores(path) ).for_branch(None)
def compute_location(course_key, path, revision=None, is_thumbnail=False): """ Constructs a location object for static content. - course_key: the course that this asset belongs to - path: is the name of the static asset - revision: is the object's revision information - is_thumbnail: is whether or not we want the thumbnail version of this asset """ path = path.replace('/', '_') # todo: new coursekeys behave weirdly with assets, will break if title is non ascii # if an asset path is empty (i.e. course image url is empty) split mongo course assets will # throw exceptions. thus we bypass that and just return an empty key if len(path) == 0 and not course_key.deprecated: return "" return course_key.make_asset_key( 'asset' if not is_thumbnail else 'thumbnail', AssetLocator.clean_keeping_underscores(path) ).for_branch(None)