Beispiel #1
0
def delete(request, key):
    if not admin():
        return HttpResponseRedirect(users.create_login_url("/blogs"))
    blog = Blog.get(key)
    Comment.batch_delete(blog.comment_set)
    archive = Archive.all().filter("year", blog.year).filter("month", blog.month).fetch(1)
    archive[0].weblog_count -= 1
    archive[0].put()
    if archive[0].weblog_count == 0:
        archive[0].delete()
    blog.delete()
    if blog.category and blog.category.blog_set.count() == 0:
        blog.category.delete()
    return HttpResponseRedirect("/blogs")