本文整理汇总了Python中models.factory.PosGraduationFactory.projects_database_dao方法的典型用法代码示例。如果您正苦于以下问题:Python PosGraduationFactory.projects_database_dao方法的具体用法?Python PosGraduationFactory.projects_database_dao怎么用?Python PosGraduationFactory.projects_database_dao使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.factory.PosGraduationFactory
的用法示例。
在下文中一共展示了PosGraduationFactory.projects_database_dao方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: edit_project
# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import projects_database_dao [as 别名]
def edit_project():
"""Render project editing form."""
form = ProjectForm()
pfactory = PosGraduationFactory(current_user.pg_initials)
dao = pfactory.projects_database_dao()
projects = pfactory.projects_database_dao().find()
projects = list(projects)
projects = dumps(projects)
if form.validate_on_submit() and form.create.data:
new_project = {
'title': form.title.data,
'subtitle': form.subtitle.data,
'description': form.description.data,
'situation': form.situation.data,
'year': form.year.data,
'email': form.email.data,
'dt_init': form.dt_init.data,
'dt_end': form.dt_end.data
}
dao.find_one_and_update({'_id' : ObjectId(form.project_id.data)}, {
'$set' : new_project})
return redirect(
url_for(
'crud_projects.edit_project',
success_msg='Projeto editado com sucesso.'
)
)
return render_template(
'admin/edit_projects.html',
form=form,
projects=projects,
success_msg=request.args.get('success_msg')
)
示例2: delete_project
# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import projects_database_dao [as 别名]
def delete_project():
"""Render project deleting form."""
form = ProjectForm()
pfactory = PosGraduationFactory(current_user.pg_initials)
dao = pfactory.projects_database_dao()
projects = pfactory.projects_database_dao().find()
projects = list(projects)
projects = dumps(projects)
if form.validate_on_submit() and form.create.data:
dao.find_one_and_update({'_id' : ObjectId(form.project_id.data)}, {
'$set' : {'deleted' : '' }})
return redirect(
url_for(
'crud_projects.delete_project',
success_msg='Projeto deletado com sucesso.'
)
)
return render_template(
'admin/delete_project.html',
form=form,
projects=projects,
success_msg=request.args.get('success_msg')
)
示例3: view_member
# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import projects_database_dao [as 别名]
def view_member():
form = MemberOfProjectForm()
pfactory = PosGraduationFactory(current_user.pg_initials)
projects = pfactory.projects_database_dao().find()
projects = list(projects)
projects = dumps(projects)
if request.args.get('crud_type') == 'Adicionar':
return render_template(
'admin/add_member_in_project.html',
form=form,
projects=projects,
crud_type=request.args.get('crud_type'),
success_msg=request.args.get('success_msg')
)
if request.args.get('crud_type') == 'Deletar':
return render_template(
'admin/delete_member_in_project.html',
form=form,
projects=projects,
crud_type=request.args.get('crud_type'),
success_msg=request.args.get('success_msg')
)
else:
return render_template(
'admin/edit_member_in_project.html',
form=form,
projects=projects,
crud_type=request.args.get('crud_type'),
success_msg=request.args.get('success_msg')
)
示例4: delete_member
# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import projects_database_dao [as 别名]
def delete_member():
form = MemberOfProjectForm()
pfactory = PosGraduationFactory(current_user.pg_initials)
dao = pfactory.projects_database_dao()
projects = pfactory.projects_database_dao().find()
projects = list(projects)
projects = dumps(projects)
if form.validate_on_submit():
index = str(form.index.data)
dao.find_one_and_update({'_id' : ObjectId(form.project_id.data)}, {
'$set': {'members.' + index + '.deleted' : '' }})
projects = pfactory.projects_database_dao().find()
projects = list(projects)
projects = dumps(projects)
return jsonify(projects=projects)
else:
return jsonify({'error':'Houve um erro'})
示例5: add_member
# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import projects_database_dao [as 别名]
def add_member():
form = MemberOfProjectForm()
pfactory = PosGraduationFactory(current_user.pg_initials)
dao = pfactory.projects_database_dao()
projects = pfactory.projects_database_dao().find()
projects = list(projects)
projects = dumps(projects)
if form.validate_on_submit():
new_member = {
'name' : form.name.data,
'general_role' : form.general_role.data,
'project_role' : form.project_role.data
}
dao.find_one_and_update({'_id' : ObjectId(form.project_id.data)}, {
'$push': {'members': new_member}})
projects = pfactory.projects_database_dao().find()
projects = list(projects)
projects = dumps(projects)
return jsonify(projects=projects)
else:
return jsonify({'error':'Houve um erro'})
示例6: view_projects
# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import projects_database_dao [as 别名]
def view_projects(initials):
"""Render a view for projects list."""
pfactory = PosGraduationFactory(initials)
post_graduation = pfactory.post_graduation
projects = pfactory.projects_database_dao().find()
projects = list(projects)
for project in projects:
coordinators_names = []
for member in project['members']:
if 'Coordenador(a)' in member['project_role']:
coordinators_names.append(member)
project['members'].remove(member)
project['coordinators_names'] = coordinators_names
# renders an own page or redirect to another (external/404)?
return render_template(
'public/projects.html',
std=get_std_for_template(post_graduation),
projects=projects
)
示例7: add_project
# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import projects_database_dao [as 别名]
def add_project():
"""Render project adding form."""
form = ProjectForm()
pfactory = PosGraduationFactory(current_user.pg_initials)
dao = pfactory.projects_database_dao()
ownerProgram = pfactory.mongo_id
if form.validate_on_submit() and form.create.data:
new_project = {
'ownerProgram': ownerProgram,
'title': form.title.data,
'subtitle': form.subtitle.data,
'description': form.description.data,
'situation': form.situation.data,
'year': form.year.data,
'email': form.email.data,
'dt_init': form.dt_init.data,
'dt_end': form.dt_end.data,
'members' : []
}
dao.insert_one(None, new_project)
return redirect(
url_for(
'crud_projects.add_project',
success_msg='Projeto adicionado adicionado com sucesso.'
)
)
return render_template(
'admin/add_project.html',
form=form,
success_msg=request.args.get('success_msg')
)