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


Python User.email方法代码示例

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


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

示例1: fb_oauth_request

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import email [as 别名]
def fb_oauth_request():
    """handle facebook oauth requests"""
    user = None
    user_info = {}
    # do not request real data if testing
    if app.config["TESTING"] is True:
        print "testing enabled, adding fake fb user"
        # and request.data == 'testytesttest':
        for f in fb_user_info_fields:
            user_info[f] = "test_%s" % f
        login_session["state"] = "testingstate"
        login_session["user_info"] = user_info
        flash("You are now logged in as %s" % user_info["name"])
        user = User()
        user.fb_id = "12345"
        user.email = user_info["email"]
        user.picture = user_info["picture"]
        user.provider = user_info["provider"]
        user.name = user_info["name"]
        session.add(user)
        session.commit()
        # add id after .commit() assigns it
        user_info["user_id"] = user.id

        return make_json_response(json.dumps("ok"), 200)

    else:
        if request.args.get("state") != login_session["state"]:
            print "fbconnect: bad state parameter"
            flash("bad login state parameter")
            return make_json_response(json.dumps("invalid state parameter."), 401)

        # continue oauth flow
        user_info = getUserDataFB(request)
        if "error" in user_info.keys():
            return make_json_response(user_info["error"], 400)

    # oauth successful

    # check db for existing user
    try:
        user = session.query(User).filter_by(email=user_info["email"]).one()
    except db.NoResultFound:
        # create a new user
        user = User()
        user.fb_id = user_info["facebook_id"]
        user.email = user_info["email"]
        user.picture = user_info["picture"]
        user.provider = user_info["provider"]
        user.name = user_info["name"]
        session.add(user)
        session.commit()

    user_info["user_id"] = user.id

    flash("You are now logged in as %s" % user_info["name"])

    # add user to session
    login_session["user_info"] = user_info
    return make_json_response(json.dumps("ok"), 200)
开发者ID:JohnFrazier,项目名称:udacity-catalog-project,代码行数:62,代码来源:application.py

示例2: test_Create_Duplicate_User

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import email [as 别名]
  def test_Create_Duplicate_User(self):
    user_email = utilities.fake.free_email()

    user1 = User()
    user1.uuid = utilities.generate_UUID()
    user1.email = user_email
    user1.save()

    user2 = User()
    user2.uuid = utilities.generate_UUID()
    user2.email = user_email
    with self.assertRaises(IntegrityError):
      user2.save()
开发者ID:jrigden,项目名称:muckamuck,代码行数:15,代码来源:test_models.py

示例3: register

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import email [as 别名]
def register():
    form = RegistrationForm(csrf_enabled=False)
    if request.method == 'POST' and form.validate():
        user = User()
        user.id = form.id.data
        user.first_name = form.first_name.data
        user.last_name = form.last_name.data
        user.password = form.password.data
        user.email = form.email.data
        user.contact_no = form.contact_no.data
        user.branch = form.branch.data
        user.profile_type = request.form['profile_type']
        profile_pic = request.files['profile_pic']

        if profile_pic:
            profile_pic_extension = ctrl.get_extension_of_file(profile_pic.filename)
            user.profile_pic_extension = profile_pic_extension
            file_op.save_profile_pic(profile_pic, user.id)

        if user.profile_type != 'P':
            ctrl.mkdir_p(os.path.join(app.config['SOLUTION_FILES_DEST'], user.id))
        user.is_active = 'Y'

        db_session = get_db_session()
        insert_to_db(db_session, user)
        return render_template('forms/registration_success.html')
    return render_template('forms/register.html', form=form)
开发者ID:hbj508,项目名称:online-judge,代码行数:29,代码来源:views.py

