本文整理汇总了Python中shared_jinja.get函数的典型用法代码示例。如果您正苦于以下问题:Python get函数的具体用法?Python get怎么用?Python get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: badge_block
def badge_block(badge, user_badge=None, show_frequency=False,
user_data_student=None):
if user_badge:
badge.is_owned = True
if badge.is_hidden():
return "" # Don't render anything for this hidden badge
frequency = None
if show_frequency:
frequency = badge.frequency()
can_become_goal = (user_data_student and
not user_data_student.is_phantom and
not badge.is_owned and
badge.is_goal)
template_values = {"badge": badge,
"user_badge": user_badge,
"extended_description": badge.safe_extended_description,
"frequency": frequency,
"can_become_goal": can_become_goal}
return shared_jinja.get().render_template("badges/badge_block.html",
**template_values)
开发者ID:Hao-Hsuan,项目名称:KhanLatest,代码行数:26,代码来源:templatetags.py
示例2: point_info
def point_info(user_data):
if user_data:
points = user_data.points
else:
points = 0
context = {"points": points}
return shared_jinja.get().render_template("phantom_users/user_points.html", **context)
开发者ID:di445,项目名称:server,代码行数:7,代码来源:templatetags.py
示例3: exercise_message
def exercise_message(exercise, user_exercise_graph, sees_graph=False,
review_mode=False):
"""Render UserExercise html for APIActionResults["exercise_message_html"] listener in khan-exercise.js.
This is called **each time** a problem is either attempted or a hint is called (via /api/v1.py)
returns nothing unless a user is struggling, proficient, etc. then it returns the appropriat template
See Also: APIActionResults
sees_graph is part of an ab_test to see if a small graph will help
"""
# TODO(david): Should we show a message if the user gets a problem wrong
# after proficiency, to explain that this exercise needs to be reviewed?
exercise_states = user_exercise_graph.states(exercise.name)
if review_mode and user_exercise_graph.has_completed_review():
filename = 'exercise_message_review_finished.html'
elif (exercise_states['proficient'] and not exercise_states['reviewing'] and
not review_mode):
if sees_graph:
filename = 'exercise_message_proficient_withgraph.html'
else:
filename = 'exercise_message_proficient.html'
elif exercise_states['struggling']:
filename = 'exercise_message_struggling.html'
exercise_states['exercise_videos'] = exercise.related_videos_fetch()
else:
return None
return shared_jinja.get().render_template(filename, **exercise_states)
开发者ID:KhanWorld,项目名称:KhanAcademy,代码行数:35,代码来源:templatetags.py
示例4: badge_counts
def badge_counts(user_data):
counts_dict = {}
# TODO: awkward turtle, decide what happens with phantom users
link_to_profile = "/profile"
if user_data:
counts_dict = util_badges.get_badge_counts(user_data)
link_to_profile = user_data.profile_root + "/achievements"
else:
counts_dict = badges.BadgeCategory.empty_count_dict()
sum_counts = 0
for key in counts_dict:
sum_counts += counts_dict[key]
template_context = {
"link_to_profile": link_to_profile,
"sum": sum_counts,
"bronze": counts_dict[badges.BadgeCategory.BRONZE],
"silver": counts_dict[badges.BadgeCategory.SILVER],
"gold": counts_dict[badges.BadgeCategory.GOLD],
"platinum": counts_dict[badges.BadgeCategory.PLATINUM],
"diamond": counts_dict[badges.BadgeCategory.DIAMOND],
"master": counts_dict[badges.BadgeCategory.MASTER],
}
return shared_jinja.get().render_template("badges/badge_counts.html", **template_context)
开发者ID:di445,项目名称:server,代码行数:27,代码来源:templatetags.py
示例5: library_content_html
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
timestamp = time.time()
template_values = {
'topics': topics,
'is_mobile': mobile,
# convert timestamp to a nice integer for the JS
'timestamp': int(round(timestamp * 1000)),
'version_date': str(version.made_default_on),
'version_id': version.number,
'approx_vid_count': Video.approx_count(),
'exercise_count': Exercise.get_count(),
}
html = shared_jinja.get().render_template("library_content_template.html", **template_values)
return html
开发者ID:di445,项目名称:server,代码行数:30,代码来源:library.py
示例6: login_notifications_html
def login_notifications_html(text, user_data, continue_url="/"):
context = {"login_notification": text,
"continue": continue_url,
"user_data": user_data}
return shared_jinja.get().render_template(
"phantom_users/notifications.html", **context)
开发者ID:Hao-Hsuan,项目名称:KhanLatest,代码行数:7,代码来源:templatetags.py
示例7: topic_browser
def topic_browser(browser_id, version_number=None):
if version_number:
version = topic_models.TopicVersion.get_by_number(version_number)
else:
version = None
root = topic_models.Topic.get_root(version)
if not root:
return ""
tree = root.make_tree(types = ["Topics"])
# TODO(tomyedwab): Remove this once the confusion over the old Developmental Math playlists settles down
if not version:
version = topic_models.TopicVersion.get_default_version()
developmental_math = topic_models.Topic(
id="developmental-math",
version=version,
title="Developmental Math",
standalone_title="Developmental Math"
)
developmental_math.children = []
#[topic for topic in tree.children if topic.id == "math"][0].children.append(developmental_math)
template_values = {
'browser_id': browser_id, 'topic_tree': tree
}
return shared_jinja.get().render_template("topic_browser.html", **template_values)
开发者ID:PaulWagener,项目名称:khan-website,代码行数:29,代码来源:templatetags.py
示例8: email_share_video
def email_share_video(title, youtube_id, event_description=None):
contex = {}
if title and youtube_id:
subject = "I just learned about %s on Khan Academy" % title
body = "You can learn about it too. Check out %s" % (BASE_VIDEO_URL % youtube_id)
context = {"subject": subject, "body": body, "event_description": event_description}
return shared_jinja.get().render_template("social/email_share.html", **context)
开发者ID:KhanWorld,项目名称:KhanML,代码行数:8,代码来源:templatetags.py
示例9: email_share_badge
def email_share_badge(desc, activity, event_description=None):
contex = {}
if desc:
subject = "I just earned the %s %s on Khan Academy" % (desc, ("" if not activity else "in " + activity))
body = "You should check it out %s" % BASE_BADGE_URL
context = {"subject": subject, "body": body, "event_description": event_description}
return shared_jinja.get().render_template("social/email_share.html", **context)
开发者ID:KhanWorld,项目名称:KhanML,代码行数:8,代码来源:templatetags.py
示例10: playlist_content_html
def playlist_content_html():
"""" Returns the HTML for the structure of the playlists as they will be
populated ont he homepage. Does not actually contain the list of video
names as those are filled in later asynchronously via the cache.
"""
# No cache found -- regenerate HTML
smart_history = getSmartHistoryContent()
dict_playlists_by_title = {}
all_playlists = []
for playlist in Playlist.all():
if playlist.title in topics_list:
dict_playlists_by_title[playlist.title] = playlist
for topic in topics_list:
if topic in dict_playlists_by_title:
playlist = dict_playlists_by_title[topic]
video_count = playlist.get_video_count()
# 3 columns, 18px per row. This must be updated in conjunction
# with code in homepage.js
height = math.ceil(video_count / 3) * 18
playlist_data = {
'title': topic,
'topic': topic,
'playlist': playlist,
'list_height': height,
'next': None,
}
all_playlists.append(playlist_data)
playlist_data_prev = None
for playlist_data in all_playlists:
if playlist_data_prev:
playlist_data_prev['next'] = playlist_data
playlist_data_prev = playlist_data
timestamp = time.time()
template_values = {
'App' : App,
'all_playlists': all_playlists,
'smart_history': smart_history,
# convert timestamp to a nice integer for the JS
'timestamp': int(round(timestamp * 1000)),
}
html = shared_jinja.get().render_template("library_playlist_template.html",
**template_values)
Setting.cached_playlist_content_date(
str(datetime.datetime.fromtimestamp(timestamp)))
return html
开发者ID:KhanWorld,项目名称:KhanAcademy,代码行数:56,代码来源:library.py
示例11: library_content_html
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
# Developmental Math playlists settles down
developmental_math = topic_models.Topic(
id="developmental-math",
version=version,
title="Developmental Math",
standalone_title="Developmental Math",
description="The Developmental Math playlist has been reorganized. "
"The videos which used to be in the Developmental Math "
"playlist can now be found under "
"<a href=\"#algebra\">Algebra</a>."
)
developmental_math.is_super = True
developmental_math.subtopics = []
developmental_math.homepage_title = "Developmental Math"
topics.append(developmental_math)
topics.sort(key=lambda topic: topic.standalone_title)
# special case the duplicate topics for now, eventually we need to
# either make use of multiple parent functionality (with a hack
# for a different title), or just wait until we rework homepage
topics = [topic for topic in topics
if not topic.id == "new-and-noteworthy" and not
(topic.standalone_title == "California Standards Test: Geometry"
and not topic.id == "geometry-2")]
# print_topics(topics)
add_next_topic(topics)
template_values = {
'topics': topics,
'ajax': ajax,
'version_date': str(version.made_default_on),
'version_id': version.number
}
html = shared_jinja.get().render_template("library_content_template.html",
**template_values)
return html
开发者ID:PaulWagener,项目名称:khan-website,代码行数:56,代码来源:library.py
示例12: email_share_exercise
def email_share_exercise(name, problems, proficiency, event_description=None):
contex = {}
if name and problems:
subject = "I was just working on about %s on Khan Academy" % name
body = "And I answered %s question%s right %s You can try it too: %s" % (problems, "" if problems == 1 else "s", ( "to earn proficiency!" if proficiency else "." ), BASE_EXERCISE_URL)
context = { 'subject': subject,
'body': body,
'event_description': event_description }
return shared_jinja.get().render_template("social/email_share.html", **context)
开发者ID:di445,项目名称:server,代码行数:10,代码来源:templatetags.py
示例13: share_exercise_button
def share_exercise_button(problem_count, proficiency, name, event_description=None):
context = {}
if problem_count and name:
context = { 'type': 'exercise',
'problem_count': problem_count,
'proficiency': proficiency,
'name': name,
'event_description': event_description }
return shared_jinja.get().render_template("social/share_button.html", **context)
开发者ID:di445,项目名称:server,代码行数:10,代码来源:templatetags.py
示例14: facebook_share_video
def facebook_share_video(name, desc, youtube_id, event_description=None):
context = {}
if name and desc and id:
context = { 'type': 'video',
'name': name,
'desc': desc,
'id': youtube_id,
'event_description': event_description }
return shared_jinja.get().render_template("social/facebook_share.html", **context)
开发者ID:di445,项目名称:server,代码行数:10,代码来源:templatetags.py
示例15: share_video_button
def share_video_button(video_title, description, youtube_id, event_description=None):
context = {}
if video_title and description and youtube_id:
context = { 'type': 'video',
'video_title': video_title,
'description': description,
'youtube_id': youtube_id,
'event_description': event_description }
return shared_jinja.get().render_template("social/share_button.html", **context)
开发者ID:di445,项目名称:server,代码行数:10,代码来源:templatetags.py
示例16: share_badge_button
def share_badge_button(description, icon_src, extended_description, context_name, event_description=None):
context = {}
if description and icon_src and extended_description:
context = { 'type': 'badge',
'description': description,
'icon_src': icon_src,
'extended_description': extended_description,
'target_context_name': context_name,
'event_description': event_description }
return shared_jinja.get().render_template("social/share_button.html", **context)
开发者ID:di445,项目名称:server,代码行数:11,代码来源:templatetags.py
示例17: facebook_share_badge
def facebook_share_badge(desc, icon, extended_desc, activity, event_description=None):
context = {}
if desc and icon and extended_desc:
context = { 'type': 'badge',
'desc': desc,
'icon': icon,
'extended_desc': extended_desc,
'activity': activity,
'event_description': event_description }
return shared_jinja.get().render_template("social/facebook_share.html", **context)
开发者ID:di445,项目名称:server,代码行数:11,代码来源:templatetags.py
示例18: facebook_share_exercise
def facebook_share_exercise(problem_count, proficiency, name, event_description=None):
context = {}
if problem_count and name:
context = { 'type': 'exercise',
'problem_count': problem_count,
'plural': "" if problem_count == 1 else "s",
'proficiency': ("to achieve proficiency in" if proficiency else "in"),
'name': name,
'event_description': event_description }
return shared_jinja.get().render_template("social/facebook_share.html", **context)
开发者ID:di445,项目名称:server,代码行数:11,代码来源:templatetags.py
示例19: twitter_share_exercise
def twitter_share_exercise(name, problems, proficiency, event_description=None):
context = {}
if name and problems:
url = BASE_EXERCISE_URL
text = "just answered %s question%s right %s %s" % (problems, "" if problems == 1 else "s", ( "to achieve proficiency in" if proficiency else "in" ), name)
context = { 'url': url,
'text': text,
'tagline': SITE_TAGLINE,
'event_description': event_description }
return shared_jinja.get().render_template("social/twitter_share.html", **context)
开发者ID:di445,项目名称:server,代码行数:11,代码来源:templatetags.py
示例20: facebook_share_video
def facebook_share_video(name, desc, youtube_id, event_description=None):
context = {}
if name and desc and id:
context = {
"type": "video",
"name": name,
"desc": desc,
"id": youtube_id,
"event_description": event_description,
}
return shared_jinja.get().render_template("social/facebook_share.html", **context)
开发者ID:KhanWorld,项目名称:KhanML,代码行数:12,代码来源:templatetags.py
注:本文中的shared_jinja.get函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论