本文整理汇总了Python中db.User.accepttos方法的典型用法代码示例。如果您正苦于以下问题:Python User.accepttos方法的具体用法?Python User.accepttos怎么用?Python User.accepttos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db.User
的用法示例。
在下文中一共展示了User.accepttos方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register
# 需要导入模块: from db import User [as 别名]
# 或者: from db.User import accepttos [as 别名]
def register():
if 'username' in session:
flash("Cannot create new account while logged in.")
return redirect(url_for('hello'))
else:
form = RegistrationForm()
if form.validate_on_submit():
login = form.username.data
user = dbsession.query(User).filter_by(name=login).first()
if user is None:
pw_hash = bcrypt.generate_password_hash(form.password.data)
user = User(login, '', pw_hash)
user.gender = form.gender.data
user.species = form.species.data
user.bio = form.bio.data
user.email = form.email.data
user.minorflag = not form.adult.data
user.accepttos = True
dbsession.add(user)
dbsession.commit()
flash("User Created")
return redirect(url_for('login'))
else:
flash("User already exists.")
return redirect(url_for('register'))
return render_template('register.html', form=form)
示例2: range
# 需要导入模块: from db import User [as 别名]
# 或者: from db.User import accepttos [as 别名]
if __name__ == '__main__':
password = '$2a$12$/xOeN.4B6wQsen5TgvOAMOUVvETJ8vDC8WqhjHRF2OYGSslxMmB2O'
from db import User, Story, addDefault, refresh_db, session as dbsession
import random
import loremipsum
for adduser in range(1,1000):
username = "User%s" % (adduser)
user = User(username,'',password)
user.species = 'Automatic'
user.bio = 'Automatic bio'
user.email = '[email protected]'
user.minorflag = True
user.accepttos =True
dbsession.add(user)
dbsession.commit()
for addstories in range(1,20000):
newstory = Story(loremipsum.generate_sentence()[2])
newstory.text = loremipsum.generate_paragraph()[2]
newstory.adult = True
newstory.uid = random.randrange(1000)+1
dbsession.add(newstory)
dbsession.commit()