From ea3072e559b7878a6021a49ae2697051f9b170e8 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Mon, 4 Oct 2021 14:14:01 +0200 Subject: [PATCH] project_of_year ist working now --- input/models.py | 6 +++++- input/tests.py | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/input/models.py b/input/models.py index 8dafe9f..ed00c46 100644 --- a/input/models.py +++ b/input/models.py @@ -103,7 +103,11 @@ class Project(Volunteer): if not projects: self.project_of_year = 1 else: - pass + projects = projects.order_by("-project_of_year")[0] + print("GEORDNET") + print(f"highest project_of_year is {projects.project_of_year}") + self.project_of_year = int(projects.project_of_year) + 1 + print(f"project_of_year is {self.project_of_year}") else: print(f"project_of_year is {self.project_of_year}") super().save(*args,**kwargs) diff --git a/input/tests.py b/input/tests.py index 92033a1..ec64c5b 100644 --- a/input/tests.py +++ b/input/tests.py @@ -52,8 +52,11 @@ class TestWithLogin(TestCase): startdate = date(2022,1,1) obj = Project.objects.create(account= acc, name='testproject', start=startdate) #obj.save() - print(f'pid: {obj.project_of_year}') + print(f'p_of_year: {obj.project_of_year}') self.assertEqual(obj.project_of_year,1) obj2 = Project.objects.create(account= acc, name='testproject2', start=startdate) - self.assertEqual(obj.project_of_year,2) + self.assertEqual(obj2.project_of_year,2) + + obj3 = Project.objects.create(account= acc, name='testproject2', start=startdate) + self.assertEqual(obj3.project_of_year,3)