Skip to content

Commit 6a859d7

Browse files
committed
Fixes
1 parent 6c1ae56 commit 6a859d7

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

backend/custom_admin/admin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def wrapper(modeladmin, request, queryset):
6060
def confirm_pending_status(modeladmin, request, queryset):
6161
queryset.update(
6262
status=F("pending_status"),
63+
pending_status=None,
6364
)
6465

6566

backend/grants/models.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,7 @@ def save(self, *args, **kwargs):
246246
self._original_status = self.status
247247

248248
def _calculate_grant_amounts(self):
249-
# Use pending_status if set, otherwise use current status
250-
effective_status = self.pending_status if self.pending_status is not None else self.status
251-
if effective_status != Grant.Status.approved:
249+
if self.effective_status != Grant.Status.approved:
252250
return
253251

254252
if (
@@ -331,6 +329,11 @@ def has_approved_accommodation(self):
331329
or self.approved_type == Grant.ApprovedType.ticket_travel_accommodation
332330
)
333331

332+
@property
333+
def effective_status(self):
334+
# If the grant is pending, use the pending status
335+
return self.pending_status if self.pending_status is not None else self.status
336+
334337

335338
class GrantConfirmPendingStatusProxy(Grant):
336339
class Meta:

backend/grants/tests/test_admin.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,11 @@ def test_confirm_pending_status_action(rf):
485485
assert grant_1.status == Grant.Status.confirmed
486486
assert grant_2.status == Grant.Status.waiting_list
487487
assert grant_3.status == Grant.Status.waiting_list_maybe
488+
489+
assert grant_1.pending_status is None
490+
assert grant_2.pending_status is None
491+
assert grant_3.pending_status is None
492+
488493
# Left out from the action
489494
assert grant_4.status == Grant.Status.waiting_list_maybe
490495

backend/reviews/templates/grants-recap.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@
254254
updateBottomBarUI();
255255
});
256256

257-
waitinglistInput.addEventListener("change", () => {
257+
waitinglistmaybeInput.addEventListener("change", () => {
258258
grantData.status = "waiting_list_maybe";
259259
updateBottomBarUI();
260260
});
@@ -469,13 +469,13 @@ <h3>
469469
<script>
470470
grantsById[{{item.id}}] = {
471471
id: {{item.id}},
472-
status: "{{ item.pending_status }}",
473-
originalStatus: "{{ item.pending_status }}",
472+
status: "{{ item.effective_status }}",
473+
originalStatus: "{{ item.effective_status }}",
474474
numOfVotes: {{item.userreview_set.count}},
475475
};
476476
</script>
477477
<tr
478-
data-original-status="{{ item.pending_status }}"
478+
data-original-status="{{ item.effective_status }}"
479479
data-original-approved-type="{{ item.approved_type }}"
480480
class="grant-item"
481481
id="grant-{{ item.id }}"
@@ -612,7 +612,7 @@ <h3>
612612
{% for status in all_review_statuses %}
613613
<li>
614614
<label>
615-
<input {% if item.pending_status == status.0 %}checked{% endif %}
615+
<input {% if item.effective_status == status.0 %}checked{% endif %}
616616
type="radio"
617617
class="status-decision-radio"
618618
name="decision-{{item.id}}"
@@ -641,7 +641,7 @@ <h3>
641641
{% if perms.reviews.decision_reviewsession %}
642642
<ul
643643
data-item-id="{{ item.id }}"
644-
class="approved-type-choices {% if item.pending_status != 'approved' %}hidden{% endif %}"
644+
class="approved-type-choices {% if item.effective_status != 'approved' %}hidden{% endif %}"
645645
>
646646
{% for approved_type in all_approved_types %}
647647
<li>

0 commit comments

Comments
 (0)