示例4: signin

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import email [as 别名]
def signin():
    form = SigninForm()

    if form.validate_on_submit():

        if len(User.query.filter_by(nickname=form.nickname.data).all()) > 0:
            flash(gettext("Selected username already exists!"), category='alert-danger')
            return redirect(url_for('signin'))

        new_email = form.email.data
        check_mail = User.query.filter_by(email=new_email).all()

        #user mail already exists
        if len(check_mail) > 0:
            flash(gettext('Selected email is already in use!'), category='alert-danger')
            return redirect(url_for('signin'))

        user = User()
        user.nickname = form.nickname.data
        user.password = generate_password_hash(form.password.data)
        user.email = new_email
        user.language = form.language.data

        # default role is user, not admin
        user.role = USER_ROLES['ROLE_USER']

        db.session.add(user)
        db.session.commit()

        flash(gettext('Thank you for joining us!'))
        return redirect(url_for('index'))

    return render_template('login/signin.html',
                           title=gettext('Sign In'),
                           form=form)
开发者ID:GriffinHeart,项目名称:Dodgeball,代码行数:37,代码来源:viewsLogin.py

示例5: post

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import email [as 别名]
    def post(self):
        if self.user:
            self.redirect(self.uri_for('www-dashboard-admin'))
            return

        if self.request.get('email') and self.request.get('first_name') and self.request.get('last_name') and self.request.get('password'):
            email = self.request.get('email').strip().lower()
            name = self.request.get('first_name') + " " + self.request.get('last_name')
            phone = self.request.get('phone')
            password = self.request.get('password')
            user = User.get_by_id(email)
            if user:
                self.redirect(self.uri_for('www-register', error="User already exist. Please log in."))
                return

            user = User(id=email)
            user.email = email
            user.password = hash_password(email, password)            
            user.name = name
            user.phone = phone

            user.put()
            self.login(user)
            if self.request.get('goto'):
                self.redirect(self.request.get('goto'))
            else:
                self.redirect(self.uri_for('www-dashboard-admin'))
            return
        else:
            self.redirect(self.uri_for('www-register', Error="Please enter the all information required."))
开发者ID:kramix888,项目名称:clearfix,代码行数:32,代码来源:main.py

示例6: auth_callback

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import email [as 别名]
    def auth_callback(self):
        client_token = request.args.get('token')

        # Check the provided token is valid.
        token_user = current_app.trello.fetch_member('me', client_token)
        user_id = token_user['id']
        user_email = token_user['email']
        user_name = token_user['fullName']

        # Create/Update existing user...
        user = current_app.db.session.query(User).filter_by(trello_id=user_id).first()
        if user is None:
            # Make a user
            user = User(trello_id=user_id)
            current_app.db.session.add(user)

        # Update their details
        user.name = user_name
        user.email = user_email
        user.trello_token = client_token

        current_app.db.session.commit()

        # And log them in...
        login_user(user, remember=True)

        return redirect(url_for('IndexView:index'))
开发者ID:nickw444,项目名称:trello-scheduled,代码行数:29,代码来源:views.py

示例7: insertUser

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import email [as 别名]
def insertUser(request):
    errors = []
    u = User()
    u.user = re.escape(request.POST.get('user'))
    u.email = request.POST.get('email')
    
    password = re.escape(request.POST.get('password'))
    salt = uuid.uuid4().hex
    hashed_password = hashlib.sha512(password + salt).hexdigest()
    
    u.password = hashed_password
    u.salt = salt
    u.locked = False
    u.activated = False
    u.attempts = 0
    
    num_users = u.query(User.user==u.user).count()
    num_emails = u.query(User.email==u.email).count()
    if num_users == 0 and num_emails == 0:
        code = hashlib.sha512(u.user + salt).hexdigest()
        u.code = re.escape(code)
        u.put()
        params = { 'user' : u.user, 'code': code}
        sendEmail(u.email, "Account verification url: http://dsswkvn.appspot.com/validateaccount?" + urllib.urlencode(params))
        return True
    else:
        message = "No se ha podido insertar el usuario"
        if (num_users != 0):
            errors.append("User already exists")
        if (num_emails != 0):
            errors.append("Email already exists")
        template_values = {
            'errors': errors
            }
        return template_values
开发者ID:jipvazoj,项目名称:ProyectoMasterKevin,代码行数:37,代码来源:methods.py

