some documentation for clarification added

This commit is contained in:
Benni Baermann 2021-10-07 10:29:04 +02:00
parent 4e4edc390c
commit fd46dd2f5a

View file

@ -38,7 +38,8 @@ class Extern(Volunteer):
service_id = models.CharField(max_length=15, null=True, blank=True) service_id = models.CharField(max_length=15, null=True, blank=True)
def save(self,*args,**kwargs): def save(self,*args,**kwargs):
# is there a way to call super().save() only once? # we don't call save with args/kwargs to avoid UNIQUE CONSTRAINT errors
# but maybe there is a better solution?
super().save() super().save()
self.service_id = type(self).__name__ + str(self.pk) self.service_id = type(self).__name__ + str(self.pk)
super().save() super().save()
@ -89,9 +90,13 @@ class Project(Volunteer):
def save(self,*args,**kwargs): def save(self,*args,**kwargs):
'''we generate the autogenerated fields here''' '''we generate the autogenerated fields here'''
# we don't call save with args/kwargs to avoid UNIQUE CONSTRAINT errors
# but maybe there is a better solution?
super().save() super().save()
self.pid = str(self.account.code) + str(self.pk).zfill(3) self.pid = str(self.account.code) + str(self.pk).zfill(3)
# generation of finance_id
if not self.project_of_year: if not self.project_of_year:
# we need to determine if this is a new year with its first new project...
year = self.start.year year = self.start.year
projects = Project.objects.filter(start__year=year) projects = Project.objects.filter(start__year=year)
if not projects: if not projects: