示例#1
0
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/')
示例#2
0
文件: views.py 项目: hober/stoutsd
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")
示例#3
0
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))
示例#4
0
文件: views.py 项目: hober/stoutsd
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))
示例#5
0
文件: views.py 项目: hober/stoutsd
def archives(request):
    posts = Post.all()
    return render_to_response('archives.html', dict(
            posts=posts))