2020-09-10 15:06:53 +02:00
|
|
|
from django import forms
|
2021-04-29 00:27:33 +02:00
|
|
|
|
2020-09-10 15:06:53 +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":
|
2020-09-10 15:06:53 +02:00
|
|
|
|
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()
|
2020-09-10 15:06:53 +02:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = ErnestoUser
|
2021-04-29 00:27:33 +02:00
|
|
|
fields = (
|
|
|
|
"trombonoscope",
|
|
|
|
"nom_trombonoscope",
|
|
|
|
"instru_trombonoscope",
|
|
|
|
"trombonoscope_colors",
|
|
|
|
"trombonoscope_fond",
|
|
|
|
"trombonoscope_texte",
|
|
|
|
)
|