ernestophone.ens.fr/trombonoscope/forms.py
2020-09-10 15:06:53 +02:00

25 lines
809 B
Python

from django import forms
from gestion.models import ErnestoUser
from django.utils.translation import gettext_lazy as _
class ChangeTrombonoscope(forms.ModelForm):
def save(self, *args, **kwargs):
super(ChangeTrombonoscope, self).save(*args, **kwargs)
trombonoscope = self.cleaned_data["trombonoscope"]
trombonoscope_colors = self.cleaned_data['trombonoscope_colors']
if(trombonoscope_colors != 'autre'):
self.instance.trombonoscope_fond=trombonoscope_colors[:7]
self.instance.trombonoscope_texte=trombonoscope_colors[7:]
self.instance.save( )
class Meta:
model = ErnestoUser
fields = ("trombonoscope","nom_trombonoscope","instru_trombonoscope","trombonoscope_colors","trombonoscope_fond","trombonoscope_texte")