本文整理汇总了Python中models.user.User.does_user_exist方法的典型用法代码示例。如果您正苦于以下问题:Python User.does_user_exist方法的具体用法?Python User.does_user_exist怎么用?Python User.does_user_exist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.user.User
的用法示例。
在下文中一共展示了User.does_user_exist方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: validate_email
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import does_user_exist [as 别名]
def validate_email(form, field):
if User.does_user_exist(field.data):
field.was_duplicate = True
msg = Markup(
render_template_string('Account already exists. '
'Please <a href="{{ url }}">click here</a> to log in.',
url=url_for('users.login', email=field.data)))
raise ValidationError(msg)
示例2: validate_email
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import does_user_exist [as 别名]
def validate_email(form, field):
if current_user.is_anonymous and User.does_user_exist(field.data):
field.was_duplicate = True
cfp_url = url_for('cfp.main')
msg = Markup(render_template_string('''You already have an account.
Please <a href="{{ url }}" target="_new">click here</a> to log in.''',
url=url_for('users.login', next=cfp_url, email=field.data)))
raise ValidationError(msg)
示例3: validate_email
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import does_user_exist [as 别名]
def validate_email(form, field):
if User.does_user_exist(field.data):
field.was_duplicate = True
raise ValidationError('Account already exists')
示例4: test_does_user_exist
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import does_user_exist [as 别名]
def test_does_user_exist(user):
assert User.does_user_exist(user.email)
assert User.does_user_exist(user.email.upper())
assert not User.does_user_exist('[email protected]')
示例5: transfer
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import does_user_exist [as 别名]
def transfer(ticket_id):
try:
ticket = current_user.owned_purchases.filter_by(id=ticket_id).one()
except NoResultFound:
abort(404)
if not ticket.is_paid_for:
flash("Unpaid tickets cannot be transferred")
return redirect(url_for('users.purchases'))
if not ticket.product.get_attribute('is_transferable'):
flash("This purchase cannot be transferred")
return redirect(url_for('users.purchases'))
form = TicketTransferForm()
if form.validate_on_submit():
email = form.email.data
if not User.does_user_exist(email):
new_user = True
# Create a new user to transfer the ticket to
to_user = User(email, form.name.data)
db.session.add(to_user)
db.session.commit()
else:
new_user = False
to_user = User.get_by_email(email)
ticket = Ticket.query.with_for_update().get(ticket_id)
assert ticket.owner_id == current_user.id
ticket.transfer(from_user=current_user, to_user=to_user)
db.session.commit()
app.logger.info('Ticket %s transferred from %s to %s', ticket,
current_user, to_user)
# Alert the users via email
code = to_user.login_code(app.config['SECRET_KEY'])
msg = Message("You've been sent a ticket to EMF!",
sender=app.config.get('TICKETS_EMAIL'),
recipients=[to_user.email])
already_emailed = set_tickets_emailed(to_user)
msg.body = render_template('emails/ticket-transfer-new-owner.txt',
to_user=to_user, from_user=current_user,
new_user=new_user, code=code,
already_emailed=already_emailed)
if feature_enabled('ISSUE_TICKETS'):
attach_tickets(msg, to_user)
mail.send(msg)
db.session.commit()
msg = Message("You sent someone an EMF ticket",
sender=app.config.get('TICKETS_EMAIL'),
recipients=[current_user.email])
msg.body = render_template('emails/ticket-transfer-original-owner.txt',
to_user=to_user, from_user=current_user)
mail.send(msg)
flash("Your ticket was transferred.")
return redirect(url_for('users.purchases'))
return render_template('ticket-transfer.html', ticket=ticket, form=form)