Exemple #1
0
def post_change_status(request, action, id):
    post = get_object_or_404(Post, pk = id)
    if not post.can_edit(request.user):
        messages.error(request, "You can't change statuses of posts that aren't yours")
    else:
        if action == 'draft' and post.status == Post.IS_PUBLIC:
            post.status = Post.IS_DRAFT
        if action == 'public' and post.status == Post.IS_DRAFT:
            post.status = Post.IS_PUBLIC
            post_published.send(sender=Post, post=post)
        post.save()
        messages.success(request, _("Successfully change status for post '%s'") % post.title)
    return redirect("blog_my_post_list")
Exemple #2
0
def post_change_status(request, action, id):
    post = get_object_or_404(Post, pk=id)
    if not post.can_edit(request.user):
        messages.error(request,
                       "You can't change statuses of posts that aren't yours")
    else:
        if action == 'draft' and post.status == Post.IS_PUBLIC:
            post.status = Post.IS_DRAFT
        if action == 'public' and post.status == Post.IS_DRAFT:
            post.status = Post.IS_PUBLIC
            post_published.send(sender=Post, post=post)
        post.save()
        messages.success(
            request,
            _("Successfully change status for post '%s'") % post.title)
    return redirect("blog_my_post_list")