Ejemplo n.º 1
0
def post_dir(request, thread_id):
    thread_info = Thread.objects.get(pk=thread_id)
    post_list = Post.objects.filter(thread=thread_id)
    if request.method == "POST":
        form = PostForm(request.POST)
        if form.is_valid():
            thread = Post(thread=thread_info)
            form = PostForm(request.POST, instance=thread)
            form.save()
            return HttpResponseRedirect(reverse("forum.views.post_dir", args=(thread_id,)))
    else:
        form = PostForm()
    return render_to_response(
        "forum/post.html",
        {"post_list": post_list, "thread_info": thread_info, "form": form},
        context_instance=RequestContext(request),
    )
Ejemplo n.º 2
0
def post_dir(request, thread_id):
    thread_info = Thread.objects.get(pk=thread_id)
    post_list = Post.objects.filter(thread=thread_id)
    if request.method == "POST":
        form = PostForm(request.POST)
        post = form.save(commit=False)
        post.utilisateur = request.user
        post.thread = thread_info
        post.save()
        return HttpResponseRedirect(reverse("forum.views.post_dir", args=(thread_id,)))
    else:
        form = PostForm()
    return render_to_response(
        "forum/post.html",
        {"post_list": post_list, "thread_info": thread_info, "form": form},
        context_instance=RequestContext(request),
    )