added topic listing

This commit is contained in:
2022-05-01 09:51:03 +02:00
parent 3b7b3b4483
commit 0a307fc953
27 changed files with 386 additions and 175 deletions

View File

@@ -11,14 +11,14 @@ def blog(request):
# get post id from request
blog_id = request.matchdict['id']
entry = BlogRecordService.by_id(request, blog_id)
if not entry:
request.session.flash(u"Page non trouvée : %s" % blog_id, 'warning')
return HTTPFound(location=request.route_url('home'))
# just created ? convert body to html
if entry.body_html == '':
BlogRecordService.proc_after_create(request, blog_id)
if not entry:
request.session.flash(u"Page non trouvée : %s" % blog_id, 'warning')
return HTTPFound(location=request.route_url('home'))
return {
'page_title': entry.title,
'entry': entry
@@ -40,6 +40,7 @@ def blog_edit(request):
entry.tag = 'pyramid'
entry.topic = 'blog'
form = BlogCreateForm(request.POST, entry)
form.tag.choices = [(row.tag, row.title) for row in BlogRecordService.tags]
else:
# modify post
entry = BlogRecordService.by_id(request, blog_id)
@@ -67,6 +68,7 @@ def blog_edit(request):
'page_title': entry.title,
'url': url,
'form': form,
'entry': entry,
}
@@ -89,3 +91,17 @@ def blog_search(request):
'criteria': criteria,
}
@view_config(route_name='topic',
renderer='cao_blogr:templates/topic.jinja2')
def topic(request):
topic = request.matchdict['topic']
# lire toutes les docs du topic
items = BlogRecordService.by_topic(request, topic)
return {
'page_title': topic.upper(),
'topic': topic,
'items': items,
}