本文整理汇总了Python中models.factory.PosGraduationFactory.news_dao方法的典型用法代码示例。如果您正苦于以下问题:Python PosGraduationFactory.news_dao方法的具体用法?Python PosGraduationFactory.news_dao怎么用?Python PosGraduationFactory.news_dao使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.factory.PosGraduationFactory
的用法示例。
在下文中一共展示了PosGraduationFactory.news_dao方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_news
# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import news_dao [as 别名]
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')
)
示例2: view_news_list
# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import news_dao [as 别名]
def view_news_list(initials):
"""Render a view for a list of news viewing."""
pfactory = PosGraduationFactory(initials)
post_graduation = pfactory.post_graduation
news = pfactory.news_dao().find_one()['news']
# renders an own page or redirect to another (external/404)?
return render_template(
'public/news_list.html',
std=get_std_for_template(post_graduation),
news=news
)
示例3: view_news
# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import news_dao [as 别名]
def view_news(initials):
"""Render a view for news viewing."""
pfactory = PosGraduationFactory(initials)
post_graduation = pfactory.post_graduation
id = request.args.get('id')
news = pfactory.news_dao().find_one()['news']
fullNews = next(piece for piece in news if piece['id'] == id)
# renders an own page or redirect to another (external/404)?
return render_template(
'public/news.html',
std=get_std_for_template(post_graduation),
fullNews=fullNews
)
示例4: add_news
# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import news_dao [as 别名]
def add_news():
"""
Render a news adding form
"""
form = NewsForm()
pfactory = PosGraduationFactory(current_user.pg_initials)
dao = pfactory.news_dao()
if form.validate_on_submit() and form.create.data:
id = ''.join([random.choice(string.ascii_letters + string.digits) for n in range(32)])
new_news = {
'title': form.title.data,
'headLine': form.headLine.data,
'body': form.body.data,
'id' : id,
'date': time.strftime("%d/%m/%Y")
}
dao.find_one_and_update(None, {
'$push': {'news': new_news}
})
return redirect(
url_for(
'crud_news.add_news',
success_msg='Nova notícia adicionada com sucesso.'
)
)
return render_template(
'admin/add_news.html',
form=form,
success_msg=request.args.get('success_msg')
)
示例5: home
# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import news_dao [as 别名]
def home(initials):
"""
Render a post-graduation program page.
Try to find which program has been requested.
If it's here: signed in Minerva, show its main page,
otherwise the user is redirected to that programs external web site.
If couldn't find which program has been requested, show a 404 page error.
"""
pfactory = PosGraduationFactory(initials)
post_graduation = pfactory.post_graduation
# renders an own page or redirect to another (external/404)?
if post_graduation is None:
return page_not_found()
if not post_graduation['isSignedIn']:
return redirect(post_graduation['oldURL'])
# query google maps api
google_maps_api_dict = keyring.get(keyring.GOOGLE_MAPS)
google_maps_api_key = 'none'
if google_maps_api_dict is not None:
google_maps_api_key = google_maps_api_dict['key']
# search for home data
final_reports = pfactory.final_reports_dao().find_one()
calendar = pfactory.calendar_dao().find_one()['events']
selections = []
events = []
for event in range(len(calendar)):
if "deleted" not in calendar[event]:
if "Seleção" in calendar[event]['title']:
selections.append(calendar[event])
else:
events.append(calendar[event])
final_reports = final_reports['scheduledReports']
news = pfactory.news_dao().find_one()['news']
classes = pfactory.classes_database_dao().find_one()['firstClasses']
integrations_infos = pfactory.integrations_infos_dao().find_one()
if integrations_infos is None:
integrations_infos = {
'name': "",
'initials': "",
'logoFile': "",
}
institutions_with_covenant = integrations_infos
else:
institutions_with_covenant = integrations_infos['institutionsWithCovenant']
attendance = pfactory.attendances_dao().find_one()
if attendance is None:
attendance = {
'location' : {
'building' : '',
'floor' : '',
'room' : '',
'opening' : ''
},
'email' : '',
'phones' : {
'type' : '',
'number' : ''
}
}
# ready... fire!
return render_template(
'public/home.html',
std=get_std_for_template(post_graduation),
google_maps_api_key=google_maps_api_key,
final_reports=final_reports,
events=events,
selections=selections,
classes=classes,
news=news,
institutions_with_covenant=institutions_with_covenant,
attendance=attendance,
)