當前位置: 首頁>>代碼示例>>Python>>正文


Python ExerciseLog.get_points_for_user方法代碼示例

本文整理匯總了Python中main.models.ExerciseLog.get_points_for_user方法的典型用法代碼示例。如果您正苦於以下問題:Python ExerciseLog.get_points_for_user方法的具體用法?Python ExerciseLog.get_points_for_user怎麽用?Python ExerciseLog.get_points_for_user使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在main.models.ExerciseLog的用法示例。


在下文中一共展示了ExerciseLog.get_points_for_user方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: status

# 需要導入模塊: from main.models import ExerciseLog [as 別名]
# 或者: from main.models.ExerciseLog 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 ExerciseLog [as 別名]
# 或者: from main.models.ExerciseLog 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 ExerciseLog [as 別名]
# 或者: from main.models.ExerciseLog 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.ExerciseLog.get_points_for_user方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。