Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
AE UTBM
Sith
Commits
8bf72daa
Commit
8bf72daa
authored
Jul 30, 2017
by
Skia
🤘
Browse files
trombi: prevent double comment using "Precedent" browser button
Signed-off-by:
Skia
<
skia@libskia.so
>
parent
e4e4eae1
Pipeline
#1110
passed with stage
in 3 minutes and 59 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
trombi/views.py
View file @
8bf72daa
...
...
@@ -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
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment