Browse Source

project_of_year ist working now

master
Benni Baermann 3 years ago
parent
commit
ea3072e559
2 changed files with 10 additions and 3 deletions
  1. +5
    -1
      input/models.py
  2. +5
    -2
      input/tests.py

+ 5
- 1
input/models.py View File

@ -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)

+ 5
- 2
input/tests.py View File

@ -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…
Cancel
Save