38 lines
987 B
Python
38 lines
987 B
Python
from captcha.fields import ReCaptchaField
|
|
from django import forms
|
|
from django.contrib.auth.models import User
|
|
from django.forms import ModelForm
|
|
from django.forms.models import inlineformset_factory
|
|
|
|
from petitscours.models import PetitCoursAbility, PetitCoursDemande
|
|
|
|
|
|
class DemandeForm(ModelForm):
|
|
captcha = ReCaptchaField(attrs={"theme": "clean", "lang": "fr"})
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
self.fields["matieres"].help_text = ""
|
|
|
|
class Meta:
|
|
model = PetitCoursDemande
|
|
fields = (
|
|
"name",
|
|
"email",
|
|
"phone",
|
|
"quand",
|
|
"freq",
|
|
"lieu",
|
|
"matieres",
|
|
"agrege_requis",
|
|
"niveau",
|
|
"remarques",
|
|
)
|
|
widgets = {"matieres": forms.CheckboxSelectMultiple}
|
|
|
|
|
|
MatieresFormSet = inlineformset_factory(
|
|
User,
|
|
PetitCoursAbility,
|
|
fields=("matiere", "niveau", "agrege"),
|
|
)
|