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
ea09604b
Commit
ea09604b
authored
Jun 07, 2017
by
Sli
Browse files
Other line fix
parent
b6a68fa0
Pipeline
#1033
passed with stage
in 4 minutes and 32 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
election/views.py
View file @
ea09604b
...
...
@@ -29,10 +29,9 @@ class LimitedCheckboxField(forms.ModelMultipleChoiceField):
label
=
None
,
initial
=
None
,
help_text
=
''
,
*
args
,
**
kwargs
):
self
.
max_choice
=
max_choice
widget
=
forms
.
CheckboxSelectMultiple
()
super
(
LimitedCheckboxField
,
self
).
__init__
(
queryset
,
None
,
required
,
widget
,
label
,
initial
,
help_text
,
*
args
,
**
kwargs
)
super
(
LimitedCheckboxField
,
self
).
__init__
(
queryset
,
None
,
required
,
widget
,
label
,
initial
,
help_text
,
*
args
,
**
kwargs
)
def
clean
(
self
,
value
):
qs
=
super
(
LimitedCheckboxField
,
self
).
clean
(
value
)
...
...
@@ -56,8 +55,7 @@ class CandidateForm(forms.ModelForm):
'program'
:
forms
.
Textarea
}
user
=
AutoCompleteSelectField
(
'users'
,
label
=
_
(
'User to candidate'
),
help_text
=
None
,
required
=
True
)
user
=
AutoCompleteSelectField
(
'users'
,
label
=
_
(
'User to candidate'
),
help_text
=
None
,
required
=
True
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
election_id
=
kwargs
.
pop
(
'election_id'
,
None
)
...
...
@@ -94,16 +92,14 @@ class RoleForm(forms.ModelForm):
election_id
=
kwargs
.
pop
(
'election_id'
,
None
)
super
(
RoleForm
,
self
).
__init__
(
*
args
,
**
kwargs
)
if
election_id
:
self
.
fields
[
'election'
].
queryset
=
Election
.
objects
.
filter
(
id
=
election_id
).
all
()
self
.
fields
[
'election'
].
queryset
=
Election
.
objects
.
filter
(
id
=
election_id
).
all
()
def
clean
(
self
):
cleaned_data
=
super
(
RoleForm
,
self
).
clean
()
title
=
cleaned_data
.
get
(
'title'
)
election
=
cleaned_data
.
get
(
'election'
)
if
Role
.
objects
.
filter
(
title
=
title
,
election
=
election
).
exists
():
raise
forms
.
ValidationError
(
_
(
"This role already exists for this election"
),
code
=
'invalid'
)
raise
forms
.
ValidationError
(
_
(
"This role already exists for this election"
),
code
=
'invalid'
)
class
ElectionListForm
(
forms
.
ModelForm
):
...
...
@@ -238,8 +234,7 @@ class VoteFormView(CanCreateMixin, FormView):
return
res
def
get_success_url
(
self
,
**
kwargs
):
return
reverse_lazy
(
'election:detail'
,
kwargs
=
{
'election_id'
:
self
.
election
.
id
})
return
reverse_lazy
(
'election:detail'
,
kwargs
=
{
'election_id'
:
self
.
election
.
id
})
def
get_context_data
(
self
,
**
kwargs
):
""" Add additionnal data to the template """
...
...
@@ -433,8 +428,7 @@ class CandidatureUpdateView(CanEditMixin, UpdateView):
self
.
object
=
self
.
get_object
()
if
not
self
.
object
.
role
.
election
.
is_vote_editable
:
raise
PermissionDenied
return
super
(
CandidatureUpdateView
,
self
).
dispatch
(
request
,
*
arg
,
**
kwargs
)
return
super
(
CandidatureUpdateView
,
self
).
dispatch
(
request
,
*
arg
,
**
kwargs
)
def
remove_fields
(
self
):
self
.
form
.
fields
.
pop
(
'role'
,
None
)
...
...
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