mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-22 15:51:19 +00:00
trombi: prevent double comment using "Precedent" browser button
Signed-off-by: Skia <skia@libskia.so>
This commit is contained in:
parent
e4e4eae11b
commit
8bf72daa31
@ -22,7 +22,7 @@
|
||||
#
|
||||
#
|
||||
|
||||
from django.http import Http404
|
||||
from django.http import Http404, HttpResponseRedirect
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
from django.core.urlresolvers import reverse_lazy, reverse
|
||||
from django.views.generic import DetailView, RedirectView, TemplateView
|
||||
@ -379,8 +379,15 @@ class TrombiCommentFormView():
|
||||
class TrombiCommentCreateView(TrombiCommentFormView, CreateView):
|
||||
def form_valid(self, form):
|
||||
target = get_object_or_404(TrombiUser, id=self.kwargs['user_id'])
|
||||
form.instance.author = self.request.user.trombi_user
|
||||
author = self.request.user.trombi_user
|
||||
form.instance.author = author
|
||||
form.instance.target = target
|
||||
# Check that this combination does not already have a comment
|
||||
old = TrombiComment.objects.filter(author=author, target=target).first()
|
||||
if old:
|
||||
old.content = form.instance.content
|
||||
old.save()
|
||||
return HttpResponseRedirect(self.get_success_url())
|
||||
return super(TrombiCommentCreateView, self).form_valid(form)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user