Added draft capabilities.
This commit is contained in:
parent
50e5bbc094
commit
69b7142acc
@ -68,6 +68,9 @@ class PostController(BaseController):
|
||||
post.modified = datetime.now()
|
||||
post.title = c.form_values[u'title']
|
||||
post.body = c.form_values[u'body']
|
||||
if c.form_values[u'action'] == u'Save Draft':
|
||||
post.status = u'draft'
|
||||
else:
|
||||
post.status = u'published'
|
||||
post.url = url
|
||||
tags = c.form_values[u'tags']
|
||||
@ -82,5 +85,26 @@ class PostController(BaseController):
|
||||
post.tags.append(Tag(name=tag, url=utils.generate_url(tag)))
|
||||
Session.add(post)
|
||||
Session.commit()
|
||||
if c.form_values[u'action'] == u'Save Draft':
|
||||
h.redirect_to(h.url_for(action=u'draft'))
|
||||
else:
|
||||
h.redirect_to(str('/archive/%s/%s' % (post.created.strftime('%Y/%m/%d'), post.url)))
|
||||
|
||||
def draft(self):
|
||||
posts = Session.query(Post)\
|
||||
.filter_by(status=u'draft')\
|
||||
.order_by(Post.created.desc())
|
||||
pagination = utils.paginate(posts, 10,
|
||||
int(request.GET.get(u'page', 1)), '/')
|
||||
c.posts = pagination[u'records']
|
||||
if pagination[u'prev'] != pagination[u'page']:
|
||||
c.first_page = pagination[u'first']
|
||||
c.prev_page = pagination[u'prev']
|
||||
if pagination[u'next'] != pagination[u'page']:
|
||||
c.next_page = pagination[u'next']
|
||||
c.last_page = pagination[u'last']
|
||||
c.list_start = pagination[u'start']
|
||||
c.list_total = pagination[u'total']
|
||||
c.list_end = pagination[u'end']
|
||||
return render(u'/post/draft.mako')
|
||||
|
||||
|
@ -33,6 +33,7 @@
|
||||
% if c.current_user:
|
||||
% if c.current_user.has_permission('Add Posts'):
|
||||
<li><a href="${h.url_for(controller='post', action='new')}">New Post</a></li>
|
||||
<li><a href="${h.url_for(controller='post', action='draft')}">Draft Posts</a></li>
|
||||
% endif
|
||||
<li><a href="${h.url_for(controller='admin', action='logout')}">Logout</a></li>
|
||||
<li>Logged in as <em>${c.current_user.nick}</em></li>
|
||||
|
15
scribeengine/templates/post/draft.mako
Normal file
15
scribeengine/templates/post/draft.mako
Normal file
@ -0,0 +1,15 @@
|
||||
<%inherit file="/base.mako"/>
|
||||
<%include file="/flash.mako"/>
|
||||
<h2 class="title">Unpublished blog posts</h2>
|
||||
% for post in c.posts:
|
||||
<div class="post">
|
||||
<h3 class="title"><a href="${h.url_for(controller=u'post', action=u'edit', id=post.id)}">${post.title}</a></h3>
|
||||
<div class="entry">
|
||||
${h.literal(h.teaser(post.body))}
|
||||
</div>
|
||||
<p class="meta">
|
||||
<span class="byline">Posted by ${post.user.nick} on ${post.created.strftime('%B %d, %Y')}</span>
|
||||
<a href="${h.url_for(controller=u'post', action=u'edit', id=post.id)}" class="read-more">Edit post</a>
|
||||
</p>
|
||||
</div>
|
||||
% endfor
|
@ -18,8 +18,12 @@
|
||||
<input type="text" name="tags" id="post-tags" class="form-text" value="${c.post.tags_list}" />
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<input type="submit" name="action" value="Save Draft"/>
|
||||
<input type="submit" name="action" value="Save & Publish"/>
|
||||
% if c.post.status == u'published':
|
||||
<input type="submit" name="action" value="Save" class="form-button"/>
|
||||
% else:
|
||||
<input type="submit" name="action" value="Save Draft" class="form-button"/>
|
||||
<input type="submit" name="action" value="Save & Publish" class="form-button"/>
|
||||
% endif
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
Reference in New Issue
Block a user