Commit 9fab667f authored by Pierre-Antoine Comby's avatar Pierre-Antoine Comby

saut de ligne pour plus de visibilité

parent ca822d0c
......@@ -20,8 +20,10 @@ class CreditRetraitWithoutIdbde(Exception):
"""Erreur levée en cas de tentative de crédit ou retrait sans idbde."""
pass
class BootstrapForm(forms.Form):
"""Ajoute l'attribut 'class' à tous les champs du formulare"""
def __init__(self, *args, **kwargs):
super(BootstrapForm, self).__init__(*args, **kwargs)
for name, field in self.fields.items():
......@@ -46,64 +48,93 @@ class BootstrapForm(forms.Form):
else:
field.widget.attrs.update({'class': 'form-control'})
class LoginForm(BootstrapForm):
"""Formulaire de login"""
username = forms.CharField(label=_(u"Pseudo"), widget=forms.TextInput(attrs={"placeholder" : _(u"Ton pseudo note kfet"), "autofocus" : "autofocus", "class" : "form-control"}))
password = forms.CharField(label=_(u"Mot de passe"), widget=forms.PasswordInput(render_value=False, attrs={ "class" : "form-control" }))
droits = forms.ChoiceField(label=_(u"Droits"), choices=[(k, settings.ACL_MASKS[k][0]) for k in settings._acl_masks_keys])
username = forms.CharField(label=_(u"Pseudo"), widget=forms.TextInput(attrs={"placeholder": _(
u"Ton pseudo note kfet"), "autofocus": "autofocus", "class": "form-control"}))
password = forms.CharField(label=_(u"Mot de passe"), widget=forms.PasswordInput(
render_value=False, attrs={"class": "form-control"}))
droits = forms.ChoiceField(label=_(u"Droits"), choices=[(
k, settings.ACL_MASKS[k][0]) for k in settings._acl_masks_keys])
class InviteForm(BootstrapForm):
"""Formulaire d'invitation"""
nom = forms.CharField(label=_(u"Nom"))
prenom = forms.CharField(label=_(u"Prénom"))
class EntreePotForm(forms.Form):
"""Formulaire pour le choix des pots à l'entrée"""
pot = forms.ChoiceField(label="Choix du [Pot] :")
class ToogleEtatPot(forms.Form):
""" Le formulaire est vide, cela permet seulement d'avoir accès à un bouton de manière simple !"""
class FrenchFloatField(forms.FloatField):
"""Un champ FloatField, mais qui accepte aussi la virgule comme séparateur"""
def to_python(self, raw_value):
"""Conversion de la valeur texte en objet python."""
return super(FrenchFloatField, self).to_python(raw_value.replace(",", "."))
class BaseCompteRelatedForm(BootstrapForm):
"""Classe de base pour tous les formulaires traitant un compte (même une préinscription)"""
type = forms.ChoiceField(label=_(u"Type de compte"), choices=[("personne", _(u"Personne")), ("club", _(u"Club"))])
nom = forms.CharField(label=_(u"Nom"), widget=forms.TextInput(attrs={"autocomplete" : "off"}))
prenom = forms.CharField(label=_(u"Prénom"), widget=forms.TextInput(attrs={"autocomplete" : "off"}))
mail = forms.CharField(label=_(u"E-mail"), widget=forms.TextInput(attrs={"autocomplete" : "off"}))
tel = forms.CharField(label=_(u"Téléphone"), required=False, widget=forms.TextInput(attrs={"autocomplete" : "off"}))
adresse = forms.CharField(label=_(u"Adresse"), required=False, widget=forms.TextInput(attrs={"autocomplete" : "off"}))
pbsante = forms.CharField(label=_(u"Problèmes de santé"), required=False, widget=forms.TextInput(attrs={"autocomplete" : "off"}))
type = forms.ChoiceField(label=_(u"Type de compte"), choices=[
("personne", _(u"Personne")), ("club", _(u"Club"))])
nom = forms.CharField(label=_(u"Nom"), widget=forms.TextInput(
attrs={"autocomplete": "off"}))
prenom = forms.CharField(
label=_(u"Prénom"), widget=forms.TextInput(attrs={"autocomplete": "off"}))
mail = forms.CharField(
label=_(u"E-mail"), widget=forms.TextInput(attrs={"autocomplete": "off"}))
tel = forms.CharField(label=_(u"Téléphone"), required=False,
widget=forms.TextInput(attrs={"autocomplete": "off"}))
adresse = forms.CharField(label=_(
u"Adresse"), required=False, widget=forms.TextInput(attrs={"autocomplete": "off"}))
pbsante = forms.CharField(label=_(u"Problèmes de santé"), required=False,
widget=forms.TextInput(attrs={"autocomplete": "off"}))
normalien = forms.BooleanField(label=_(u"Normalien"), required=False)
section = forms.CharField(label=_(u"Section"), required=False, widget=forms.TextInput(attrs={"autocomplete" : "off"}))
section = forms.CharField(label=_(
u"Section"), required=False, widget=forms.TextInput(attrs={"autocomplete": "off"}))
class Regen_pwForm(BootstrapForm):
"""Formulaire de demande de nouveau mot de passe"""
nom = forms.CharField(label=_(u"Nom"), widget=forms.TextInput(attrs={"autocomplete" : "off", "class" : "form-control"}), required=True)
prenom = forms.CharField(label=_(u"Prénom"), widget=forms.TextInput(attrs={"autocomplete" : "off", "class" : "form-control" }), required=True)
mail = forms.CharField(label=_(u"E-mail"), widget=forms.TextInput(attrs={"autocomplete" : "off", "class" : "form-control" }), required=True)
nom = forms.CharField(label=_(u"Nom"), widget=forms.TextInput(
attrs={"autocomplete": "off", "class": "form-control"}), required=True)
prenom = forms.CharField(label=_(u"Prénom"), widget=forms.TextInput(
attrs={"autocomplete": "off", "class": "form-control"}), required=True)
mail = forms.CharField(label=_(u"E-mail"), widget=forms.TextInput(
attrs={"autocomplete": "off", "class": "form-control"}), required=True)
class CompteRelatedForm(BaseCompteRelatedForm):
"""Classe de base pour les formulaires traitant un compte avec toutes ses données
(par opposition à une préinscription)."""
pseudo = forms.CharField(label=_(u"Pseudo"), widget=forms.TextInput(attrs={"autocomplete" : "off"}))
fonction = forms.CharField(label=_(u"Fonction"), required=False, widget=forms.TextInput(attrs={"autocomplete" : "off"}))
commentaire = forms.CharField(label=_(u"Commentaire"), required=False, widget=forms.TextInput(attrs={"autocomplete" : "off"}))
report_period = forms.IntegerField(label=_(u"Fréquence des rapports"), required=False, widget=forms.TextInput(attrs={"autocomplete" : "off"}))
pseudo = forms.CharField(
label=_(u"Pseudo"), widget=forms.TextInput(attrs={"autocomplete": "off"}))
fonction = forms.CharField(label=_(
u"Fonction"), required=False, widget=forms.TextInput(attrs={"autocomplete": "off"}))
commentaire = forms.CharField(label=_(
u"Commentaire"), required=False, widget=forms.TextInput(attrs={"autocomplete": "off"}))
report_period = forms.IntegerField(label=_(
u"Fréquence des rapports"), required=False, widget=forms.TextInput(attrs={"autocomplete": "off"}))
bloque = forms.BooleanField(label=_(u"Bloquer le compte"), required=False)
def __init__(self, *args, **kwargs):
super(CompteRelatedForm, self).__init__(*args, **kwargs)
# La section n'est facultative qu'à la préinscription et si c'est une personne
self.fields["section"].required = (self.fields["type"] == "personne")
class CompteForm(CompteRelatedForm):
"""Formulaire pour modifier un compte"""
def clean(self):
"""Supprime les None des champs facultatifs"""
out = super(CompteForm, self).clean()
......
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