当前位置: 首页>>代码示例>>Python>>正文


Python VideoLog.get_points_for_user方法代码示例

本文整理汇总了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)
开发者ID:Eleonore9,项目名称:ka-lite,代码行数:53,代码来源:api_views.py

示例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)
开发者ID:AidanJones,项目名称:ka-lite,代码行数:19,代码来源:api_views.py

示例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)
开发者ID:aronasorman,项目名称:ka-lite-central,代码行数:7,代码来源:api_views.py


注:本文中的main.models.VideoLog.get_points_for_user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。