forked from DGNum/gestioCOF
PEP8: fixed ' = ' → '=' on parameters
'unexpected spaces around keyword / parameter equals'
This commit is contained in:
parent
7de11f2285
commit
c7a3656ded
18 changed files with 496 additions and 379 deletions
|
@ -10,6 +10,7 @@ from gestioncof.models import CofProfile, EventCommentValue
|
|||
from gestioncof.widgets import TriStateCheckbox
|
||||
from gestioncof.shared import lock_table, unlock_table
|
||||
|
||||
|
||||
class EventForm(forms.Form):
|
||||
def __init__(self, *args, **kwargs):
|
||||
event = kwargs.pop("event")
|
||||
|
@ -28,18 +29,18 @@ class EventForm(forms.Form):
|
|||
choices = [(choice.id, choice.value) for choice in option.choices.all()]
|
||||
if option.multi_choices:
|
||||
initial = [] if option.id not in all_choices else all_choices[option.id]
|
||||
field = forms.MultipleChoiceField(label = option.name,
|
||||
choices = choices,
|
||||
widget = CheckboxSelectMultiple,
|
||||
required = False,
|
||||
initial = initial)
|
||||
field = forms.MultipleChoiceField(label=option.name,
|
||||
choices=choices,
|
||||
widget=CheckboxSelectMultiple,
|
||||
required=False,
|
||||
initial=initial)
|
||||
else:
|
||||
initial = None if option.id not in all_choices else all_choices[option.id][0]
|
||||
field = forms.ChoiceField(label = option.name,
|
||||
choices = choices,
|
||||
widget = RadioSelect,
|
||||
required = False,
|
||||
initial = initial)
|
||||
field = forms.ChoiceField(label=option.name,
|
||||
choices=choices,
|
||||
widget=RadioSelect,
|
||||
required=False,
|
||||
initial=initial)
|
||||
field.option_id = option.id
|
||||
self.fields["option_%d" % option.id] = field
|
||||
|
||||
|
@ -48,6 +49,7 @@ class EventForm(forms.Form):
|
|||
if name.startswith('option_'):
|
||||
yield (self.fields[name].option_id, value)
|
||||
|
||||
|
||||
class SurveyForm(forms.Form):
|
||||
def __init__(self, *args, **kwargs):
|
||||
survey = kwargs.pop("survey")
|
||||
|
@ -64,18 +66,18 @@ class SurveyForm(forms.Form):
|
|||
choices = [(answer.id, answer.answer) for answer in question.answers.all()]
|
||||
if question.multi_answers:
|
||||
initial = [] if question.id not in answers else answers[question.id]
|
||||
field = forms.MultipleChoiceField(label = question.question,
|
||||
choices = choices,
|
||||
widget = CheckboxSelectMultiple,
|
||||
required = False,
|
||||
initial = initial)
|
||||
field = forms.MultipleChoiceField(label=question.question,
|
||||
choices=choices,
|
||||
widget=CheckboxSelectMultiple,
|
||||
required=False,
|
||||
initial=initial)
|
||||
else:
|
||||
initial = None if question.id not in answers else answers[question.id][0]
|
||||
field = forms.ChoiceField(label = question.question,
|
||||
choices = choices,
|
||||
widget = RadioSelect,
|
||||
required = False,
|
||||
initial = initial)
|
||||
field = forms.ChoiceField(label=question.question,
|
||||
choices=choices,
|
||||
widget=RadioSelect,
|
||||
required=False,
|
||||
initial=initial)
|
||||
field.question_id = question.id
|
||||
self.fields["question_%d" % question.id] = field
|
||||
|
||||
|
@ -83,7 +85,8 @@ class SurveyForm(forms.Form):
|
|||
for name, value in self.cleaned_data.items():
|
||||
if name.startswith('question_'):
|
||||
yield (self.fields[name].question_id, value)
|
||||
|
||||
|
||||
|
||||
class SurveyStatusFilterForm(forms.Form):
|
||||
def __init__(self, *args, **kwargs):
|
||||
survey = kwargs.pop("survey")
|
||||
|
@ -95,11 +98,11 @@ class SurveyStatusFilterForm(forms.Form):
|
|||
initial = self.data.get(self.add_prefix(name), None)
|
||||
else:
|
||||
initial = "none"
|
||||
field = forms.ChoiceField(label = "%s : %s" % (question.question, answer.answer),
|
||||
choices = [("yes", "yes"),("no","no"),("none","none")],
|
||||
widget = TriStateCheckbox,
|
||||
required = False,
|
||||
initial = initial)
|
||||
field = forms.ChoiceField(label="%s : %s" % (question.question, answer.answer),
|
||||
choices=[("yes", "yes"), ("no", "no"), ("none", "none")],
|
||||
widget=TriStateCheckbox,
|
||||
required=False,
|
||||
initial=initial)
|
||||
field.question_id = question.id
|
||||
field.answer_id = answer.id
|
||||
self.fields[name] = field
|
||||
|
@ -109,6 +112,7 @@ class SurveyStatusFilterForm(forms.Form):
|
|||
if name.startswith('question_'):
|
||||
yield (self.fields[name].question_id, self.fields[name].answer_id, value)
|
||||
|
||||
|
||||
class EventStatusFilterForm(forms.Form):
|
||||
def __init__(self, *args, **kwargs):
|
||||
event = kwargs.pop("event")
|
||||
|
@ -120,11 +124,11 @@ class EventStatusFilterForm(forms.Form):
|
|||
initial = self.data.get(self.add_prefix(name), None)
|
||||
else:
|
||||
initial = "none"
|
||||
field = forms.ChoiceField(label = "%s : %s" % (option.name, choice.value),
|
||||
choices = [("yes", "yes"),("no","no"),("none","none")],
|
||||
widget = TriStateCheckbox,
|
||||
required = False,
|
||||
initial = initial)
|
||||
field = forms.ChoiceField(label="%s : %s" % (option.name, choice.value),
|
||||
choices=[("yes", "yes"), ("no", "no"), ("none", "none")],
|
||||
widget=TriStateCheckbox,
|
||||
required=False,
|
||||
initial=initial)
|
||||
field.option_id = option.id
|
||||
field.choice_id = choice.id
|
||||
self.fields[name] = field
|
||||
|
@ -134,11 +138,11 @@ class EventStatusFilterForm(forms.Form):
|
|||
initial = self.data.get(self.add_prefix(name), None)
|
||||
else:
|
||||
initial = "none"
|
||||
field = forms.ChoiceField(label = "Événement payé",
|
||||
choices = [("yes", "yes"),("no","no"),("none","none")],
|
||||
widget = TriStateCheckbox,
|
||||
required = False,
|
||||
initial = initial)
|
||||
field = forms.ChoiceField(label="Événement payé",
|
||||
choices=[("yes", "yes"), ("no", "no"), ("none", "none")],
|
||||
widget=TriStateCheckbox,
|
||||
required=False,
|
||||
initial=initial)
|
||||
self.fields[name] = field
|
||||
|
||||
def filters(self):
|
||||
|
@ -148,6 +152,7 @@ class EventStatusFilterForm(forms.Form):
|
|||
elif name == "event_has_paid":
|
||||
yield ("has_paid", None, value)
|
||||
|
||||
|
||||
class UserProfileForm(forms.ModelForm):
|
||||
first_name = forms.CharField(label=_(u'Prénom'), max_length=30)
|
||||
last_name = forms.CharField(label=_(u'Nom'), max_length=30)
|
||||
|
@ -174,7 +179,8 @@ class UserProfileForm(forms.ModelForm):
|
|||
|
||||
class Meta:
|
||||
model = CofProfile
|
||||
fields = ("phone", "mailing_cof", "mailing_bda", "mailing_bda_revente",)
|
||||
fields = ("phone", "mailing_cof", "mailing_bda", "mailing_bda_revente", )
|
||||
|
||||
|
||||
class RegistrationUserForm(forms.ModelForm):
|
||||
def __init__(self, *args, **kw):
|
||||
|
@ -185,6 +191,7 @@ class RegistrationUserForm(forms.ModelForm):
|
|||
model = User
|
||||
fields = ("username", "first_name", "last_name", "email")
|
||||
|
||||
|
||||
class RegistrationProfileForm(forms.ModelForm):
|
||||
def __init__(self, *args, **kw):
|
||||
super(RegistrationProfileForm, self).__init__(*args, **kw)
|
||||
|
@ -226,12 +233,13 @@ class RegistrationProfileForm(forms.ModelForm):
|
|||
model = CofProfile
|
||||
fields = ("login_clipper", "num", "phone", "occupation", "departement", "is_cof", "type_cotiz", "mailing_cof", "mailing_bda", "mailing_bda_revente", "comments")
|
||||
|
||||
STATUS_CHOICES = (('no','Non'),
|
||||
('wait','Oui mais attente paiement'),
|
||||
('paid','Oui payé'),)
|
||||
STATUS_CHOICES = (('no', 'Non'),
|
||||
('wait', 'Oui mais attente paiement'),
|
||||
('paid', 'Oui payé'),)
|
||||
|
||||
|
||||
class AdminEventForm(forms.Form):
|
||||
status = forms.ChoiceField(label = "Inscription", choices = STATUS_CHOICES, widget = RadioSelect)
|
||||
status = forms.ChoiceField(label="Inscription", choices=STATUS_CHOICES, widget=RadioSelect)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
event = kwargs.pop("event")
|
||||
|
@ -239,12 +247,12 @@ class AdminEventForm(forms.Form):
|
|||
registration = kwargs.pop("current_registration", None)
|
||||
current_choices = registration.options.all() if registration is not None else []
|
||||
paid = kwargs.pop("paid", None)
|
||||
if paid == True:
|
||||
kwargs["initial"] = {"status":"paid"}
|
||||
elif paid == False:
|
||||
kwargs["initial"] = {"status":"wait"}
|
||||
if paid is True:
|
||||
kwargs["initial"] = {"status": "paid"}
|
||||
elif paid is False:
|
||||
kwargs["initial"] = {"status": "wait"}
|
||||
else:
|
||||
kwargs["initial"] = {"status":"no"}
|
||||
kwargs["initial"] = {"status": "no"}
|
||||
super(AdminEventForm, self).__init__(*args, **kwargs)
|
||||
choices = {}
|
||||
for choice in current_choices:
|
||||
|
@ -257,32 +265,32 @@ class AdminEventForm(forms.Form):
|
|||
choices = [(choice.id, choice.value) for choice in option.choices.all()]
|
||||
if option.multi_choices:
|
||||
initial = [] if option.id not in all_choices else all_choices[option.id]
|
||||
field = forms.MultipleChoiceField(label = option.name,
|
||||
choices = choices,
|
||||
widget = CheckboxSelectMultiple,
|
||||
required = False,
|
||||
initial = initial)
|
||||
field = forms.MultipleChoiceField(label=option.name,
|
||||
choices=choices,
|
||||
widget=CheckboxSelectMultiple,
|
||||
required=False,
|
||||
initial=initial)
|
||||
else:
|
||||
initial = None if option.id not in all_choices else all_choices[option.id][0]
|
||||
field = forms.ChoiceField(label = option.name,
|
||||
choices = choices,
|
||||
widget = RadioSelect,
|
||||
required = False,
|
||||
initial = initial)
|
||||
field = forms.ChoiceField(label=option.name,
|
||||
choices=choices,
|
||||
widget=RadioSelect,
|
||||
required=False,
|
||||
initial=initial)
|
||||
field.option_id = option.id
|
||||
self.fields["option_%d" % option.id] = field
|
||||
for commentfield in event.commentfields.all():
|
||||
initial = commentfield.default
|
||||
if registration is not None:
|
||||
try:
|
||||
initial = registration.comments.get(commentfield = commentfield).content
|
||||
initial = registration.comments.get(commentfield=commentfield).content
|
||||
except EventCommentValue.DoesNotExist:
|
||||
pass
|
||||
widget = forms.Textarea if commentfield.fieldtype == "text" else forms.TextInput
|
||||
field = forms.CharField(label = commentfield.name,
|
||||
widget = widget,
|
||||
required = False,
|
||||
initial = initial)
|
||||
field = forms.CharField(label=commentfield.name,
|
||||
widget=widget,
|
||||
required=False,
|
||||
initial=initial)
|
||||
field.comment_id = commentfield.id
|
||||
self.fields["comment_%d" % commentfield.id] = field
|
||||
|
||||
|
@ -295,4 +303,3 @@ class AdminEventForm(forms.Form):
|
|||
for name, value in self.cleaned_data.items():
|
||||
if name.startswith('comment_'):
|
||||
yield (self.fields[name].comment_id, value)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue