本文整理匯總了Python中app.users.models.User.is_supervisor方法的典型用法代碼示例。如果您正苦於以下問題:Python User.is_supervisor方法的具體用法?Python User.is_supervisor怎麽用?Python User.is_supervisor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app.users.models.User
的用法示例。
在下文中一共展示了User.is_supervisor方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: add_users
# 需要導入模塊: from app.users.models import User [as 別名]
# 或者: from app.users.models.User import is_supervisor [as 別名]
def add_users():
form = AddUserForms(request.form)
all_users = User.query.all()
form.select_role.choices = [(role.id, role.name) ## Loads up choices
for role in Role.query.all()]
## load roles that had supervisor roles in it:
form.select_supervisor.choices = [(user.username, user.username)
for user in User.query.all() if user.is_supervisor]
print form.select_role.choices
if form.validate_on_submit():
password = generate_password_hash('seer')
u = User (form.fname.data,form.midname.data,form.lname.data, ## Load user
form.email.data,form.username.data,password)
print form.select_role.data
for i in form.select_role.data: ## Loads up the selected choices of the user
print i
u.role.append(Role.query.get(i))
print u.role
##Checks if the user is a supervisor
if form.check_if_supervisor.data:
u.is_supervisor = True
## Loads up the supervisor of the user, and loads up the user to its supervisor
u.supervisor = form.select_supervisor.data
print form.select_supervisor.data
supervisor = User.query.filter_by(username=form.select_supervisor.data).first()
if supervisor.supervisee is None or '':
supervisor.supervisee = u.username
print supervisor.supervisee
else:
supervisor.supervisee = supervisor.supervisee + ' ' + u.username
print supervisor.supervisee
db_session.add(u)
db_session.add(supervisor)
db_session.commit()
us = UserStatistics(userId=u.id)
us.sl = form.number_of_sick_leaves.data
us.vl = form.number_of_vacation_leaves.data
us.offset = 0
db_session.add(us)
db_session.commit()
flash('User Created')
return redirect(url_for('Users.add_users'))
return render_template('admin/add_user.html', form = form)