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


Python User.first_name方法代码示例

本文整理汇总了Python中model.User.first_name方法的典型用法代码示例。如果您正苦于以下问题:Python User.first_name方法的具体用法?Python User.first_name怎么用?Python User.first_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在model.User的用法示例。


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

示例1: register_post

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import first_name [as 别名]
def register_post():

    # Create the user object to store our data
    user = User()
    user.first_name = request.form.get('first_name')
    user.last_name = request.form.get('last_name')
    user.email = request.form.get('email')
    user.phone = request.form.get('phone')
    user.password = request.form.get('password')
    user.role = request.form.get('role')

    existing = db_session.query(User).filter_by(email=user.email).first()
    if existing:
        flash("Email already in use", "error")
        return redirect(url_for("user_login_get"))


    # Add the user object to the database
    db_session.add(user)

    # Save the user in the database
    db_session.commit()

    # # Redirect user to landing page
    return redirect(url_for("traveler_view_trip"))
开发者ID:jessjoschwartz,项目名称:Lighthouse,代码行数:27,代码来源:controller.py

示例2: authenticate

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import first_name [as 别名]
def authenticate():
    if request.form['btn'] == "login": 
        form_login = forms.LoginForm(request.form)
        if not form_login.validate():
            flash("Incorrect username or password") 
            return render_template("create_info")

        email = form_login.email.data
        password = form_login.password.data

        user = User.query.filter_by(email=email).first()

        if not user or not user.authenticate(password):
            flash("Incorrect username or password")         
            return render_template("login.html")

        login_user(user)
        session["user_id"] = user.id
        return redirect(request.args.get("next", url_for("browse")))

    elif request.form['btn'] == "register": 
        password = request.form.get("password")
        email = request.form.get("email")
        first_name=request.form.get("first_name")
        last_name=request.form.get("last_name")
        new_user = User(email=email)
        new_user.set_password(password=password)
        new_user.first_name=first_name
        new_user.last_name=last_name
        model.session.add(new_user)
        model.session.commit()

        return redirect(url_for("create_info"))

    elif request.form['btn'] == "fb_login":
        fb_name = request.form.get("name")
        if current_user.is_anonymous == False:
            current_user.fb_id = fb_id
            current_user.fb_img_url = "https://graph.facebook.com/%s/picture?type=small" % fb_id 
            print current_user.fb_img_url 
            model.session.commit()
            model.session.refresh()
        return redirect(url_for("browse"))
开发者ID:dslevi,项目名称:CS-Go,代码行数:45,代码来源:controller.py

示例3: register_submit

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import first_name [as 别名]
def register_submit():
    """ Register new user """

    firstname = request.form.get('firstname')
    lastname = request.form.get('lastname')
    email = request.form.get('newemail')
    password1 = request.form.get('password1')

    if User.query.filter_by(email=email).first():
        flash("A user already exists with this email")
        return render_template("register.html")
    else:
        new_user = User(email, password1)
        db.session.add(new_user)
        new_user.first_name = firstname
        new_user.last_name = lastname
        db.session.commit()
        if not session.get('new_user.user_id'):
            session['user_id'] = new_user.user_id
        flash("You have been registered successfully.")
        return redirect("/dashboard")
开发者ID:bpownow,项目名称:BreakItUp,代码行数:23,代码来源:server.py


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