8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-27 07:02:26 +00:00

Ajoute des etiquettes, factorise un peu le code des modèles avec de l'heritage

This commit is contained in:
chirac 2016-07-05 11:33:27 +02:00
parent 49a3041c61
commit 9436331c26
3 changed files with 15 additions and 15 deletions

View file

@ -56,6 +56,8 @@ class NewFactureForm(ModelForm):
self.fields['cheque'].required = False self.fields['cheque'].required = False
self.fields['banque'].required = False self.fields['banque'].required = False
self.fields['cheque'].label = 'Numero de chèque' 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: class Meta:
model = Facture model = Facture
@ -71,6 +73,9 @@ class EditFactureForm(ModelForm):
self.fields['cheque'].label = 'Numero de chèque' self.fields['cheque'].label = 'Numero de chèque'
self.fields['name'].label = 'Designation' self.fields['name'].label = 'Designation'
self.fields['prix'].label = 'Prix unitaire' 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: class Meta:
model = Facture model = Facture

View file

@ -25,7 +25,7 @@ class Interface(models.Model):
mac_address = MACAddressField(integer=False, unique=True) mac_address = MACAddressField(integer=False, unique=True)
machine = models.ForeignKey('Machine', on_delete=models.PROTECT) machine = models.ForeignKey('Machine', on_delete=models.PROTECT)
details = models.CharField(max_length=255, blank=True) 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): def __str__(self):
return self.dns return self.dns
@ -45,6 +45,7 @@ class EditMachineForm(ModelForm):
super(EditMachineForm, self).__init__(*args, **kwargs) super(EditMachineForm, self).__init__(*args, **kwargs)
self.fields['name'].label = 'Nom de la machine' self.fields['name'].label = 'Nom de la machine'
self.fields['type'].label = 'Type de machine' self.fields['type'].label = 'Type de machine'
self.fields['type'].empty_label = "Séléctionner un type de machine"
class NewMachineForm(EditMachineForm): class NewMachineForm(EditMachineForm):
class Meta(EditMachineForm.Meta): class Meta(EditMachineForm.Meta):

View file

@ -29,7 +29,7 @@ class User(models.Model):
surname = models.CharField(max_length=255) surname = models.CharField(max_length=255)
pseudo = models.CharField(max_length=255, unique=True) pseudo = models.CharField(max_length=255, unique=True)
email = models.EmailField() 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) 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) room = models.OneToOneField('topologie.Room', on_delete=models.PROTECT, blank=True, null=True)
pwd_ssha = models.CharField(max_length=255) pwd_ssha = models.CharField(max_length=255)
@ -80,19 +80,6 @@ class Whitelist(models.Model):
def __str__(self): def __str__(self):
return str(self.user) + ' ' + str(self.raison) 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): class InfoForm(ModelForm):
force = forms.BooleanField(label="Forcer le déménagement ?", initial=False, required=False) 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['school'].label = 'Établissement'
self.fields['comment'].label = 'Commentaire' self.fields['comment'].label = 'Commentaire'
self.fields['room'].label = 'Chambre' 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): def clean_force(self):
if self.cleaned_data.get('force', False): if self.cleaned_data.get('force', False):
@ -113,6 +102,10 @@ class InfoForm(ModelForm):
model = User model = User
fields = ['name','surname','pseudo','email', 'school', 'comment', 'room'] fields = ['name','surname','pseudo','email', 'school', 'comment', 'room']
class UserForm(InfoForm):
class Meta(InfoForm.Meta):
fields = '__all__'
class PasswordForm(ModelForm): class PasswordForm(ModelForm):
class Meta: class Meta:
model = User model = User
@ -132,6 +125,7 @@ class RightForm(ModelForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(RightForm, self).__init__(*args, **kwargs) super(RightForm, self).__init__(*args, **kwargs)
self.fields['right'].label = 'Droit' self.fields['right'].label = 'Droit'
self.fields['right'].empty_label = "Choisir un nouveau droit"
class Meta: class Meta:
model = Right model = Right