added button to dupplicate a post
This commit is contained in:
@@ -31,6 +31,35 @@ def blog(request):
|
||||
}
|
||||
|
||||
|
||||
@view_config(route_name='blog_copy',
|
||||
renderer='cao_blogr:templates/blog_copy.jinja2', permission='view')
|
||||
def blog_copy(request):
|
||||
# get post parameters from request
|
||||
topic = request.matchdict['topic']
|
||||
blog_id = request.matchdict['id']
|
||||
|
||||
# get the post
|
||||
entry = BlogRecordService.by_id(request, blog_id)
|
||||
if not entry:
|
||||
request.session.flash("Page non trouvée : %s" % blog_id, 'warning')
|
||||
return HTTPFound(location=request.route_url('topic', topic=topic))
|
||||
|
||||
# create a new post
|
||||
dup_entry = BlogRecord()
|
||||
dup_entry.title = entry.title + ' - copie'
|
||||
dup_entry.body = entry.body
|
||||
dup_entry.topic_id = entry.topic_id
|
||||
dup_entry.tag = entry.tag
|
||||
dup_entry.author = entry.author
|
||||
dup_entry.status = entry.status
|
||||
request.dbsession.add(dup_entry)
|
||||
|
||||
request.session.flash("La page a été duppliquée avec succès", 'success')
|
||||
return HTTPFound(location=request.route_url('topic', topic=topic))
|
||||
|
||||
|
||||
|
||||
|
||||
@view_config(route_name='blog_edit',
|
||||
renderer='cao_blogr:templates/blog_edit.jinja2', permission='view')
|
||||
def blog_edit(request):
|
||||
@@ -54,8 +83,8 @@ def blog_edit(request):
|
||||
# modify post
|
||||
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'))
|
||||
request.session.flash("Page non trouvée : %s" % blog_id, 'warning')
|
||||
return HTTPFound(location=request.route_url('topic', topic=topic))
|
||||
form = BlogUpdateForm(request.POST, entry)
|
||||
form.tag.choices = [(row.tag, row.tag_name) for row in tags]
|
||||
page_title = 'Modifier : ' + entry.title
|
||||
|
||||
Reference in New Issue
Block a user