本文整理汇总了Python中models.factory.PosGraduationFactory.publications_dao方法的典型用法代码示例。如果您正苦于以下问题:Python PosGraduationFactory.publications_dao方法的具体用法?Python PosGraduationFactory.publications_dao怎么用?Python PosGraduationFactory.publications_dao使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.factory.PosGraduationFactory
的用法示例。
在下文中一共展示了PosGraduationFactory.publications_dao方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_chapter
# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import publications_dao [as 别名]
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')
)
示例2: delete_book
# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import publications_dao [as 别名]
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')
)
示例3: edit_chapter
# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import publications_dao [as 别名]
def edit_chapter():
"""
Render a chapter editing 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)
new_chapter = {
'bookTitle': form.book_title.data,
'bookAuthors': form.book_authors.data,
'chapterTitle': form.chapter_title.data,
'chapterAuthors': form.chapter_authors.data,
'edition': form.edition.data,
'location': form.location.data,
'publisher': form.publisher.data,
'pages': form.pages.data,
'year': form.year.data
}
dao.find_one_and_update(None, {
'$set': {'chapters.' + index : new_chapter}
})
return redirect(
url_for(
'crud_books.edit_chapter',
success_msg='Capítulo editado com sucesso.'))
return render_template(
'admin/edit_chapters.html',
publications=publications,
form=form,
success_msg=request.args.get('success_msg')
)
示例4: edit_article
# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import publications_dao [as 别名]
def edit_article():
"""
Render a article editing form
"""
form = ArticleForm()
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)
new_article = {
'title': form.title.data,
'subtitle': form.subtitle.data,
'authors': form.authors.data,
'edition': form.edition.data,
'location': form.location.data,
'publisher': form.publisher.data,
'number': form.number.data,
'pages': form.pages.data,
'date': form.date.data
}
dao.find_one_and_update(None, {
'$set': {'articles.' + index : new_article}
})
return redirect(
url_for(
'crud_articles.edit_article',
success_msg='Livro editado com sucesso.'))
return render_template(
'admin/edit_articles.html',
publications=json,
form=form,
success_msg=request.args.get('success_msg')
)
示例5: view_chapters
# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import publications_dao [as 别名]
def view_chapters(initials):
"""Render a view for chapters list."""
pfactory = PosGraduationFactory(initials)
post_graduation = pfactory.post_graduation
publications = pfactory.publications_dao().find_one()
# renders an own page or redirect to another (external/404)?
return render_template(
'public/chapters.html',
std=get_std_for_template(post_graduation),
publications=publications
)
示例6: add_chapter
# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import publications_dao [as 别名]
def add_chapter():
"""
Render a chapter in book adding form
"""
pfactory = PosGraduationFactory(current_user.pg_initials)
form = ChapterForm()
dao = pfactory.publications_dao()
if form.validate_on_submit() and form.create.data:
new_chapter = {
'bookTitle': form.book_title.data,
'bookAuthors': form.book_authors.data,
'chapterTitle': form.chapter_title.data,
'chapterAuthors': form.chapter_authors.data,
'edition': form.edition.data,
'location': form.location.data,
'publisher': form.publisher.data,
'pages': form.pages.data,
'year': form.year.data
}
dao.find_one_and_update(None, {
'$push': {'chapters': new_chapter}
})
return redirect(
url_for(
'crud_books.add_chapter',
success_msg='Novo capitulo adicionado com sucesso.'
)
)
return render_template(
'admin/add_chapter.html',
form=form,
success_msg=request.args.get('success_msg')
)
示例7: add_article
# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import publications_dao [as 别名]
def add_article():
"""
Render a article adding form
"""
form = ArticleForm()
pfactory = PosGraduationFactory(current_user.pg_initials)
dao = pfactory.publications_dao()
if form.validate_on_submit() and form.create.data:
new_article = {
'title': form.title.data,
'subtitle': form.subtitle.data,
'authors': form.authors.data,
'edition': form.edition.data,
'location': form.location.data,
'publisher': form.publisher.data,
'number': form.number.data,
'pages': form.pages.data,
'date': form.date.data
}
dao.find_one_and_update(None, {
'$push': {'articles': new_article}
})
return redirect(
url_for(
'crud_articles.add_article',
success_msg='Novo artigo adicionado com sucesso.'
)
)
return render_template(
'admin/add_article.html',
form=form,
success_msg=request.args.get('success_msg')
)
示例8: add_book
# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import publications_dao [as 别名]
def add_book():
"""
Render a book adding form
"""
form = BookForm()
pfactory = PosGraduationFactory(current_user.pg_initials)
dao = pfactory.publications_dao()
if form.validate_on_submit() and form.create.data:
new_book = {
'title': form.title.data,
'subtitle': form.subtitle.data,
'authors': form.authors.data,
'edition': form.edition.data,
'location': form.location.data,
'publisher': form.publisher.data,
'year': form.year.data
}
dao.find_one_and_update(None, {
'$push': {'books': new_book}
})
return redirect(
url_for(
'crud_books.add_book',
success_msg='Novo livro adicionado com sucesso.'
)
)
return render_template(
'admin/add_book.html',
form=form,
success_msg=request.args.get('success_msg')
)