本文整理汇总了Python中models.factory.PosGraduationFactory类的典型用法代码示例。如果您正苦于以下问题:Python PosGraduationFactory类的具体用法?Python PosGraduationFactory怎么用?Python PosGraduationFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PosGraduationFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: edit_project
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
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: get
def get(nick, authenticated=False):
"""Return an User from database. If failed, None."""
try:
condition = {'users.nick': nick}
pfactory = PosGraduationFactory()
dao = pfactory.post_graduations_dao()
program = list(dao.find(condition))
if program:
initials = program[0]['initials']
else:
return None
for user in program[0]['users']:
if nick.lower() == user['nick'].lower():
found_user = User()
found_user._nick = user['nick']
found_user._pg_initials = initials.lower()
found_user._full_name = user['fullName']
found_user._role = user['role']
found_user._email = user['email']
found_user._token = user['token']
found_user.__is_authenticated = authenticated
found_user.__is_active = True
found_user.__is_anonymous = False
return found_user
return None
except (TypeError, AttributeError):
return None
示例4: view_member
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')
)
示例5: delete_chapter
def delete_chapter():
"""
Render a chapter delete form
"""
form = ChapterForm()
pfactory = PosGraduationFactory(current_user.pg_initials)
dao = pfactory.publications_dao()
publications = pfactory.publications_dao().find_one()
publications = dict(publications)
publications = dumps(publications)
if form.validate_on_submit() and form.create.data:
index = str(form.index.data)
dao.find_one_and_update(None, {
'$set': {'chapters.' + index + '.deleted' : ''}
})
return redirect(
url_for(
'crud_books.delete_chapter',
success_msg='Capítulo deletado com sucesso.'))
return render_template(
'admin/delete_chapters.html',
publications=publications,
form=form,
success_msg=request.args.get('success_msg')
)
示例6: delete_book
def delete_book():
"""
Render a book deleting form
"""
form = BookForm()
pfactory = PosGraduationFactory(current_user.pg_initials)
dao = pfactory.publications_dao()
json = pfactory.publications_dao().find_one()
json = dict(json)
json = dumps(json)
if form.validate_on_submit() and form.create.data:
index = str(form.index.data)
dao.find_one_and_update(None, {
'$set': {'books.' + index + '.deleted' : ''}
})
return redirect(
url_for(
'crud_books.delete_book',
success_msg='Livro deletado com sucesso.'))
return render_template(
'admin/delete_books.html',
publications=json,
form=form,
success_msg=request.args.get('success_msg')
)
示例7: delete_staff
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
)
示例8: delete_subjects
def delete_subjects():
"""
Render a delete subject form.
"""
course_type = request.args.get('course_type')
form = SubjectsForm(course_type=course_type)
pfactory = PosGraduationFactory(current_user.pg_initials)
dao = pfactory.grades_of_subjects_dao()
json = pfactory.grades_of_subjects_dao().find({'courseType' : course_type})
json = list(json)
json = dumps(json)
if form.validate_on_submit():
index = str(form.index.data)
condition = {'title': form.requirement.data, 'courseType' : form.course_type.data}
dao.find_one_and_update(condition, {
'$set': {'subjects.' + index + '.deleted' : ""}
})
return redirect(
url_for(
'crud_subjects.delete_subjects',
success_msg='Disciplina deletada com sucesso',
course_type=form.course_type.data
)
)
return render_template(
'admin/delete_subjects.html',
form=form,
subjects=json,
success_msg=request.args.get('success_msg'),
)
示例9: delete_events
def delete_events():
"""Render a view for deleting events."""
form = CalendarForm()
pfactory = PosGraduationFactory(current_user.pg_initials)
dao = pfactory.calendar_dao()
json = pfactory.calendar_dao().find_one()
json = dict(json)
json = dumps(json)
if form.validate_on_submit() and form.create.data:
index = str(form.index.data)
dao.find_one_and_update(None, {
'$set': {'events.' + index + '.deleted' : ""}
})
return redirect(
url_for(
'crud_events.delete_events',
events=json,
success_msg='Evento deletado com sucesso.'
)
)
return render_template(
'admin/delete_events.html',
events=json,
form=form,
success_msg=request.args.get('success_msg')
)
示例10: delete_news
def delete_news():
form = NewsForm()
pfactory = PosGraduationFactory(current_user.pg_initials)
dao = pfactory.news_dao()
news = pfactory.news_dao().find_one()
news = dict(news)
news = dumps(news)
if form.validate_on_submit() and form.create.data:
index = str(form.index.data)
dao.find_one_and_update(None, {
'$set': {'news.' + index + '.deleted' : ''}
})
return redirect(
url_for(
'crud_news.delete_news',
success_msg='Notícia deletada com sucesso.'))
return render_template(
'admin/delete_news.html',
news=news,
form=form,
success_msg=request.args.get('success_msg')
)
示例11: delete_scheduled_reports
def delete_scheduled_reports():
form = ScheduledReportForm()
pfactory = PosGraduationFactory(current_user.pg_initials)
dao = pfactory.final_reports_dao()
json = pfactory.final_reports_dao().find_one()
json = dict(json)
json = dumps(json)
if form.validate_on_submit() and form.create.data:
index = str(form.index.data)
dao.find_one_and_update(None, {
'$set': {'scheduledReports.' + index + '.deleted' : ""}
})
return redirect(
url_for(
'crud_scheduled_reports.delete_scheduled_reports',
final_reports=json,
success_msg='Agendamento deletado com sucesso'
)
)
return render_template(
'admin/delete_scheduled_reports.html',
final_reports=json,
form=form,
post_graduation=current_user.pg_initials,
success_msg=request.args.get('success_msg')
)
示例12: scheduled_reports
def scheduled_reports():
"""
Render a report scheduling form.
"""
form = ScheduledReportForm()
pfactory = PosGraduationFactory(current_user.pg_initials)
dao = pfactory.final_reports_dao()
if form.validate_on_submit():
new_report = {
'time': datetime.combine(form.date.data, form.time.data.time()),
'title': form.title.data,
'author': form.author.data,
'location': form.location.data
}
dao.find_one_and_update(None, {
'$push': {'scheduledReports': new_report}
})
return redirect(
url_for(
'crud_scheduled_reports.scheduled_reports',
success_msg='Defesa de tese adicionada com sucesso.'
)
)
return render_template(
'admin/scheduled_reports.html',
form=form,
success_msg=request.args.get('success_msg')
)
示例13: view_classes
def view_classes(initials):
"""Render a view for classes list."""
form = FindClass()
pfactory = PosGraduationFactory(initials)
post_graduation = pfactory.post_graduation
now = datetime.datetime.now()
if now.month <= 7:
semester = 1
else:
semester = 2
classes=pfactory.classes_dao(now.year,semester,100).find()
if form.validate_on_submit():
return redirect(
url_for(
'public.find_classes',
initials=initials,
year=form.year.data,
period=form.period.data
)
)
# renders an own page or redirect to another (external/404)?
return render_template(
'public/subjectsinclasses.html',
std=get_std_for_template(post_graduation),
form=form,
classes=classes
)
示例14: edit_staff
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
)
示例15: find_classes
def find_classes():
form = FindClass()
pfactory = PosGraduationFactory(request.args['initials'])
post_graduation = pfactory.post_graduation
classes_2 =pfactory.classes_dao(request.args['year'], request.args['period'], 100).find()
return render_template(
'public/subjectsinclasses.html',
std=get_std_for_template(post_graduation),
form=form,
classes=classes_2
)