Added "edit post" links.

This commit is contained in:
Raoul Snyman 2010-02-01 23:57:47 +02:00
parent 4b03d57c43
commit 50e5bbc094
3 changed files with 20 additions and 6 deletions

View File

@ -50,6 +50,10 @@ class PostController(BaseController):
if id is None: if id is None:
h.redirect_to('/post/new') h.redirect_to('/post/new')
c.post = Session.query(Post).get(id) c.post = Session.query(Post).get(id)
if len(c.post.tags):
c.post.tags_list = u', '.join([tag.name for tag in c.post.tags])
else:
c.post.tags_list = u''
c.page_title = 'Edit Post: %s' % c.post.title c.page_title = 'Edit Post: %s' % c.post.title
return render(u'/post/edit.mako') return render(u'/post/edit.mako')

View File

@ -8,14 +8,19 @@
${h.literal(h.teaser(post.body))} ${h.literal(h.teaser(post.body))}
</div> </div>
<p class="meta"> <p class="meta">
<span class="byline">Posted by ${post.user.nick} on ${post.created.strftime('%B %d, %Y')}</span> <span class="byline">
<a href="${h.url_for_post(post)}" class="read-more">Read more</a> Posted by ${post.user.nick} on ${post.created.strftime('%B %d, %Y')}
% if c.current_user and c.current_user.id == post.user.id and c.current_user.has_permission(u'Edit My Posts'):
[<a href="${h.url_for(controller=u'post', action=u'edit', id=post.id)}">Edit</a>]
% endif
</span>
<a href="${h.url_for_post(post)}" class="read-more">Read more</a>
% if len(post.comments) == 0: % if len(post.comments) == 0:
<a href="${h.url_for_post(post)}#comments" class="comments">No comments</a> <a href="${h.url_for_post(post)}#comments" class="comments">No comments</a>
% elif len(post.comments) == 1: % elif len(post.comments) == 1:
<a href="${h.url_for_post(post)}#comments" class="comments">1 comment</a> <a href="${h.url_for_post(post)}#comments" class="comments">1 comment</a>
% else: % else:
<a href="${h.url_for_post(post)}#comments" class="comments">${len(post.comments)} comments</a> <a href="${h.url_for_post(post)}#comments" class="comments">${len(post.comments)} comments</a>
% endif % endif
</p> </p>
</div> </div>

View File

@ -2,7 +2,12 @@
<%include file="/flash.mako"/> <%include file="/flash.mako"/>
<div class="post"> <div class="post">
<h2 class="title">${c.post.title}</h2> <h2 class="title">${c.post.title}</h2>
<div class="info">Posted by ${c.post.user.nick} on ${c.post.created.strftime('%B %d, %Y')}</div> <div class="info">
Posted by ${c.post.user.nick} on ${c.post.created.strftime('%B %d, %Y')}
% if c.current_user and c.current_user.id == c.post.user.id and c.current_user.has_permission(u'Edit My Posts'):
[<a href="${h.url_for(controller=u'post', action=u'edit', id=c.post.id)}">Edit</a>]
% endif
</div>
<div class="entry"> <div class="entry">
${h.literal(c.post.body)} ${h.literal(c.post.body)}
</div> </div>