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


Python User.update_user_points方法代碼示例

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


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

示例1: submit_quiz

# 需要導入模塊: from src.models.user import User [as 別名]
# 或者: from src.models.user.User import update_user_points [as 別名]
def submit_quiz():
    if request.get_json() is None:
        return jsonify({"result": "error", "field":"", "message": "Not valid model!"}), 200
    quiz = Quiz.factory_form_json(request.get_json())
    if quiz.get_points() is "":
        return jsonify({"result": "error", "field":"points", "message": "Points cannot be empty"}), 200
    if not quiz.is_valid_model():
        return jsonify({"result": "error", "field":"", "message": "Not valid model!"}), 200
    if len(quiz.get_title()) == 0:
        return jsonify({"result": "error", "field": "title", "message": "Title cannot be empty!"}), 200
    if quiz.get_points() < 0:
        return jsonify({"result": "error", "field":"points", "message": "Points cannot be less then 0!"}), 200
    quiz_real = Quiz.get_by_id(uuid.UUID(quiz._id))

    passed = False
    if quiz_real.mark_subbmitted_quiz(quiz):
        passed = True
    try:
        QuizProfile.get_by_composite_id(uuid.UUID(quiz._id),session['email'])
        return jsonify({"result": "ok", "field": "title", "message": "", "relocateTo": "/quiz_profile/"+str(quiz_real.get_id()) }), 200
    except NoSuchQuizProfileExistException as e:
        new_quiz_profile = QuizProfile(uuid.UUID(quiz._id),session['email'],datetime.now(),0,passed)
        new_quiz_profile.save_to_db()
        User.update_user_points(session['email'],"virtual",quiz_real.get_points())
        return jsonify({"result": "ok", "field": "title", "message": "", "relocateTo": "/quiz_profile/"+str(quiz_real.get_id())}), 200
開發者ID:jslvtr,項目名稱:AC41004-Team-2,代碼行數:27,代碼來源:app.py

示例2: update_attended

# 需要導入模塊: from src.models.user import User [as 別名]
# 或者: from src.models.user.User import update_user_points [as 別名]
def update_attended(user, event_id):
    id_ = uuid.UUID(event_id)
    event = Event.get_by_id(id_)
    category = event.get_event_type()
    points = event.get_points()

    if EventRegister.get_user_attended(user, event_id):
        EventRegister.set_user_attended(user, event_id)
        User.update_user_points(user, category, -points)
    else:
        User.update_user_points(user, category, points)
        EventRegister.set_user_attended(user, event_id)

    return jsonify({"message": "ok"}), 200
開發者ID:jslvtr,項目名稱:AC41004-Team-2,代碼行數:16,代碼來源:app.py


注:本文中的src.models.user.User.update_user_points方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。