本文整理汇总了Python中main.models.VideoLog.get_points_for_user方法的典型用法代码示例。如果您正苦于以下问题:Python VideoLog.get_points_for_user方法的具体用法?Python VideoLog.get_points_for_user怎么用?Python VideoLog.get_points_for_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类main.models.VideoLog
的用法示例。
在下文中一共展示了VideoLog.get_points_for_user方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: status
# 需要导入模块: from main.models import VideoLog [as 别名]
# 或者: from main.models.VideoLog import get_points_for_user [as 别名]
def status(request):
"""In order to promote (efficient) caching on (low-powered)
distributed devices, we do not include ANY user data in our
templates. Instead, an AJAX request is made to download user
data, and javascript used to update the page.
This view is the view providing the json blob of user information,
for each page view on the distributed server.
Besides basic user data, we also provide access to the
Django message system through this API, again to promote
caching by excluding any dynamic information from the server-generated
templates.
"""
# Build a list of messages to pass to the user.
# Iterating over the messages removes them from the
# session storage, thus they only appear once.
message_dicts = []
for message in get_messages(request):
# Make sure to escape strings not marked as safe.
# Note: this duplicates a bit of Django template logic.
msg_txt = message.message
if not (isinstance(msg_txt, SafeString) or isinstance(msg_txt, SafeUnicode)):
msg_txt = cgi.escape(str(msg_txt))
message_dicts.append({
"tags": message.tags,
"text": msg_txt,
})
# Default data
data = {
"is_logged_in": request.is_logged_in,
"registered": bool(Settings.get("registered")),
"is_admin": request.is_admin,
"is_django_user": request.is_django_user,
"points": 0,
"messages": message_dicts,
}
# Override properties using facility data
if "facility_user" in request.session:
user = request.session["facility_user"]
data["is_logged_in"] = True
data["username"] = user.get_name()
data["points"] = VideoLog.get_points_for_user(user) + ExerciseLog.get_points_for_user(user)
# Override data using django data
if request.user.is_authenticated():
data["is_logged_in"] = True
data["username"] = request.user.username
return JsonResponse(data)
示例2: status
# 需要导入模块: from main.models import VideoLog [as 别名]
# 或者: from main.models.VideoLog import get_points_for_user [as 别名]
def status(request):
data = {
"is_logged_in": request.is_logged_in,
"registered": bool(Settings.get("registered")),
"is_admin": request.is_admin,
"is_django_user": request.is_django_user,
"points": 0,
}
if "facility_user" in request.session:
user = request.session["facility_user"]
data["is_logged_in"] = True
data["username"] = user.get_name()
data["points"] = VideoLog.get_points_for_user(user) + ExerciseLog.get_points_for_user(user)
if request.user.is_authenticated():
data["is_logged_in"] = True
data["username"] = request.user.username
return JsonResponse(data)
示例3: compute_total_points
# 需要导入模块: from main.models import VideoLog [as 别名]
# 或者: from main.models.VideoLog import get_points_for_user [as 别名]
def compute_total_points(user):
if user.is_teacher:
return None
else:
return VideoLog.get_points_for_user(user) + ExerciseLog.get_points_for_user(user)