1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-06-21 09:58:23 +02:00

Add department and promotion in Profile model

This commit is contained in:
Yohann D'ANELLO
2020-04-22 16:25:09 +02:00
parent a85a5bf8fe
commit c31fb0c13d
4 changed files with 72 additions and 1 deletions

View File

@ -25,6 +25,12 @@ class ProfileForm(forms.ModelForm):
A form for the extras field provided by the :model:`member.Profile` model.
"""
def save(self, commit=True):
if not self.instance.section or (("department" in self.changed_data
or "promotion" in self.changed_data) and "section" not in self.changed_data):
self.instance.section = self.instance.section_generated
return super().save(commit)
class Meta:
model = Profile
fields = '__all__'