本文整理汇总了Python中models.Setting.topic_tree_version方法的典型用法代码示例。如果您正苦于以下问题:Python Setting.topic_tree_version方法的具体用法?Python Setting.topic_tree_version怎么用?Python Setting.topic_tree_version使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Setting
的用法示例。
在下文中一共展示了Setting.topic_tree_version方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Counter
# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import topic_tree_version [as 别名]
topic.content = []
topic.content_count = {}
topic.all_content_count = Counter(topic.content_count)
for subtopic in topic.subtopics:
topic.all_content_count.update(subtopic.all_content_count)
topic.height = math.ceil(len(topic.content)/3.0) * 18
return [topic]
@layer_cache.cache_with_key_fxn(
lambda mobile=False, version_number=None:
"library_content_by_topic_%s_v%s" % (
"mobile" if mobile else "desktop",
version_number if version_number else Setting.topic_tree_version()),
layer=layer_cache.Layers.Blobstore
)
def library_content_html(mobile=False, version_number=None):
if version_number:
version = TopicVersion.get_by_number(version_number)
else:
version = TopicVersion.get_default_version()
tree = Topic.get_root(version).make_tree(types = ["Topics", "Video", "Exercise", "Url"])
videos = [item for item in walk_children(tree) if item.kind()=="Video"]
root, = prepare(tree)
topics = root.subtopics
示例2: exercise_title_dicts
# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import topic_tree_version [as 别名]
import layer_cache
from models import Video, Url, Topic, Setting, TopicVersion, Exercise
@layer_cache.cache_with_key_fxn(lambda:
"exercise_title_dicts_%s" % Setting.cached_exercises_date())
def exercise_title_dicts():
return [{
"title": exercise.display_name,
"key": str(exercise.key()),
"relative_url": exercise.relative_url,
"id": exercise.name,
} for exercise in Exercise.get_all_use_cache() if not exercise.summative]
@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 = TopicVersion.get_by_number(version_number)
else:
version = None
return [{
"title": video.title,
"key": str(video.key()),
"relative_url": "/video/%s" % video.readable_id,
"id": video.readable_id
} for video in Video.get_all_live(version=version) if video is not None]
@layer_cache.cache_with_key_fxn(lambda version_number=None:
"url_title_dicts_%s" % (