2016-05-27 17:52:02 +02:00
|
|
|
from django import forms
|
2019-03-25 23:22:06 +01:00
|
|
|
from django.contrib.auth import get_user_model
|
2019-03-25 23:05:47 +01:00
|
|
|
from django.contrib.auth.forms import AuthenticationForm
|
2016-08-17 15:34:01 +02:00
|
|
|
from django.forms.formsets import BaseFormSet, formset_factory
|
2018-10-06 12:35:49 +02:00
|
|
|
from django.forms.widgets import CheckboxSelectMultiple, RadioSelect
|
|
|
|
from django.utils.translation import ugettext_lazy as _
|
2017-05-26 00:58:59 +02:00
|
|
|
from djconfig.forms import ConfigForm
|
2016-05-27 17:52:02 +02:00
|
|
|
|
2016-07-15 01:06:33 +02:00
|
|
|
from bda.models import Spectacle
|
2018-10-06 12:35:49 +02:00
|
|
|
from gestioncof.models import CalendarSubscription, Club, CofProfile, EventCommentValue
|
|
|
|
from gestioncof.widgets import TriStateCheckbox
|
2016-07-15 01:06:33 +02:00
|
|
|
|
2019-03-25 23:22:06 +01:00
|
|
|
User = get_user_model()
|
|
|
|
|
2016-07-09 21:19:37 +02:00
|
|
|
|
2019-03-25 23:05:47 +01:00
|
|
|
class ExteAuthenticationForm(AuthenticationForm):
|
|
|
|
"""
|
|
|
|
Formulaire pour l'authentification des extés : renvoie une erreur si la personne
|
|
|
|
qui essaie de s'authentifier n'a pas de mot de passe. L'erreur dépend de si la
|
|
|
|
personne a un login clipper ou non.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def clean(self):
|
|
|
|
username = self.cleaned_data.get("username")
|
|
|
|
|
|
|
|
if username is not None:
|
|
|
|
try:
|
|
|
|
user = User.objects.get(username=username)
|
|
|
|
if not user.has_usable_password() or user.password in ("", "!"):
|
|
|
|
profile, created = CofProfile.objects.get_or_create(user=user)
|
|
|
|
if profile.login_clipper:
|
|
|
|
raise forms.ValidationError(
|
|
|
|
_("L'utilisateur·ice a un login clipper !"),
|
|
|
|
code="has_clipper",
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
raise forms.ValidationError(
|
|
|
|
_("L'utilisateur·ice n'a pas de mot de passe"),
|
|
|
|
code="no_password",
|
|
|
|
)
|
|
|
|
except User.DoesNotExist:
|
|
|
|
pass
|
|
|
|
|
|
|
|
return super().clean()
|
|
|
|
|
|
|
|
|
2016-05-27 17:52:02 +02:00
|
|
|
class EventForm(forms.Form):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
event = kwargs.pop("event")
|
|
|
|
self.event = event
|
|
|
|
current_choices = kwargs.pop("current_choices", None)
|
2018-01-16 16:22:52 +01:00
|
|
|
super().__init__(*args, **kwargs)
|
2016-05-27 17:52:02 +02:00
|
|
|
choices = {}
|
|
|
|
if current_choices:
|
|
|
|
for choice in current_choices.all():
|
|
|
|
if choice.event_option.id not in choices:
|
|
|
|
choices[choice.event_option.id] = [choice.id]
|
|
|
|
else:
|
|
|
|
choices[choice.event_option.id].append(choice.id)
|
|
|
|
all_choices = choices
|
|
|
|
for option in event.options.all():
|
2018-10-06 12:35:49 +02:00
|
|
|
choices = [(choice.id, choice.value) for choice in option.choices.all()]
|
2016-05-27 17:52:02 +02:00
|
|
|
if option.multi_choices:
|
2018-10-06 12:35:49 +02:00
|
|
|
initial = [] if option.id not in all_choices else all_choices[option.id]
|
2016-07-09 22:31:56 +02:00
|
|
|
field = forms.MultipleChoiceField(
|
|
|
|
label=option.name,
|
|
|
|
choices=choices,
|
|
|
|
widget=CheckboxSelectMultiple,
|
|
|
|
required=False,
|
2018-10-06 12:35:49 +02:00
|
|
|
initial=initial,
|
|
|
|
)
|
2016-05-27 17:52:02 +02:00
|
|
|
else:
|
2018-10-06 12:35:49 +02:00
|
|
|
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,
|
|
|
|
)
|
2016-05-27 17:52:02 +02:00
|
|
|
field.option_id = option.id
|
|
|
|
self.fields["option_%d" % option.id] = field
|
|
|
|
|
|
|
|
def choices(self):
|
|
|
|
for name, value in self.cleaned_data.items():
|
2018-10-06 12:35:49 +02:00
|
|
|
if name.startswith("option_"):
|
2016-05-27 17:52:02 +02:00
|
|
|
yield (self.fields[name].option_id, value)
|
|
|
|
|
2016-07-09 21:19:37 +02:00
|
|
|
|
2016-05-27 17:52:02 +02:00
|
|
|
class SurveyForm(forms.Form):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
survey = kwargs.pop("survey")
|
|
|
|
current_answers = kwargs.pop("current_answers", None)
|
2018-01-16 16:22:52 +01:00
|
|
|
super().__init__(*args, **kwargs)
|
2016-05-27 17:52:02 +02:00
|
|
|
answers = {}
|
|
|
|
if current_answers:
|
|
|
|
for answer in current_answers.all():
|
|
|
|
if answer.survey_question.id not in answers:
|
|
|
|
answers[answer.survey_question.id] = [answer.id]
|
|
|
|
else:
|
|
|
|
answers[answer.survey_question.id].append(answer.id)
|
|
|
|
for question in survey.questions.all():
|
2018-10-06 12:35:49 +02:00
|
|
|
choices = [(answer.id, answer.answer) for answer in question.answers.all()]
|
2016-05-27 17:52:02 +02:00
|
|
|
if question.multi_answers:
|
2018-10-06 12:35:49 +02:00
|
|
|
initial = [] if question.id not in answers else answers[question.id]
|
2016-07-09 22:31:56 +02:00
|
|
|
field = forms.MultipleChoiceField(
|
|
|
|
label=question.question,
|
|
|
|
choices=choices,
|
|
|
|
widget=CheckboxSelectMultiple,
|
|
|
|
required=False,
|
2018-10-06 12:35:49 +02:00
|
|
|
initial=initial,
|
|
|
|
)
|
2016-05-27 17:52:02 +02:00
|
|
|
else:
|
2018-10-06 12:35:49 +02:00
|
|
|
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,
|
|
|
|
)
|
2016-05-27 17:52:02 +02:00
|
|
|
field.question_id = question.id
|
|
|
|
self.fields["question_%d" % question.id] = field
|
|
|
|
|
2016-06-13 19:08:14 +02:00
|
|
|
def answers(self):
|
|
|
|
for name, value in self.cleaned_data.items():
|
2018-10-06 12:35:49 +02:00
|
|
|
if name.startswith("question_"):
|
2016-06-13 19:08:14 +02:00
|
|
|
yield (self.fields[name].question_id, value)
|
2016-07-09 21:19:37 +02:00
|
|
|
|
|
|
|
|
2016-05-27 17:52:02 +02:00
|
|
|
class SurveyStatusFilterForm(forms.Form):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
survey = kwargs.pop("survey")
|
2018-01-16 16:22:52 +01:00
|
|
|
super().__init__(*args, **kwargs)
|
2016-05-27 17:52:02 +02:00
|
|
|
for question in survey.questions.all():
|
|
|
|
for answer in question.answers.all():
|
|
|
|
name = "question_%d_answer_%d" % (question.id, answer.id)
|
2018-10-06 12:35:49 +02:00
|
|
|
if self.is_bound and self.data.get(self.add_prefix(name), None):
|
2016-05-27 17:52:02 +02:00
|
|
|
initial = self.data.get(self.add_prefix(name), None)
|
|
|
|
else:
|
|
|
|
initial = "none"
|
2016-07-09 22:31:56 +02:00
|
|
|
field = forms.ChoiceField(
|
2016-07-10 00:26:02 +02:00
|
|
|
label="%s : %s" % (question.question, answer.answer),
|
2016-07-09 22:31:56 +02:00
|
|
|
choices=[("yes", "yes"), ("no", "no"), ("none", "none")],
|
|
|
|
widget=TriStateCheckbox,
|
|
|
|
required=False,
|
2018-10-06 12:35:49 +02:00
|
|
|
initial=initial,
|
|
|
|
)
|
2016-05-27 17:52:02 +02:00
|
|
|
field.question_id = question.id
|
|
|
|
field.answer_id = answer.id
|
|
|
|
self.fields[name] = field
|
|
|
|
|
|
|
|
def filters(self):
|
|
|
|
for name, value in self.cleaned_data.items():
|
2018-10-06 12:35:49 +02:00
|
|
|
if name.startswith("question_"):
|
|
|
|
yield (
|
|
|
|
self.fields[name].question_id,
|
|
|
|
self.fields[name].answer_id,
|
|
|
|
value,
|
|
|
|
)
|
2016-05-27 17:52:02 +02:00
|
|
|
|
2016-07-09 21:19:37 +02:00
|
|
|
|
2016-05-27 17:52:02 +02:00
|
|
|
class EventStatusFilterForm(forms.Form):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
event = kwargs.pop("event")
|
2018-01-16 16:22:52 +01:00
|
|
|
super().__init__(*args, **kwargs)
|
2016-05-27 17:52:02 +02:00
|
|
|
for option in event.options.all():
|
|
|
|
for choice in option.choices.all():
|
|
|
|
name = "option_%d_choice_%d" % (option.id, choice.id)
|
2018-10-06 12:35:49 +02:00
|
|
|
if self.is_bound and self.data.get(self.add_prefix(name), None):
|
2016-05-27 17:52:02 +02:00
|
|
|
initial = self.data.get(self.add_prefix(name), None)
|
|
|
|
else:
|
|
|
|
initial = "none"
|
2016-07-09 22:31:56 +02:00
|
|
|
field = forms.ChoiceField(
|
|
|
|
label="%s : %s" % (option.name, choice.value),
|
|
|
|
choices=[("yes", "yes"), ("no", "no"), ("none", "none")],
|
|
|
|
widget=TriStateCheckbox,
|
|
|
|
required=False,
|
2018-10-06 12:35:49 +02:00
|
|
|
initial=initial,
|
|
|
|
)
|
2016-05-27 17:52:02 +02:00
|
|
|
field.option_id = option.id
|
|
|
|
field.choice_id = choice.id
|
|
|
|
self.fields[name] = field
|
|
|
|
# has_paid
|
|
|
|
name = "event_has_paid"
|
|
|
|
if self.is_bound and self.data.get(self.add_prefix(name), None):
|
|
|
|
initial = self.data.get(self.add_prefix(name), None)
|
|
|
|
else:
|
|
|
|
initial = "none"
|
2018-10-06 12:35:49 +02:00
|
|
|
field = forms.ChoiceField(
|
|
|
|
label="Événement payé",
|
|
|
|
choices=[("yes", "yes"), ("no", "no"), ("none", "none")],
|
|
|
|
widget=TriStateCheckbox,
|
|
|
|
required=False,
|
|
|
|
initial=initial,
|
|
|
|
)
|
2016-05-27 17:52:02 +02:00
|
|
|
self.fields[name] = field
|
|
|
|
|
|
|
|
def filters(self):
|
|
|
|
for name, value in self.cleaned_data.items():
|
2018-10-06 12:35:49 +02:00
|
|
|
if name.startswith("option_"):
|
|
|
|
yield (self.fields[name].option_id, self.fields[name].choice_id, value)
|
2016-05-27 17:52:02 +02:00
|
|
|
elif name == "event_has_paid":
|
|
|
|
yield ("has_paid", None, value)
|
|
|
|
|
2016-07-09 21:19:37 +02:00
|
|
|
|
2018-08-05 18:11:10 +02:00
|
|
|
class UserForm(forms.ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = User
|
|
|
|
fields = ["first_name", "last_name", "email"]
|
2016-05-27 17:52:02 +02:00
|
|
|
|
|
|
|
|
2018-08-05 18:11:10 +02:00
|
|
|
class ProfileForm(forms.ModelForm):
|
2016-05-27 17:52:02 +02:00
|
|
|
class Meta:
|
|
|
|
model = CofProfile
|
2018-09-02 23:26:18 +02:00
|
|
|
fields = [
|
|
|
|
"phone",
|
|
|
|
"mailing_cof",
|
|
|
|
"mailing_bda",
|
|
|
|
"mailing_bda_revente",
|
2018-10-06 12:35:49 +02:00
|
|
|
"mailing_unernestaparis",
|
2018-09-02 23:26:18 +02:00
|
|
|
]
|
2016-07-09 21:19:37 +02:00
|
|
|
|
2016-05-27 17:52:02 +02:00
|
|
|
|
|
|
|
class RegistrationUserForm(forms.ModelForm):
|
|
|
|
def __init__(self, *args, **kw):
|
2018-01-16 16:22:52 +01:00
|
|
|
super().__init__(*args, **kw)
|
2018-10-06 12:35:49 +02:00
|
|
|
self.fields["username"].help_text = ""
|
2016-08-24 16:26:43 +02:00
|
|
|
|
2016-05-27 17:52:02 +02:00
|
|
|
class Meta:
|
|
|
|
model = User
|
|
|
|
fields = ("username", "first_name", "last_name", "email")
|
|
|
|
|
2016-07-09 21:19:37 +02:00
|
|
|
|
2016-08-17 15:34:01 +02:00
|
|
|
class RegistrationPassUserForm(RegistrationUserForm):
|
|
|
|
"""
|
|
|
|
Formulaire pour changer le mot de passe d'un utilisateur.
|
|
|
|
"""
|
2018-10-06 12:35:49 +02:00
|
|
|
|
|
|
|
password1 = forms.CharField(label=_("Mot de passe"), widget=forms.PasswordInput)
|
|
|
|
password2 = forms.CharField(
|
|
|
|
label=_("Confirmation du mot de passe"), widget=forms.PasswordInput
|
|
|
|
)
|
2016-08-17 15:34:01 +02:00
|
|
|
|
|
|
|
def clean_password2(self):
|
2018-10-06 12:35:49 +02:00
|
|
|
pass1 = self.cleaned_data["password1"]
|
|
|
|
pass2 = self.cleaned_data["password2"]
|
2016-08-17 15:34:01 +02:00
|
|
|
if pass1 and pass2:
|
|
|
|
if pass1 != pass2:
|
2018-10-06 12:35:49 +02:00
|
|
|
raise forms.ValidationError(_("Mots de passe non identiques."))
|
2016-08-17 15:34:01 +02:00
|
|
|
return pass2
|
|
|
|
|
|
|
|
def save(self, commit=True, *args, **kwargs):
|
2018-01-16 16:22:52 +01:00
|
|
|
user = super().save(commit, *args, **kwargs)
|
2018-10-06 12:35:49 +02:00
|
|
|
user.set_password(self.cleaned_data["password2"])
|
2016-08-17 15:34:01 +02:00
|
|
|
if commit:
|
|
|
|
user.save()
|
|
|
|
return user
|
|
|
|
|
|
|
|
|
2016-05-27 17:52:02 +02:00
|
|
|
class RegistrationProfileForm(forms.ModelForm):
|
|
|
|
def __init__(self, *args, **kw):
|
2018-01-16 16:22:52 +01:00
|
|
|
super().__init__(*args, **kw)
|
2018-10-06 12:35:49 +02:00
|
|
|
self.fields["mailing_cof"].initial = True
|
|
|
|
self.fields["mailing_bda"].initial = True
|
|
|
|
self.fields["mailing_bda_revente"].initial = True
|
|
|
|
self.fields["mailing_unernestaparis"].initial = True
|
2016-05-27 17:52:02 +02:00
|
|
|
|
|
|
|
self.fields.keyOrder = [
|
2018-10-06 12:35:49 +02:00
|
|
|
"login_clipper",
|
|
|
|
"phone",
|
|
|
|
"occupation",
|
|
|
|
"departement",
|
|
|
|
"is_cof",
|
|
|
|
"type_cotiz",
|
|
|
|
"mailing_cof",
|
|
|
|
"mailing_bda",
|
|
|
|
"mailing_bda_revente",
|
2018-09-02 23:26:18 +02:00
|
|
|
"mailing_unernestaparis",
|
2018-10-06 12:35:49 +02:00
|
|
|
"comments",
|
2018-09-02 23:26:18 +02:00
|
|
|
]
|
2016-05-27 17:52:02 +02:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = CofProfile
|
2018-10-06 12:35:49 +02:00
|
|
|
fields = (
|
|
|
|
"login_clipper",
|
|
|
|
"phone",
|
|
|
|
"occupation",
|
|
|
|
"departement",
|
|
|
|
"is_cof",
|
|
|
|
"type_cotiz",
|
|
|
|
"mailing_cof",
|
|
|
|
"mailing_bda",
|
|
|
|
"mailing_bda_revente",
|
|
|
|
"mailing_unernestaparis",
|
|
|
|
"comments",
|
|
|
|
)
|
2016-05-27 17:52:02 +02:00
|
|
|
|
2018-08-05 18:11:10 +02:00
|
|
|
|
2018-10-06 12:35:49 +02:00
|
|
|
STATUS_CHOICES = (
|
|
|
|
("no", "Non"),
|
|
|
|
("wait", "Oui mais attente paiement"),
|
|
|
|
("paid", "Oui payé"),
|
|
|
|
)
|
2016-07-09 21:19:37 +02:00
|
|
|
|
2016-05-27 17:52:02 +02:00
|
|
|
|
|
|
|
class AdminEventForm(forms.Form):
|
2018-10-06 12:35:49 +02:00
|
|
|
status = forms.ChoiceField(
|
|
|
|
label="Inscription", initial="no", choices=STATUS_CHOICES, widget=RadioSelect
|
|
|
|
)
|
2016-05-27 17:52:02 +02:00
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
2016-08-07 18:47:59 +02:00
|
|
|
self.event = kwargs.pop("event")
|
2016-05-27 17:52:02 +02:00
|
|
|
registration = kwargs.pop("current_registration", None)
|
2018-10-06 12:35:49 +02:00
|
|
|
current_choices, paid = (
|
|
|
|
(registration.options.all(), registration.paid)
|
|
|
|
if registration is not None
|
|
|
|
else ([], None)
|
|
|
|
)
|
2016-07-09 21:19:37 +02:00
|
|
|
if paid is True:
|
|
|
|
kwargs["initial"] = {"status": "paid"}
|
|
|
|
elif paid is False:
|
|
|
|
kwargs["initial"] = {"status": "wait"}
|
2016-05-27 17:52:02 +02:00
|
|
|
else:
|
2016-07-09 21:19:37 +02:00
|
|
|
kwargs["initial"] = {"status": "no"}
|
2018-01-16 16:22:52 +01:00
|
|
|
super().__init__(*args, **kwargs)
|
2016-05-27 17:52:02 +02:00
|
|
|
choices = {}
|
|
|
|
for choice in current_choices:
|
|
|
|
if choice.event_option.id not in choices:
|
|
|
|
choices[choice.event_option.id] = [choice.id]
|
|
|
|
else:
|
|
|
|
choices[choice.event_option.id].append(choice.id)
|
|
|
|
all_choices = choices
|
2016-08-07 18:47:59 +02:00
|
|
|
for option in self.event.options.all():
|
2018-10-06 12:35:49 +02:00
|
|
|
choices = [(choice.id, choice.value) for choice in option.choices.all()]
|
2016-05-27 17:52:02 +02:00
|
|
|
if option.multi_choices:
|
2018-10-06 12:35:49 +02:00
|
|
|
initial = [] if option.id not in all_choices else all_choices[option.id]
|
2016-07-09 22:31:56 +02:00
|
|
|
field = forms.MultipleChoiceField(
|
|
|
|
label=option.name,
|
|
|
|
choices=choices,
|
|
|
|
widget=CheckboxSelectMultiple,
|
|
|
|
required=False,
|
2018-10-06 12:35:49 +02:00
|
|
|
initial=initial,
|
|
|
|
)
|
2016-05-27 17:52:02 +02:00
|
|
|
else:
|
2018-10-06 12:35:49 +02:00
|
|
|
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,
|
|
|
|
)
|
2016-05-27 17:52:02 +02:00
|
|
|
field.option_id = option.id
|
|
|
|
self.fields["option_%d" % option.id] = field
|
2016-08-07 18:47:59 +02:00
|
|
|
for commentfield in self.event.commentfields.all():
|
2016-05-27 17:52:02 +02:00
|
|
|
initial = commentfield.default
|
|
|
|
if registration is not None:
|
|
|
|
try:
|
2018-10-06 12:35:49 +02:00
|
|
|
initial = registration.comments.get(
|
|
|
|
commentfield=commentfield
|
|
|
|
).content
|
2016-05-27 17:52:02 +02:00
|
|
|
except EventCommentValue.DoesNotExist:
|
|
|
|
pass
|
2018-10-06 12:35:49 +02:00
|
|
|
widget = (
|
|
|
|
forms.Textarea if commentfield.fieldtype == "text" else forms.TextInput
|
|
|
|
)
|
|
|
|
field = forms.CharField(
|
|
|
|
label=commentfield.name, widget=widget, required=False, initial=initial
|
|
|
|
)
|
2016-05-27 17:52:02 +02:00
|
|
|
field.comment_id = commentfield.id
|
|
|
|
self.fields["comment_%d" % commentfield.id] = field
|
|
|
|
|
|
|
|
def choices(self):
|
|
|
|
for name, value in self.cleaned_data.items():
|
2018-10-06 12:35:49 +02:00
|
|
|
if name.startswith("option_"):
|
2016-05-27 17:52:02 +02:00
|
|
|
yield (self.fields[name].option_id, value)
|
|
|
|
|
|
|
|
def comments(self):
|
|
|
|
for name, value in self.cleaned_data.items():
|
2018-10-06 12:35:49 +02:00
|
|
|
if name.startswith("comment_"):
|
2016-05-27 17:52:02 +02:00
|
|
|
yield (self.fields[name].comment_id, value)
|
2016-07-15 01:06:33 +02:00
|
|
|
|
|
|
|
|
2016-08-07 18:47:59 +02:00
|
|
|
class BaseEventRegistrationFormset(BaseFormSet):
|
|
|
|
def __init__(self, *args, **kwargs):
|
2018-10-06 12:35:49 +02:00
|
|
|
self.events = kwargs.pop("events")
|
|
|
|
self.current_registrations = kwargs.pop("current_registrations", None)
|
2016-08-07 18:47:59 +02:00
|
|
|
self.extra = len(self.events)
|
2018-01-16 16:22:52 +01:00
|
|
|
super().__init__(*args, **kwargs)
|
2016-08-07 18:47:59 +02:00
|
|
|
|
|
|
|
def _construct_form(self, index, **kwargs):
|
2018-10-06 12:35:49 +02:00
|
|
|
kwargs["event"] = self.events[index]
|
2016-08-07 18:47:59 +02:00
|
|
|
if self.current_registrations is not None:
|
2018-10-06 12:35:49 +02:00
|
|
|
kwargs["current_registration"] = self.current_registrations[index]
|
2018-01-16 16:22:52 +01:00
|
|
|
return super()._construct_form(index, **kwargs)
|
|
|
|
|
|
|
|
|
2016-08-17 15:34:01 +02:00
|
|
|
EventFormset = formset_factory(AdminEventForm, BaseEventRegistrationFormset)
|
2016-08-07 18:47:59 +02:00
|
|
|
|
|
|
|
|
2016-07-15 01:06:33 +02:00
|
|
|
class CalendarForm(forms.ModelForm):
|
2016-07-16 01:51:20 +02:00
|
|
|
subscribe_to_events = forms.BooleanField(
|
2018-10-06 12:35:49 +02:00
|
|
|
initial=True, label="Événements du COF", required=False
|
|
|
|
)
|
2016-07-16 01:51:20 +02:00
|
|
|
subscribe_to_my_shows = forms.BooleanField(
|
2018-10-06 12:35:49 +02:00
|
|
|
initial=True,
|
|
|
|
label="Les spectacles pour lesquels j'ai obtenu une place",
|
|
|
|
required=False,
|
|
|
|
)
|
2016-07-16 01:51:20 +02:00
|
|
|
other_shows = forms.ModelMultipleChoiceField(
|
2018-10-06 12:35:49 +02:00
|
|
|
label="Spectacles supplémentaires",
|
|
|
|
queryset=Spectacle.objects.filter(tirage__active=True),
|
|
|
|
widget=forms.CheckboxSelectMultiple,
|
|
|
|
required=False,
|
|
|
|
)
|
2016-07-15 01:06:33 +02:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = CalendarSubscription
|
2018-10-06 12:35:49 +02:00
|
|
|
fields = ["subscribe_to_events", "subscribe_to_my_shows", "other_shows"]
|
2016-08-23 17:40:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ClubsForm(forms.Form):
|
|
|
|
"""
|
|
|
|
Formulaire d'inscription d'un membre à plusieurs clubs du COF.
|
|
|
|
"""
|
2018-10-06 12:35:49 +02:00
|
|
|
|
2016-08-23 17:40:24 +02:00
|
|
|
clubs = forms.ModelMultipleChoiceField(
|
2018-10-06 12:35:49 +02:00
|
|
|
label="Inscriptions aux clubs du COF",
|
|
|
|
queryset=Club.objects.all(),
|
|
|
|
widget=forms.CheckboxSelectMultiple,
|
|
|
|
required=False,
|
|
|
|
)
|
2017-05-26 00:58:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
# ---
|
|
|
|
# Announcements banner
|
|
|
|
# TODO: move this to the `gestion` app once the supportBDS branch is merged
|
|
|
|
# ---
|
|
|
|
|
2018-10-06 12:35:49 +02:00
|
|
|
|
2017-05-26 00:58:59 +02:00
|
|
|
class GestioncofConfigForm(ConfigForm):
|
|
|
|
gestion_banner = forms.CharField(
|
|
|
|
label=_("Announcements banner"),
|
|
|
|
help_text=_("An empty banner disables annoucements"),
|
2018-10-06 12:35:49 +02:00
|
|
|
max_length=2048,
|
2017-05-26 00:58:59 +02:00
|
|
|
)
|