Mercurial > public > sg101
comparison gpp/forums/views.py @ 102:e67c4dd98db5
Forums: new topic form sprouts boolean fields for sticky and locking if the user has rights. Implemented the locked logic. Fixed a bug where topics where getting out of order (the view_count was bumping the update_date because of auto_now).
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 16 Sep 2009 02:01:57 +0000 |
parents | 4bbb6a9aa317 |
children | 59688577a8f1 |
comparison
equal
deleted
inserted
replaced
101:4bbb6a9aa317 | 102:e67c4dd98db5 |
---|---|
132 | 132 |
133 if not forum.category.can_access(request.user): | 133 if not forum.category.can_access(request.user): |
134 return HttpResponseForbidden() | 134 return HttpResponseForbidden() |
135 | 135 |
136 if request.method == 'POST': | 136 if request.method == 'POST': |
137 form = NewTopicForm(request.POST) | 137 form = NewTopicForm(request.user, forum, request.POST) |
138 if form.is_valid(): | 138 if form.is_valid(): |
139 topic = form.save(forum, request.user, request.META.get("REMOTE_ADDR")) | 139 topic = form.save(request.META.get("REMOTE_ADDR")) |
140 return HttpResponseRedirect(reverse('forums-new_topic_thanks', | 140 return HttpResponseRedirect(reverse('forums-new_topic_thanks', |
141 kwargs={'tid': topic.pk})) | 141 kwargs={'tid': topic.pk})) |
142 else: | 142 else: |
143 form = NewTopicForm() | 143 form = NewTopicForm(request.user, forum) |
144 | 144 |
145 return render_to_response('forums/new_topic.html', { | 145 return render_to_response('forums/new_topic.html', { |
146 'forum': forum, | 146 'forum': forum, |
147 'form': form, | 147 'form': form, |
148 }, | 148 }, |
173 if not request.user.is_authenticated(): | 173 if not request.user.is_authenticated(): |
174 return HttpResponseForbidden() | 174 return HttpResponseForbidden() |
175 | 175 |
176 form = PostForm(request.POST) | 176 form = PostForm(request.POST) |
177 if form.is_valid(): | 177 if form.is_valid(): |
178 if not form.topic.forum.category.can_access(request.user): | 178 if form.topic.locked or not form.topic.forum.category.can_access(request.user): |
179 return HttpResponseForbidden() | 179 return HttpResponseForbidden() |
180 | 180 |
181 post = form.save(request.user, request.META.get("REMOTE_ADDR")) | 181 post = form.save(request.user, request.META.get("REMOTE_ADDR")) |
182 return render_to_response('forums/display_post.html', { | 182 return render_to_response('forums/display_post.html', { |
183 'post': post, | 183 'post': post, |