コード例 #1
0
ファイル: views.py プロジェクト: WilliamGoossen/ct-blog
def _edit_post(request, obj):

    if request.method == 'POST':
        form = BlogPostForm(request.POST, instance=obj)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(obj.get_absolute_url())
    else:
        form = BlogPostForm(instance=obj)
    return render_to_response('blog/post_add.html',
        RequestContext( request, {'form': form, 'object': obj, 'group': obj.group }))
コード例 #2
0
ファイル: views.py プロジェクト: WilliamGoossen/ct-blog
def _new_post(request, group):

    if request.method == 'POST':
        form = BlogPostForm(request.POST)
        if form.is_valid():
            post = form.save(commit=False)
            post.author = request.user
            post.slug = slugify(post.title)[:50]
            post.publish = datetime.datetime.now()
            post.group = group
            post.save()
            return HttpResponseRedirect(post.get_absolute_url())
    else:
        form = BlogPostForm()
    return render_to_response('blog/post_add.html',
        RequestContext( request, {'form': form, 'group': group  }))
コード例 #3
0
ファイル: views.py プロジェクト: snowcloud/ct-blog
def _edit_post(request, obj):

    if request.method == 'POST':
        form = BlogPostForm(request.POST, instance=obj)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(obj.get_absolute_url())
    else:
        form = BlogPostForm(instance=obj)
    return render_to_response(
        'blog/post_add.html',
        RequestContext(request, {
            'form': form,
            'object': obj,
            'group': obj.group
        }))
コード例 #4
0
ファイル: views.py プロジェクト: snowcloud/ct-blog
def _new_post(request, group):

    if request.method == 'POST':
        form = BlogPostForm(request.POST)
        if form.is_valid():
            post = form.save(commit=False)
            post.author = request.user
            post.slug = slugify(post.title)[:50]
            post.publish = datetime.datetime.now()
            post.group = group
            post.save()
            return HttpResponseRedirect(post.get_absolute_url())
    else:
        form = BlogPostForm()
    return render_to_response(
        'blog/post_add.html',
        RequestContext(request, {
            'form': form,
            'group': group
        }))