本文整理汇总了Python中models.factory.PosGraduationFactory.boards_of_staffs_dao方法的典型用法代码示例。如果您正苦于以下问题:Python PosGraduationFactory.boards_of_staffs_dao方法的具体用法?Python PosGraduationFactory.boards_of_staffs_dao怎么用?Python PosGraduationFactory.boards_of_staffs_dao使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.factory.PosGraduationFactory
的用法示例。
在下文中一共展示了PosGraduationFactory.boards_of_staffs_dao方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_staff
# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import boards_of_staffs_dao [as 别名]
def delete_staff():
"""
Render a delete staff form.
"""
form = StaffForm()
pfactory = PosGraduationFactory(current_user.pg_initials)
dao = pfactory.boards_of_staffs_dao()
json = pfactory.boards_of_staffs_dao().find_one()
json = dict(json)
json = dumps(json)
index = '.' + str(form.index.data)
if form.validate_on_submit():
dao.find_one_and_update(None, {
'$set': {form.function.data + index + '.deleted' : ''}
})
return redirect(
url_for(
'crud_staff.delete_staff',
success_msg='Servidor deletado com sucesso.',
staff=json
)
)
return render_template(
'admin/delete_staff.html',
form=form,
success_msg=request.args.get('success_msg'),
staff=json
)
示例2: edit_staff
# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import boards_of_staffs_dao [as 别名]
def edit_staff():
"""
Render a staff form.
"""
form = StaffForm()
pfactory = PosGraduationFactory(current_user.pg_initials)
dao = pfactory.boards_of_staffs_dao()
json = pfactory.boards_of_staffs_dao().find_one()
json = dict(json)
json = dumps(json)
dao = pfactory.boards_of_staffs_dao()
if form.validate_on_submit():
index = '.' + str(form.index.data)
if form.photo.data == '':
photo = None
else:
photo = form.photo.data
if form.function.data == 'coordination':
new_staff = {
'name': form.name.data,
'rank': form.rank.data,
'abstract': form.abstract.data,
'photo': photo
}
else:
new_staff = {
'name': form.name.data,
'function': {
'rank': form.rank.data,
'description': form.abstract.data
},
'photo': photo
}
dao.find_one_and_update(None, {
'$set': {form.function.data + index: new_staff}
})
return redirect(
url_for(
'crud_staff.edit_staff',
success_msg='Servidor editado com sucesso.',
staff=json
)
)
return render_template(
'admin/edit_staff.html',
form=form,
success_msg=request.args.get('success_msg'),
staff=json
)
示例3: view_staffs
# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import boards_of_staffs_dao [as 别名]
def view_staffs(initials):
"""Render a view for staff list."""
pfactory = PosGraduationFactory(initials)
post_graduation = pfactory.post_graduation
board_of_staffs = pfactory.boards_of_staffs_dao().find_one()
# renders an own page or redirect to another (external/404)?
return render_template(
'public/staffs.html',
std=get_std_for_template(post_graduation),
board_of_staffs=board_of_staffs
)