added showing blogs by tag

This commit is contained in:
2023-02-09 21:53:51 +01:00
parent fcd83c48d7
commit f1287c3fad
9 changed files with 85 additions and 20 deletions

View File

@@ -92,12 +92,32 @@ def blog_edit(request):
'blog_id': blog_id,
'entry': entry, }
@view_config(route_name='blog_bytag', renderer='cao_blogr:templates/blog_bytag.jinja2')
def blog_bytag(request):
# get tag parameters from request
tag = request.matchdict['tag']
retour = request.matchdict['retour']
url_retour = request.route_url(retour)
@view_config(route_name='blog_search',
renderer='cao_blogr:templates/blog_search.jinja2')
# get the posts by tag
items = BlogRecordService.by_tag(request, tag)
nb_items = len(items)
return {
'page_title': "Billets avec tag : " + tag,
'items': items,
'nb_items': nb_items,
'url_retour': url_retour,
}
@view_config(route_name='blog_search', renderer='cao_blogr:templates/blog_search.jinja2')
def blog_search(request):
criteria = ''
# get the list of tags
tags = BlogRecordService.get_tags(request)
form = BlogSearchForm(request.POST)
items = []
if 'form.submitted' in request.params and form.validate():
@@ -110,12 +130,13 @@ def blog_search(request):
'form': form,
'items': items,
'criteria': criteria,
'tags': tags,
}
@view_config(route_name='tags', renderer='cao_blogr:templates/tags.jinja2', permission='view')
def tags(request):
# get the list of tags of this topic
# get the list of tags
tags = BlogRecordService.get_tags(request)
return {