# return last item in the list return prev_topic # A number to increment if the layout of the page, as expected by the client # side JS changes, and the JS is changed to update it. This version is # independent of topic content version, and is to do with code versions _layout_version = 2 @layer_cache.cache_with_key_fxn( lambda ajax=False, version_number=None: "library_content_by_topic_%s_v%s.%s" % ( "ajax" if ajax else "inline", version_number if version_number else Setting.topic_tree_version(), _layout_version)) def library_content_html(ajax=False, version_number=None): """" Returns the HTML for the structure of the topics as they will be populated on the homepage. Does not actually contain the list of video names as those are filled in later asynchronously via the cache. """ if version_number: version = topic_models.TopicVersion.get_by_number(version_number) else: version = topic_models.TopicVersion.get_default_version() tree = topic_models.Topic.get_root(version).make_tree( types=["Topics", "Video", "Url"]) topics = flatten_tree(tree)
import layer_cache import topic_models import video_models from url_model import Url from setting_model import Setting @layer_cache.cache_with_key_fxn(lambda version_number=None: "video_title_dicts_%s" % ( version_number or Setting.topic_tree_version())) def video_title_dicts(version_number=None): if version_number: version = topic_models.TopicVersion.get_by_number(version_number) else: version = None return map(lambda video: { "title": video.title, "key": str(video.key()), "relative_url": "/video/%s" % video.readable_id, "id": video.readable_id }, [v for v in video_models.Video.get_all_live(version=version) if v is not None]) @layer_cache.cache_with_key_fxn(lambda version_number=None: "url_title_dicts_%s" % ( version_number or Setting.topic_tree_version())) def url_title_dicts(version_number=None): if version_number: version = topic_models.TopicVersion.get_by_number(version_number)
import layer_cache import topic_models import video_models from url_model import Url from setting_model import Setting @layer_cache.cache_with_key_fxn( lambda version_number=None: "video_title_dicts_%s" % (version_number or Setting.topic_tree_version())) def video_title_dicts(version_number=None): if version_number: version = topic_models.TopicVersion.get_by_number(version_number) else: version = None return map( lambda video: { "title": video.title, "key": str(video.key()), "relative_url": "/video/%s" % video.readable_id, "id": video.readable_id }, [ v for v in video_models.Video.get_all_live(version=version) if v is not None ]) @layer_cache.cache_with_key_fxn( lambda version_number=None: "url_title_dicts_%s" % (version_number or Setting.topic_tree_version()))
# return last item in the list return prev_topic # A number to increment if the layout of the page, as expected by the client # side JS changes, and the JS is changed to update it. This version is # independent of topic content version, and is to do with code versions _layout_version = 1 @layer_cache.cache_with_key_fxn( lambda ajax=False, version_number=None: "library_content_by_topic_%s_v%s.%s" % ("ajax" if ajax else "inline", version_number if version_number else Setting.topic_tree_version(), _layout_version)) def library_content_html(ajax=False, version_number=None): """" Returns the HTML for the structure of the topics as they will be populated on the homepage. Does not actually contain the list of video names as those are filled in later asynchronously via the cache. """ if version_number: version = topic_models.TopicVersion.get_by_number(version_number) else: version = topic_models.TopicVersion.get_default_version() tree = topic_models.Topic.get_root(version).make_tree( types=["Topics", "Video", "Url"]) topics = flatten_tree(tree) # TODO(tomyedwab): Remove this once the confusion over the old
# return last item in the list return prev_topic # A number to increment if the layout of the page, as expected by the client # side JS changes, and the JS is changed to update it. This version is # independent of topic content version, and is to do with code versions _layout_version = 2 @layer_cache.cache_with_key_fxn( lambda ajax=False, version_number=None: "library_content_by_topic_%s_v%s.%s" % ( "ajax" if ajax else "inline", version_number if version_number else Setting.topic_tree_version(), _layout_version)) def library_content_html(ajax=False, version_number=None): """" Returns the HTML for the structure of the topics as they will be populated on the homepage. Does not actually contain the list of video names as those are filled in later asynchronously via the cache. """ if version_number: version = topic_models.TopicVersion.get_by_number(version_number) else: version = topic_models.TopicVersion.get_default_version() root = topic_models.Topic.get_root(version) if root == None: return "" tree = root.make_tree(types=["Topics", "Video", "Url"]) topics = flatten_tree(tree)