Mercurial > public > sg101
comparison gpp/messages/views.py @ 430:9df368d9775d
Fix bug where messages were never getting replied to.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Thu, 05 May 2011 02:58:44 +0000 |
parents | d0f0800eef0c |
children | 0d91176cf9b3 |
comparison
equal
deleted
inserted
replaced
429:d0f0800eef0c | 430:9df368d9775d |
---|---|
196 if not request.user.is_authenticated(): | 196 if not request.user.is_authenticated(): |
197 return HttpResponseForbidden() | 197 return HttpResponseForbidden() |
198 | 198 |
199 if request.method == "POST": | 199 if request.method == "POST": |
200 compose_form = ComposeForm(request.user, request.POST) | 200 compose_form = ComposeForm(request.user, request.POST) |
201 | |
202 # Is this a reply to another message? | |
203 parent_msg_id = request.POST.get('reply_to') | |
204 if parent_msg_id: | |
205 parent_msg = get_object_or_404(Message, id=parent_msg_id) | |
206 if (request.user != parent_msg.receiver and | |
207 request.user != parent_msg.sender): | |
208 return HttpResponseForbidden() | |
209 else: | |
210 parent_msg = None | |
211 | |
201 if compose_form.is_valid(): | 212 if compose_form.is_valid(): |
202 compose_form.save(sender=request.user) | 213 compose_form.save(parent_msg=parent_msg) |
203 messages.success(request, 'Message sent.') | 214 messages.success(request, 'Message sent.') |
204 return HttpResponseRedirect(reverse('messages-index_named', args=['compose'])) | 215 return HttpResponseRedirect(reverse('messages-index_named', args=['compose'])) |
205 else: | 216 else: |
206 if receiver is not None: | 217 if receiver is not None: |
207 form_data = {'receiver': receiver} | 218 form_data = {'receiver': receiver} |