示例8: signup

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import email [as 别名]
def signup():
    """For GET requests, display the login form. For POSTS, login the current user
    by processing the form."""

    form = SignupForm()
    if form.validate_on_submit():
        if form.password.data != form.retype_password.data:
            flash('Invalid Password')
            return render_template("signup.html", form=form)

        user = User.query.get(form.email.data)
        if user :
            flash('User already exists')
            return render_template("signup.html", form=form)          

        user = User()
        user.email = form.email.data
        user.password = bcrypt.generate_password_hash(form.password.data)
        user.first_name = form.first_name.data
        user.last_name = form.last_name.data
        user.contact_no = form.contact_no.data

        # Adding Zero Balance to user
        user.balance = Balance()
        user.balance.amount = 0.0

        db.session.add(user)
        db.session.commit()

        return redirect(url_for("login"))

    return render_template("signup.html", form=form)
开发者ID:mthipparthi,项目名称:playnpay,代码行数:34,代码来源:app.py

示例9: activate

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import email [as 别名]
def activate(key):
	""" Activate profile. Create a new user object. 
		We use the email as username.
	"""
	profile = RegistrationProfile.query.filter(
		RegistrationProfile.activation_key==key).first()
	
	if not profile:
		return render_template("auth/activation_failed.html")

	if not profile.activation_date == None:
		return render_template("auth/already_activated.html")
	
	if profile.expiration_date > datetime.datetime.now():
		user = User()
		user.first_name = profile.first_name
		user.last_name = profile.last_name
		user.email = profile.email
		user.username = profile.email
		user.password = profile.password
		profile.activation_date = datetime.datetime.now()
		user.dob = profile.dob
		user.identifier_id= profile.identifier_id
		user.country = profile.country
		user.zipcode = profile.zipcode
		user.city = profile.city
		user.street = profile.street
		db_session.add(user)
		db_session.add(profile)
		db_session.commit()
		flash("Your account has been activated. You may login now.")
		return redirect(url_for('index'))
	return render_template("auth/activation_expired.html")
开发者ID:miku,项目名称:evreg,代码行数:35,代码来源:app.py

示例10: register

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import email [as 别名]
def register():
    error = None
    form = RegisterForm()
    next = get_redirect_target()
    next = retain_before_auth_page(next)
    if request.method == 'POST':
        if request.form['submit'] == 'cancel':
            return redirect_back('index')
        else:
            if form.validate_on_submit():
                user = User(
                    username=form.username.data,
                    email=form.email.data,
                    password=bcrypt.generate_password_hash(form.password.data)
                )
                db.session.add(user)
                db.session.commit()

                if not form.email.data:
                    user=User.query.filter_by(username=form.username.data).first()
                    user.email = 'defaultemail_' + str(user.id) + '@gmail.com'
                    db.session.add(user)
                    db.session.commit()

                login_user(user)
                flash('You were logged in. ', 'success')

                return redirect_back('index')

            return render_template('register.html', form=form, error=error, next=next)
    return render_template('register.html', form=form, error=error, next=next)
开发者ID:jmjuanico,项目名称:blogapp,代码行数:33,代码来源:views.py

示例11: signup

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import email [as 别名]
def signup():
    form = SignupForm(request.form)
    if form.validate_on_submit():
        user = User()
        form.populate_obj(user)
        username_exist = User.query.filter_by(username=form.username.data).first()
        email_exist = User.query.filter_by(email=form.email.data).first()
        if username_exist:
            form.username.errors.append('User already exists')
        if email_exist:
            form.email.errors.append('Email already exists')
        if username_exist or email_exist:
            return render_template('signup.html', form=form, signinpage_form=LoginForm(),
                                   page_title='Sign up form')
        else:
            user.firstname = 'firstname',
            user.lastname = 'lastname',
            user.email = form.email.data,
            user.password = hash_password(form.password.data),
            user.biography = 'This is a test portfolio',
            user.avatar = 'http://placehold.it/350/300',
            db.session.add(user)
            db.session.commit()
            return render_template("signup-success.html", signinpage_form=LoginForm(), form=form,
                                   page_title='Success page on signup',
                                   user=user)
    else:
        return render_template('signup.html', signinpage_form=LoginForm(), form=form,
                               page_title='This is the signup form')
