added topic listing
This commit is contained in:
@@ -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,
|
||||
}
|
||||
|
||||
@@ -23,10 +23,11 @@ def home(request):
|
||||
dir + '/S21.jpg',
|
||||
dir + '/S25.jpg']
|
||||
page = int(request.params.get('page', 1))
|
||||
paginator = BlogRecordService.get_paginator(request, page)
|
||||
# get the 5 last modified posts
|
||||
last_five = BlogRecordService.get_last_five(request)
|
||||
return {
|
||||
'page_title': "",
|
||||
'paginator': paginator,
|
||||
'last_five': last_five,
|
||||
'car_images': car_images,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user