Skip to content

Commit 02a5899

Browse files
authored
Calculate Grant amounts according to pending status (#4324)
1 parent 2e5b4d7 commit 02a5899

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

backend/grants/models.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ class ApprovedType(models.TextChoices):
230230

231231
def __init__(self, *args, **kwargs):
232232
super().__init__(*args, **kwargs)
233-
self._original_status = self.status
233+
self._original_pending_status = self.pending_status
234234
self._original_approved_type = self.approved_type
235235
self._original_country_type = self.country_type
236236

@@ -253,14 +253,14 @@ def save(self, *args, **kwargs):
253253

254254
self._original_approved_type = self.approved_type
255255
self._original_country_type = self.country_type
256-
self._original_status = self.status
256+
self._original_pending_status = self.pending_status
257257

258258
def _calculate_grant_amounts(self):
259-
if self.status != Grant.Status.approved:
259+
if self.pending_status != Grant.Status.approved:
260260
return
261261

262262
if (
263-
self._original_status == self.status
263+
self._original_pending_status == self.pending_status
264264
and self._original_approved_type == self.approved_type
265265
and self._original_country_type == self.country_type
266266
):

backend/grants/tests/test_models.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def test_calculate_grant_amounts(data):
5454
expected_travel_amount = data["expected_travel_amount"]
5555

5656
grant = GrantFactory(
57-
status=Grant.Status.pending,
57+
pending_status=Grant.Status.pending,
5858
approved_type=approved_type,
5959
departure_country=departure_country,
6060
conference__grants_default_ticket_amount=100,
@@ -64,7 +64,7 @@ def test_calculate_grant_amounts(data):
6464
conference__grants_default_travel_from_extra_eu_amount=500,
6565
)
6666

67-
grant.status = Grant.Status.approved
67+
grant.pending_status = Grant.Status.approved
6868
grant.save()
6969

7070
grant.refresh_from_db()
@@ -82,7 +82,7 @@ def test_calculate_grant_amounts(data):
8282

8383
def test_resets_amounts_on_approved_type_change():
8484
grant = GrantFactory(
85-
status=Grant.Status.pending,
85+
pending_status=Grant.Status.pending,
8686
approved_type=Grant.ApprovedType.ticket_only,
8787
departure_country="IT",
8888
conference__grants_default_ticket_amount=100,
@@ -92,7 +92,7 @@ def test_resets_amounts_on_approved_type_change():
9292
conference__grants_default_travel_from_extra_eu_amount=500,
9393
)
9494

95-
grant.status = Grant.Status.approved
95+
grant.pending_status = Grant.Status.approved
9696
grant.save()
9797

9898
assert grant.ticket_amount == 100
@@ -111,7 +111,7 @@ def test_resets_amounts_on_approved_type_change():
111111

112112
def test_can_manually_change_amounts():
113113
grant = GrantFactory(
114-
status=Grant.Status.pending,
114+
pending_status=Grant.Status.pending,
115115
approved_type=Grant.ApprovedType.ticket_only,
116116
departure_country="IT",
117117
conference__grants_default_ticket_amount=100,
@@ -121,8 +121,8 @@ def test_can_manually_change_amounts():
121121
conference__grants_default_travel_from_extra_eu_amount=500,
122122
)
123123

124-
grant.status = Grant.Status.approved
125-
grant.save(update_fields=["status"])
124+
grant.pending_status = Grant.Status.approved
125+
grant.save(update_fields=["pending_status"])
126126

127127
assert grant.ticket_amount == 100
128128
assert grant.accommodation_amount == 0

0 commit comments

Comments
 (0)