project_of_year ist working now
This commit is contained in:
parent
bef1f6d5ae
commit
ea3072e559
2 changed files with 10 additions and 3 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue