Commit ea09604b authored by Sli's avatar Sli

Other line fix

parent b6a68fa0
Pipeline #1033 passed with stage
in 4 minutes and 32 seconds
...@@ -29,10 +29,9 @@ class LimitedCheckboxField(forms.ModelMultipleChoiceField): ...@@ -29,10 +29,9 @@ class LimitedCheckboxField(forms.ModelMultipleChoiceField):
label=None, initial=None, help_text='', *args, **kwargs): label=None, initial=None, help_text='', *args, **kwargs):
self.max_choice = max_choice self.max_choice = max_choice
widget = forms.CheckboxSelectMultiple() widget = forms.CheckboxSelectMultiple()
super(LimitedCheckboxField, self).__init__(queryset, None, required, super(LimitedCheckboxField,
widget, label, self).__init__(queryset, None, required, widget,
initial, help_text, label, initial, help_text, *args, **kwargs)
*args, **kwargs)
def clean(self, value): def clean(self, value):
qs = super(LimitedCheckboxField, self).clean(value) qs = super(LimitedCheckboxField, self).clean(value)
...@@ -56,8 +55,7 @@ class CandidateForm(forms.ModelForm): ...@@ -56,8 +55,7 @@ class CandidateForm(forms.ModelForm):
'program': forms.Textarea 'program': forms.Textarea
} }
user = AutoCompleteSelectField('users', label=_( user = AutoCompleteSelectField('users', label=_('User to candidate'), help_text=None, required=True)
'User to candidate'), help_text=None, required=True)
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
election_id = kwargs.pop('election_id', None) election_id = kwargs.pop('election_id', None)
...@@ -94,16 +92,14 @@ class RoleForm(forms.ModelForm): ...@@ -94,16 +92,14 @@ class RoleForm(forms.ModelForm):
election_id = kwargs.pop('election_id', None) election_id = kwargs.pop('election_id', None)
super(RoleForm, self).__init__(*args, **kwargs) super(RoleForm, self).__init__(*args, **kwargs)
if election_id: if election_id:
self.fields['election'].queryset = Election.objects.filter( self.fields['election'].queryset = Election.objects.filter(id=election_id).all()
id=election_id).all()
def clean(self): def clean(self):
cleaned_data = super(RoleForm, self).clean() cleaned_data = super(RoleForm, self).clean()
title = cleaned_data.get('title') title = cleaned_data.get('title')
election = cleaned_data.get('election') election = cleaned_data.get('election')
if Role.objects.filter(title=title, election=election).exists(): if Role.objects.filter(title=title, election=election).exists():
raise forms.ValidationError( raise forms.ValidationError(_("This role already exists for this election"), code='invalid')
_("This role already exists for this election"), code='invalid')
class ElectionListForm(forms.ModelForm): class ElectionListForm(forms.ModelForm):
...@@ -238,8 +234,7 @@ class VoteFormView(CanCreateMixin, FormView): ...@@ -238,8 +234,7 @@ class VoteFormView(CanCreateMixin, FormView):
return res return res
def get_success_url(self, **kwargs): def get_success_url(self, **kwargs):
return reverse_lazy('election:detail', return reverse_lazy('election:detail', kwargs={'election_id': self.election.id})
kwargs={'election_id': self.election.id})
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
""" Add additionnal data to the template """ """ Add additionnal data to the template """
...@@ -433,8 +428,7 @@ class CandidatureUpdateView(CanEditMixin, UpdateView): ...@@ -433,8 +428,7 @@ class CandidatureUpdateView(CanEditMixin, UpdateView):
self.object = self.get_object() self.object = self.get_object()
if not self.object.role.election.is_vote_editable: if not self.object.role.election.is_vote_editable:
raise PermissionDenied raise PermissionDenied
return super(CandidatureUpdateView, return super(CandidatureUpdateView, self).dispatch(request, *arg, **kwargs)
self).dispatch(request, *arg, **kwargs)
def remove_fields(self): def remove_fields(self):
self.form.fields.pop('role', None) self.form.fields.pop('role', None)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment