def delete_post(request, key=None): post = None if key is not None: post = Post.get(key) if key and request.method == 'POST': post.delete() return HttpResponseRedirect('/admin/posts/')
def feed(request): sotd = SoupOfTheDay.today() posts = Post.recent(5) events = Event.upcoming(5) feedobj = AtomFeed() entries = [AtomEntry(p) for p in posts] + [AtomEntry(e) for e in events] return HttpResponse(loader.render_to_string('feed.atom', dict( feed=feedobj, entries=entries)), mimetype="application/atom+xml")
def edit_post(request, key=None): post = None if key is not None: post = Post.get(key) if request.method == 'POST': form = PostForm(request.POST) if form.is_valid(): post = Post.from_form(form) post.put() return HttpResponseRedirect('/admin/posts/') elif post: form = PostForm({'title': post.title, 'content': post.content, 'publish': (post.published is not None), # Hidden 'key': post.key(), 'slug': post.slug, 'published': post.published, 'updated': post.updated}) else: form = PostForm() return render_admin_template('admin/posts/edit.html', dict( post=post, post_form=form))
def post(request, slug=None): post = None if slug is not None: post = Post.gql("WHERE slug = :1", slug).get() return render_to_response('post.html', dict( post=post))
def archives(request): posts = Post.all() return render_to_response('archives.html', dict( posts=posts))