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


Python User.add_user方法代码示例

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


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

示例1: login

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import add_user [as 别名]
def login():
    """Log in page"""

    name = request.form.get('name')
    email = request.form.get('email')
    image = request.form.get('image')

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

    if user:
        user_id = user.user_id
        session['user_id']=user_id
        session['name']=name
        session['image']=image
       
        return "%s is in session" %(name)

    if not user:
        User.add_user(email=email, name=name, image=image)
        session['user_id']=user_id
        session['name']=name
        session['image']=image
       
        return "%s is in session" %(name)

    else:
        return None
开发者ID:katherinehuwu,项目名称:Word_Fit,代码行数:29,代码来源:server.py

示例2: test_add_user

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import add_user [as 别名]
    def test_add_user(self):
        # Ensures that a food object is created in the database
        # when the mush form is submitted

        User.add_user("[email protected]", "test", "test", "test")

        assert User.query.filter_by(email="[email protected]").one()
开发者ID:akvanhar,项目名称:MakeLessMush,代码行数:9,代码来源:tests.py

示例3: facebook_login

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import add_user [as 别名]
def facebook_login():
    # Handles the login from the facebook login button

    fb_user_id = request.form.get('fbUserId')
    fb_fname = request.form.get('fbFname')
    fb_lname = request.form.get('fbLname')
    fb_email = request.form.get('fbEmail')
    current_acces_token = request.form.get('accessToken')
    fb_friends = request.form.get('fbFriends')

    fb_friends = json.loads(fb_friends)
    fb_user = User.query.filter_by(fb_id=fb_user_id).first()

    if fb_user:
        # User has previously logged into MLM
        user_id = fb_user.user_id
        session['user_id'] = user_id
        session['current_acces_token'] = current_acces_token

        # check friends list in friends table. If friendship not there, add it.
        if fb_friends:
            friends_user_ids = []
            # turn the fb_ids into user_ids.
            for friend_fb_id in fb_friends:
                friend_user_id = db.session.query(User.user_id
                                                  ).filter_by(
                                                  fb_id=friend_fb_id
                                                  ).first()
                friends_user_ids.append(friend_user_id)
            friends_user_ids = [x[0] for x in friends_user_ids]

            # now see if those friends are in the friendship table.
            for friend in friends_user_ids:
                friend_exists = db.session.query(Friendship.friend_id
                                                 ).filter_by(friend_id=friend
                                                             ).first()
                # if they're not, add them in! Yay friendship!
                if friend_exists is None:
                    Friendship.add_friendship(user_id, friend)

        flash('Login successful!')

        return redirect('/home')
    else:
        # First time for user logging into MLM
        # add the user to the database
        User.add_user(email=fb_email, fname=fb_fname,
                      lname=fb_lname, fb_id=fb_user_id)
        # access that user's information, add it to the session
        fb_user = User.query.filter_by(fb_id=fb_user_id).first()
        user_id = fb_user.user_id

        session['user_id'] = user_id
        session['current_acces_token'] = current_acces_token

        flash('Thanks for creating an account with Make Less Mush')

        return redirect('/home')
开发者ID:akvanhar,项目名称:MakeLessMush,代码行数:60,代码来源:server.py

示例4: signup_portal

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import add_user [as 别名]
def signup_portal():
    """Create new user and add the user to the database"""
    email = request.form.get('email')
    password = request.form.get('password')
    age = request.form.get('age')
    zipcode = request.form.get('zipcode')


    User.add_user(email, password, age, zipcode)

    return redirect("/login")
开发者ID:katherinehuwu,项目名称:ratings,代码行数:13,代码来源:server.py

示例5: account_feedback

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import add_user [as 别名]
def account_feedback():
    email = request.form.get('email')
    password = request.form.get('password')
    fname = request.form.get('fname')
    lname = request.form.get('lname')

    user = User.query.filter_by(email=email).first()
    if user:
        flash("Hi, %s, you already have an account"%fname)
        return redirect("/")
    else:
        User.add_user(  email=email, 
                        password=password,
                        fname=fname,
                        lname=lname)
        flash("Congrats %s! You've successfully created an account!\nYou can now log in."%fname)
        return redirect("/")
开发者ID:bmeck,项目名称:Word_Fit,代码行数:19,代码来源:server.py

示例6: signup_portal

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import add_user [as 别名]
def signup_portal():
    # Handles the signup form

    email = request.form.get('email')
    password = request.form.get('password')
    password = hash(password)
    fname = request.form.get('fname')
    fname = titlecase(fname)
    lname = request.form.get('lname')
    lname = titlecase(lname)
    User.add_user(email, fname, lname, password)

    # automatically sign in user after account creation
    user = User.query.filter_by(email=email, password=password).first()
    user_id = user.user_id
    session['user_id'] = user_id
    flash('Account successfully created. Welcome to Make Less Mush!')

    return redirect('/home')
开发者ID:akvanhar,项目名称:MakeLessMush,代码行数:21,代码来源:server.py


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