From fd46dd2f5aa466043533c6774f0e0cfca88a9c7a Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Thu, 7 Oct 2021 10:29:04 +0200 Subject: [PATCH] some documentation for clarification added --- input/models.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/input/models.py b/input/models.py index b798ef8..6dff1dc 100644 --- a/input/models.py +++ b/input/models.py @@ -38,7 +38,8 @@ class Extern(Volunteer): service_id = models.CharField(max_length=15, null=True, blank=True) 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() self.service_id = type(self).__name__ + str(self.pk) super().save() @@ -89,9 +90,13 @@ class Project(Volunteer): def save(self,*args,**kwargs): '''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() self.pid = str(self.account.code) + str(self.pk).zfill(3) + # generation of finance_id 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 projects = Project.objects.filter(start__year=year) if not projects: