当前位置: 首页>>代码示例>>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;未经允许,请勿转载。