project_of_year ist working now

This commit is contained in:
Benni Bärmann 2021-10-04 14:14:01 +02:00
parent bef1f6d5ae
commit ea3072e559
2 changed files with 10 additions and 3 deletions

View File

@ -103,7 +103,11 @@ class Project(Volunteer):
if not projects: if not projects:
self.project_of_year = 1 self.project_of_year = 1
else: 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: else:
print(f"project_of_year is {self.project_of_year}") print(f"project_of_year is {self.project_of_year}")
super().save(*args,**kwargs) super().save(*args,**kwargs)

View File

@ -52,8 +52,11 @@ class TestWithLogin(TestCase):
startdate = date(2022,1,1) startdate = date(2022,1,1)
obj = Project.objects.create(account= acc, name='testproject', start=startdate) obj = Project.objects.create(account= acc, name='testproject', start=startdate)
#obj.save() #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) self.assertEqual(obj.project_of_year,1)
obj2 = Project.objects.create(account= acc, name='testproject2', start=startdate) 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)