From bef1f6d5aebd3a427656f32ac08bbde347fd7cc9 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Mon, 4 Oct 2021 12:57:13 +0200 Subject: [PATCH] projects_of_year test expanded, fails now (as expected) --- input/models.py | 6 ++++++ input/tests.py | 3 +++ 2 files changed, 9 insertions(+) diff --git a/input/models.py b/input/models.py index 2909653..8dafe9f 100644 --- a/input/models.py +++ b/input/models.py @@ -98,6 +98,12 @@ class Project(Volunteer): # self.finance_id = "1234000" year = self.start.year print(f"startyear: {year}") + projects = Project.objects.filter(start__year=year) + print(projects) + if not projects: + self.project_of_year = 1 + else: + pass 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 b08b620..92033a1 100644 --- a/input/tests.py +++ b/input/tests.py @@ -54,3 +54,6 @@ class TestWithLogin(TestCase): #obj.save() print(f'pid: {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)