开发者ID:andela-rekemezie,项目名称:Online-Portfolio-Manager,代码行数:31,代码来源:main.py

示例12: register

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import email [as 别名]
def register():
    if request.method == 'POST':
        logger.info('Registration POST: %s%s%s'\
                    % (request.form['email'], \
                       request.form['name'],\
                       request.form['tel']))
        user = User()
        user.name = request.form.get('name', None)
        user.email = request.form.get('email', None)
        user.tel = request.form.get('tel', None)
        user.msg = request.form.get('message', None)

        if not user.is_valid:
            logger.error('No valid form. Request:%s' % request)
            return jsonify(False)

        try:
            user.save()
        except:
            logger.error('Don\'t save in base. Request:%s' % request)
            return jsonify('Error')
        
        logger.info('Register:Done!')
        send_email(user)
        return jsonify(True)

    else:
        return jsonify(False)
开发者ID:shuric80,项目名称:photogallery,代码行数:30,代码来源:views.py

示例13: sign_up

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import email [as 别名]
def sign_up():
    form = SignUpForm()
    user = User()
    if form.validate_on_submit():
        user_name = request.form.get('user_name')
        user_email = request.form.get('user_email')

        register_check = User.login_check(user_name)
        if register_check:
            flash("error: The user's name already exists!")
            return redirect('/sign-up')

        if len(user_name) and len(user_email):
            user.nickname = user_name
            user.email = user_email

            try:
                session = Session()
                session.add(user)
                session.commit()
            except:
                flash("The Database error!")
                return redirect('/sign-up')

            flash("Sign up successful!")
            return redirect('/index')

    return render_template(
        "sign_up.html",
        form=form)
开发者ID:sa615153,项目名称:learn_prototype1,代码行数:32,代码来源:views.py

示例14: truck_page

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import email [as 别名]
def truck_page(truck):
    items = session.query(Item).filter(Item.operator_id == truck)
    if request.method == "POST":
        user = User()
        user.firstName = request.form.get("firstName")
        user.lastName = request.form.get("lastName")
        user.email = request.form.get("email")
        session.add(user)
        session.commit()
        order = Order()
        order.operator_id = truck
        order.user = user
        order.status = "created"
        session.add(order)
        session.commit()
        for item_id in request.form.getlist("item"):
            orderitem = OrderItems()
            orderitem.order_id = order.id
            orderitem.item_id = item_id
            item = items.filter(Item.id == item_id).first()
            session.add(orderitem)
            session.commit()
        return render_template("checkout.html", key=stripe_keys["publishable_key"], order=order, user=user)
    else:
        items = items.all()
        items = filter(lambda x: x.count > 0, items)
        return render_template("truckPage.html", items=items)
开发者ID:hunterowens,项目名称:truckate_flask,代码行数:29,代码来源:app.py

示例15: post

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import email [as 别名]
	def post(self):
		fbid = self.request.get('fbid')
		fbtoken = self.request.get('fbtoken')
		fbexpires = self.request.get('fbexpires')

		email = self.request.get('email')
		picture = self.request.get('picture')
		name = self.request.get('name')
		nick = self.request.get('nick')

		user = User.query(User.email == email).get()

		if user == None:
			user = User()
			user.status = '1'
			user.email = email

		user.name = name
		user.nick = nick
		user.picture = picture

		user.fb = json.dumps({'status': 0, 'id': fbid, 'token': fbtoken, 'expires': fbexpires})

		user.put()

                ret = {'status': 0, 'message': 'User ' + email + ' set.'}

                self.response.out.write(json.dumps(ret))
开发者ID:ThomasMarcel,项目名称:natural_selection,代码行数:30,代码来源:api.py


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