Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nuages
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etch
nuages
Commits
f6f96d18
Commit
f6f96d18
authored
Jan 25, 2014
by
Christophe Siraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement antispam mesures.
parent
403247d2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
2 deletions
+28
-2
meetingpoll/templates/meetingpoll/poll_detail.html
meetingpoll/templates/meetingpoll/poll_detail.html
+2
-1
meetingpoll/views.py
meetingpoll/views.py
+26
-1
No files found.
meetingpoll/templates/meetingpoll/poll_detail.html
View file @
f6f96d18
...
...
@@ -58,7 +58,8 @@
<form
action=
"."
method=
"post"
>
{% csrf_token %}
<td
class=
'names'
title=
" Fill in your name "
>
<div
class=
"blue"
>
{% trans "Your name:" %}
</div>
{{ form.as_p }}
{{ form.as_p }}
<input
type=
"text"
name=
"trap"
style=
"display:none;"
/>
</td>
{% for forms in vforms %}
...
...
meetingpoll/views.py
View file @
f6f96d18
...
...
@@ -104,10 +104,17 @@ def vote(request, poll_id):
has_voted
,
is_updated
=
False
,
False
if
request
.
method
==
'POST'
:
form
=
BulletinForm
(
request
.
POST
,
initial
=
{
'poll'
:
poll
.
id
})
vforms
=
[[
VoteForm
(
request
.
POST
,
prefix
=
choice
,
instance
=
choice
)
]
for
choice
in
Choice
.
objects
.
filter
(
poll
=
poll
.
id
)]
if
form
.
is_valid
():
if
request
.
POST
.
get
(
'trap'
,
False
):
return
render
(
request
,
'meetingpoll/poll_detail.html'
,
{
'object'
:
poll
,
'form'
:
form
,
'vforms'
:
vforms
,
'has_voted'
:
has_voted
})
if
request
.
user
.
is_authenticated
():
voter
=
str
(
request
.
user
)
else
:
...
...
@@ -115,6 +122,22 @@ def vote(request, poll_id):
if
request
.
session
.
get
(
'name'
):
voter
=
request
.
session
.
get
(
'name'
)
for
forms
in
vforms
:
for
vorm
in
forms
:
if
vorm
.
is_valid
():
comment
=
vorm
.
cleaned_data
[
'comment'
]
if
'http'
in
comment
or
'href'
in
comment
:
messages
.
error
(
request
,
_
(
'Sorry no link is allowed in comments.'
))
return
render
(
request
,
'meetingpoll/poll_detail.html'
,
{
'object'
:
poll
,
'form'
:
form
,
'vforms'
:
vforms
,
'has_voted'
:
has_voted
})
if
len
(
Bulletin
.
objects
.
filter
(
poll
=
poll
.
id
))
>
100
:
messages
.
error
(
request
,
_
(
'Sorry this poll reached the maximum of participants'
))
return
render
(
request
,
'meetingpoll/poll_detail.html'
,
{
'object'
:
poll
,
'form'
:
form
,
'vforms'
:
vforms
,
'has_voted'
:
has_voted
})
if
voter
!=
'your name'
:
if
not
Bulletin
.
objects
.
filter
(
poll
=
poll
.
id
,
voter
=
voter
):
bulletin
=
Bulletin
(
poll
=
poll
,
voter
=
voter
)
...
...
@@ -133,7 +156,9 @@ def vote(request, poll_id):
if
not
Vote
.
objects
.
filter
(
choice
=
choice
,
bulletin
=
bulletin
):
new
=
Vote
(
choice
=
choice
,
bulletin
=
bulletin
,
comment
=
vorm
.
cleaned_data
[
'comment'
])
if
vorm
.
cleaned_data
[
'voice'
]:
new
.
voice
=
vorm
.
cleaned_data
[
'voice'
]
new
.
voice
=
True
else
:
new
.
voice
=
False
new
.
save
()
if
new
.
voice
:
choice
.
votecount
+=
1
...
...
Write
Preview
Markdown
is supported
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