Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added thread closed

  • Loading branch information...
commit 46dea03f33e07317f43883cfe832a018a07f209a 1 parent d46a516
@brosner brosner authored
Showing with 7 additions and 3 deletions.
  1. +1 −1  agora/models.py
  2. +6 −2 agora/views.py
View
2  agora/models.py
@@ -279,7 +279,7 @@ class ForumThread(ForumPost):
)
sticky = models.IntegerField(default=0)
- # @@@ closed threads
+ closed = models.DateTimeField(null=True)
view_count = models.IntegerField(default=0, editable=False)
reply_count = models.IntegerField(default=0, editable=False)
View
8 agora/views.py
@@ -3,6 +3,7 @@
from django.template import RequestContext
from django.shortcuts import get_object_or_404, render_to_response
+from django.contrib import messages
from django.contrib.auth.decorators import login_required
from agora.forms import ThreadForm, ReplyForm
@@ -74,7 +75,7 @@ def forum(request, forum_id):
def forum_thread(request, thread_id):
thread = get_object_or_404(ForumThread, id=thread_id)
- if request.user.is_authenticated():
+ if request.user.is_authenticated() and not thread.closed:
if request.method == "POST":
reply_form = ReplyForm(request.POST)
@@ -93,7 +94,7 @@ def forum_thread(request, thread_id):
return HttpResponseRedirect(reverse("agora_thread", args=[thread.id]))
else:
- reply_form = ReplyForm(request.POST)
+ reply_form = ReplyForm()
else:
reply_form = None
@@ -153,6 +154,9 @@ def reply_create(request, thread_id):
member = request.user.get_profile()
thread = get_object_or_404(ForumThread, id=thread_id)
+ if thread.closed:
+ messages.error(request, "This thread is closed.")
+
if request.method == "POST":
form = ReplyForm(request.POST)
Please sign in to comment.
Something went wrong with that request. Please try again.