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


Python user.User类代码示例

本文整理汇总了Python中src.models.user.User的典型用法代码示例。如果您正苦于以下问题:Python User类的具体用法?Python User怎么用?Python User使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: register_user

def register_user():
    email = request.form['email']
    password = request.form['password']

    User.register(email, password)

    return render_template("profile.html", email=session['email'])
开发者ID:Shutirtho,项目名称:BlogWebApplication_using_Python_Flask,代码行数:7,代码来源:application.py

示例2: submit_quiz

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,代码行数:25,代码来源:app.py

示例3: admin_edit_profile_page

def admin_edit_profile_page(user):
    universities = University.get_uni_list()
    profile = User.find_by_email(user)
    mypermissions = User.get_user_permissions(session['email'])
    permissions = [permission_level for permission_level in Database.find(Permissions.COLLECTION, {})]
    return render_template('edit-profile.html', user=user, universities=universities, profile=profile,
                           permissions=permissions, mypermissions=mypermissions)
开发者ID:jslvtr,项目名称:AC41004-Team-2,代码行数:7,代码来源:app.py

示例4: save

def save():
    if request.method == 'POST':
        username = request.form['username']
        password = request.form['password']
        user = User(username, password)
        user.save()
    return
开发者ID:WeRockStar,项目名称:android-mongodb,代码行数:7,代码来源:app.py

示例5: user_blogs

def user_blogs(user_id=None):
    if user_id is not None:
        user = User.get_by_id(user_id)
    else:
        user = User.get_by_email(session['email'])
    blogs = user.get_blogs()
    return render_template('user_blogs.html', blogs=blogs, email=user.email)
开发者ID:leverage2014,项目名称:python_web_blog,代码行数:7,代码来源:app.py

示例6: test_save_simple_user_to_db

    def test_save_simple_user_to_db(self):
        email = "[email protected]"
        user = User(email, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
        user.permissions = Permissions.default().name
        user.save_to_db()

        self.assertIsNotNone(User.find_by_email(email))

        Database.remove("users", {"email": email})
开发者ID:jslvtr,项目名称:AC41004-Team-2,代码行数:9,代码来源:test_user.py

示例7: home_function

def home_function():
    email = request.form['email']
    password = request.form['password']
    if User.login_valid(email,password):
        User.login_valid(email,password)
    else:
        session['email'] = None

    return render_template('homepage.html',user=session['email'])
开发者ID:rohit-136,项目名称:Sherlock_partial,代码行数:9,代码来源:app.py

示例8: login

def login():
    email = request.form['email']
    password = request.form['password']

    if User.login_valid(email, password):
        User.login(email)
    else:
        session['email'] = None
    return render_template("profile.html", email=session['email'])
开发者ID:Shutirtho,项目名称:BlogWebApplication_using_Python_Flask,代码行数:9,代码来源:application.py

示例9: login_user

def login_user():
    email = request.form['email']
    password = request.form['password']
    if User.login_valid(email, password):
        print('user verified')
        User.login(email)
    else:
        session['email'] = None
    print('session email', session['email'])
    return render_template('profile.html', email=session['email'])
开发者ID:leverage2014,项目名称:python_web_blog,代码行数:10,代码来源:app.py

示例10: edit_profile

def edit_profile():
    if User.check_login(session['email'], request.form['password']):
        user = User.find_by_email(session['email'])
        user.data.update(firstname=request.form['firstname'], lastname=request.form['lastname'],
                         university=request.form['university'], level=request.form['level'],
                         country=request.form['country'], school=request.form['college'],
                         subject=request.form['course'], year=request.form['yearofstudy'])

        user.save_to_db()
        return make_response(view_profile())
    else:
        return render_template('user-profile.html', message="Incorrect Password")
开发者ID:jslvtr,项目名称:AC41004-Team-2,代码行数:12,代码来源:app.py

示例11: login_user

def login_user():
    email = request.form['email']
    password = request.form['password']

    if User.login_valid(email, password):
        User.login(email)
    else:
        session['email'] = None
        return render_template('login.html',
                               failed_login=True)  # check if variable check_login is passed, other wise do not display error message

    return render_template("profile.html", email=session['email'])
开发者ID:ibininja,项目名称:blpymo,代码行数:12,代码来源:app.py

示例12: login_user

def login_user():
    email=request.form['email']
    password=request.form['password']


    if User.login_valid(email,password):
        User.login(email)
    else:
        session['email']=None
        print('Wrong Details')
        return render_template("login.html",email=session['email'])

    return render_template("choice.html",email=session['email'])
开发者ID:hg0605,项目名称:iprint,代码行数:13,代码来源:app.py

示例13: admin_update_user_profile

def admin_update_user_profile():
    if User.check_login(session['email'], request.form['password']):
        user = User.find_by_email(request.form['email'])
        user.data.update(firstname=request.form['firstname'], lastname=request.form['lastname'],
                         university=request.form['university'], level=request.form['level'],
                         country=request.form['country'], school=request.form['college'],
                         subject=request.form['course'], year=request.form['yearofstudy'],
                         permissions=request.form['permissions'])

        user.save_to_db()
        return redirect("/admin/view-profile/" + request.form['email'])
    else:
        return render_template('user-profile.html', message="Incorrect Password")
开发者ID:jslvtr,项目名称:AC41004-Team-2,代码行数:13,代码来源:app.py

示例14: login_userapp

def login_userapp():
    email=request.form['email']
    password=request.form['password']


    if User.login_valid(email,password):
        User.login(email)
        print('Correct Details')
    else:
        session['email']=None
        print('Wrong Details')


    return jsonify({"status":"success"})
开发者ID:hg0605,项目名称:iprint,代码行数:14,代码来源:app.py

示例15: update_attended

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,代码行数:14,代码来源:app.py


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