From a0f656b3189cdd19aaf54d34683f4bf84a4cb7d1 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Tue, 5 Jul 2016 11:33:27 +0200 Subject: [PATCH] =?UTF-8?q?Ajoute=20des=20etiquettes,=20factorise=20un=20p?= =?UTF-8?q?eu=20le=20code=20des=20mod=C3=A8les=20avec=20de=20l'heritage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cotisations/models.py | 5 +++++ machines/models.py | 3 ++- users/models.py | 22 ++++++++-------------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/cotisations/models.py b/cotisations/models.py index 60c6cc33..d72ec60b 100644 --- a/cotisations/models.py +++ b/cotisations/models.py @@ -56,6 +56,8 @@ class NewFactureForm(ModelForm): self.fields['cheque'].required = False self.fields['banque'].required = False self.fields['cheque'].label = 'Numero de chèque' + self.fields['banque'].empty_label = "Non renseigné" + self.fields['paiement'].empty_label = "Séléctionner un moyen de paiement" class Meta: model = Facture @@ -71,6 +73,9 @@ class EditFactureForm(ModelForm): self.fields['cheque'].label = 'Numero de chèque' self.fields['name'].label = 'Designation' self.fields['prix'].label = 'Prix unitaire' + self.fields['banque'].empty_label = "Non renseigné" + self.fields['paiement'].empty_label = "Séléctionner un moyen de paiement" + self.fields['user'].empty_label = "Séléctionner l'adhérent propriétaire" class Meta: model = Facture diff --git a/machines/models.py b/machines/models.py index 1cf9c557..778a83fb 100644 --- a/machines/models.py +++ b/machines/models.py @@ -25,7 +25,7 @@ class Interface(models.Model): mac_address = MACAddressField(integer=False, unique=True) machine = models.ForeignKey('Machine', on_delete=models.PROTECT) details = models.CharField(max_length=255, blank=True) - dns = models.CharField(help_text="Obligatoire et unique", max_length=255, unique=True) + dns = models.CharField(help_text="Obligatoire et unique, doit se terminer en .rez et ne pas comporter de points", max_length=255, unique=True) def __str__(self): return self.dns @@ -45,6 +45,7 @@ class EditMachineForm(ModelForm): super(EditMachineForm, self).__init__(*args, **kwargs) self.fields['name'].label = 'Nom de la machine' self.fields['type'].label = 'Type de machine' + self.fields['type'].empty_label = "Séléctionner un type de machine" class NewMachineForm(EditMachineForm): class Meta(EditMachineForm.Meta): diff --git a/users/models.py b/users/models.py index b37f6066..446dac15 100644 --- a/users/models.py +++ b/users/models.py @@ -29,7 +29,7 @@ class User(models.Model): surname = models.CharField(max_length=255) pseudo = models.CharField(max_length=255, unique=True) email = models.EmailField() - school = models.ForeignKey('School', on_delete=models.PROTECT) + school = models.ForeignKey('School', on_delete=models.PROTECT, null=False, blank=False) comment = models.CharField(help_text="Commentaire, promo", max_length=255, blank=True) room = models.OneToOneField('topologie.Room', on_delete=models.PROTECT, blank=True, null=True) pwd_ssha = models.CharField(max_length=255) @@ -80,19 +80,6 @@ class Whitelist(models.Model): def __str__(self): return str(self.user) + ' ' + str(self.raison) -class UserForm(ModelForm): - def __init__(self, *args, **kwargs): - super(InfoForm, self).__init__(*args, **kwargs) - self.fields['name'].label = 'Nom' - self.fields['surname'].label = 'Prénom' - self.fields['school'].label = 'Établissement' - self.fields['comment'].label = 'Commentaire' - self.fields['room'].label = 'Chambre' - - class Meta: - model = User - fields = '__all__' - class InfoForm(ModelForm): force = forms.BooleanField(label="Forcer le déménagement ?", initial=False, required=False) @@ -103,6 +90,8 @@ class InfoForm(ModelForm): self.fields['school'].label = 'Établissement' self.fields['comment'].label = 'Commentaire' self.fields['room'].label = 'Chambre' + self.fields['room'].empty_label = "Pas de chambre" + self.fields['school'].empty_label = "Séléctionner un établissement" def clean_force(self): if self.cleaned_data.get('force', False): @@ -113,6 +102,10 @@ class InfoForm(ModelForm): model = User fields = ['name','surname','pseudo','email', 'school', 'comment', 'room'] +class UserForm(InfoForm): + class Meta(InfoForm.Meta): + fields = '__all__' + class PasswordForm(ModelForm): class Meta: model = User @@ -132,6 +125,7 @@ class RightForm(ModelForm): def __init__(self, *args, **kwargs): super(RightForm, self).__init__(*args, **kwargs) self.fields['right'].label = 'Droit' + self.fields['right'].empty_label = "Choisir un nouveau droit" class Meta: model = Right