ernestophone.ens.fr/trombonoscope/forms.py

27 lines
781 B
Python
Raw Permalink Normal View History

from django import forms
2021-04-29 00:27:33 +02:00
from gestion.models import ErnestoUser
class ChangeTrombonoscope(forms.ModelForm):
def save(self, *args, **kwargs):
super(ChangeTrombonoscope, self).save(*args, **kwargs)
2021-04-29 00:27:33 +02:00
trombonoscope_colors = self.cleaned_data["trombonoscope_colors"]
if trombonoscope_colors != "autre":
2021-04-29 00:27:33 +02:00
self.instance.trombonoscope_fond = trombonoscope_colors[:7]
self.instance.trombonoscope_texte = trombonoscope_colors[7:]
self.instance.save()
class Meta:
model = ErnestoUser
2021-04-29 00:27:33 +02:00
fields = (
"trombonoscope",
"nom_trombonoscope",
"instru_trombonoscope",
"trombonoscope_colors",
"trombonoscope_fond",
"trombonoscope_texte",
)