當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。