Skip to content

Commit 288dd44

Browse files
committed
Grant/Proposal pending status
1 parent fdfe60d commit 288dd44

File tree

5 files changed

+85
-41
lines changed

5 files changed

+85
-41
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Generated by Django 5.1.4 on 2025-01-20 00:57
2+
3+
from django.db import migrations, models
4+
5+
def copy_grant_status_to_pending_status(apps, schema_editor):
6+
Grant = apps.get_model('grants', 'Grant')
7+
for grant in Grant.objects.all():
8+
grant.pending_status = grant.status
9+
grant.save(update_fields=['pending_status'])
10+
11+
12+
class Migration(migrations.Migration):
13+
14+
dependencies = [
15+
('grants', '0025_alter_grant_approved_type'),
16+
]
17+
18+
operations = [
19+
migrations.AddField(
20+
model_name='grant',
21+
name='pending_status',
22+
field=models.CharField(blank=True, choices=[('pending', 'Pending'), ('rejected', 'Rejected'), ('approved', 'Approved'), ('waiting_list', 'Waiting List'), ('waiting_list_maybe', 'Waiting List, Maybe'), ('waiting_for_confirmation', 'Waiting for confirmation'), ('refused', 'Refused'), ('confirmed', 'Confirmed'), ('did_not_attend', 'Did Not Attend')], default='pending', max_length=30, verbose_name='pending status'),
23+
),
24+
migrations.RunPython(copy_grant_status_to_pending_status, reverse_code=migrations.RunPython.noop),
25+
]

backend/grants/models.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,13 @@ class ApprovedType(models.TextChoices):
145145
status = models.CharField(
146146
_("status"), choices=Status.choices, max_length=30, default=Status.pending
147147
)
148+
pending_status = models.CharField(
149+
_("pending status"),
150+
choices=Status.choices,
151+
max_length=30,
152+
default=Status.pending,
153+
blank=True,
154+
)
148155
approved_type = models.CharField(
149156
verbose_name=_("approved type"),
150157
choices=ApprovedType.choices,

backend/grants/summary.py

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def calculate(self, conference_id):
2727
filtered_grants = Grant.objects.for_conference(conference)
2828

2929
grants_by_country = filtered_grants.values(
30-
"departure_country", "status"
30+
"departure_country", "pending_status"
3131
).annotate(total=Count("id"))
3232

3333
(
@@ -110,30 +110,30 @@ def _aggregate_data_by_country(self, grants_by_country, statuses):
110110
if key not in summary:
111111
summary[key] = {status[0]: 0 for status in statuses}
112112

113-
summary[key][data["status"]] += data["total"]
114-
status_totals[data["status"]] += data["total"]
113+
summary[key][data["pending_status"]] += data["total"]
114+
status_totals[data["pending_status"]] += data["total"]
115115

116116
# Update continent totals
117117
if continent not in totals_per_continent:
118118
totals_per_continent[continent] = {status[0]: 0 for status in statuses}
119-
totals_per_continent[continent][data["status"]] += data["total"]
119+
totals_per_continent[continent][data["pending_status"]] += data["total"]
120120

121121
return summary, status_totals, totals_per_continent
122122

123123
def _aggregate_data_by_country_type(self, filtered_grants, statuses):
124124
"""
125125
Aggregates grant data by country type and status.
126126
"""
127-
country_type_data = filtered_grants.values("country_type", "status").annotate(
128-
total=Count("id")
129-
)
127+
country_type_data = filtered_grants.values(
128+
"country_type", "pending_status"
129+
).annotate(total=Count("id"))
130130
country_type_summary = defaultdict(
131131
lambda: {status[0]: 0 for status in statuses}
132132
)
133133

134134
for data in country_type_data:
135135
country_type = data["country_type"]
136-
status = data["status"]
136+
status = data["pending_status"]
137137
total = data["total"]
138138
country_type_summary[country_type][status] += total
139139

@@ -143,13 +143,14 @@ def _aggregate_data_by_gender(self, filtered_grants, statuses):
143143
"""
144144
Aggregates grant data by gender and status.
145145
"""
146-
gender_data = filtered_grants.values("gender", "status").annotate(
146+
gender_data = filtered_grants.values("gender", "pending_status").annotate(
147147
total=Count("id")
148148
)
149149
gender_summary = defaultdict(lambda: {status[0]: 0 for status in statuses})
150+
150151
for data in gender_data:
151152
gender = data["gender"] if data["gender"] else ""
152-
status = data["status"]
153+
status = data["pending_status"]
153154
total = data["total"]
154155
gender_summary[gender][status] += total
155156

@@ -159,14 +160,14 @@ def _aggregate_financial_data_by_status(self, filtered_grants, statuses):
159160
"""
160161
Aggregates financial data (total amounts) by grant status.
161162
"""
162-
financial_data = filtered_grants.values("status").annotate(
163+
financial_data = filtered_grants.values("pending_status").annotate(
163164
total_amount_sum=Sum("total_amount")
164165
)
165166
financial_summary = {status[0]: 0 for status in statuses}
166167
overall_total = 0
167168

168169
for data in financial_data:
169-
status = data["status"]
170+
status = data["pending_status"]
170171
total_amount = data["total_amount_sum"] or 0
171172
financial_summary[status] += total_amount
172173
if status in self.BUDGET_STATUSES:
@@ -178,14 +179,14 @@ def _aggregate_data_by_grant_type(self, filtered_grants, statuses):
178179
"""
179180
Aggregates grant data by grant_type and status.
180181
"""
181-
grant_type_data = filtered_grants.values("grant_type", "status").annotate(
182-
total=Count("id")
183-
)
182+
grant_type_data = filtered_grants.values(
183+
"grant_type", "pending_status"
184+
).annotate(total=Count("id"))
184185
grant_type_summary = defaultdict(lambda: {status[0]: 0 for status in statuses})
185186

186187
for data in grant_type_data:
187188
grant_types = data["grant_type"]
188-
status = data["status"]
189+
status = data["pending_status"]
189190
total = data["total"]
190191
for grant_type in grant_types:
191192
grant_type_summary[grant_type][status] += total
@@ -213,13 +214,13 @@ def _aggregate_data_by_speaker_status(self, filtered_grants, statuses):
213214

214215
proposed_speaker_data = (
215216
filtered_grants.filter(is_proposed_speaker=True)
216-
.values("status")
217+
.values("pending_status")
217218
.annotate(total=Count("id"))
218219
)
219220

220221
confirmed_speaker_data = (
221222
filtered_grants.filter(is_confirmed_speaker=True)
222-
.values("status")
223+
.values("pending_status")
223224
.annotate(total=Count("id"))
224225
)
225226

@@ -228,12 +229,12 @@ def _aggregate_data_by_speaker_status(self, filtered_grants, statuses):
228229
)
229230

230231
for data in proposed_speaker_data:
231-
status = data["status"]
232+
status = data["pending_status"]
232233
total = data["total"]
233234
speaker_status_summary["proposed_speaker"][status] += total
234235

235236
for data in confirmed_speaker_data:
236-
status = data["status"]
237+
status = data["pending_status"]
237238
total = data["total"]
238239
speaker_status_summary["confirmed_speaker"][status] += total
239240

@@ -243,16 +244,16 @@ def _aggregate_data_by_approved_type(self, filtered_grants, statuses):
243244
"""
244245
Aggregates grant data by approved type and status.
245246
"""
246-
approved_type_data = filtered_grants.values("approved_type", "status").annotate(
247-
total=Count("id")
248-
)
247+
approved_type_data = filtered_grants.values(
248+
"approved_type", "pending_status"
249+
).annotate(total=Count("id"))
249250
approved_type_summary = defaultdict(
250251
lambda: {status[0]: 0 for status in statuses}
251252
)
252253

253254
for data in approved_type_data:
254255
approved_type = data["approved_type"]
255-
status = data["status"]
256+
status = data["pending_status"]
256257
total = data["total"]
257258
approved_type_summary[approved_type][status] += total
258259

@@ -271,11 +272,11 @@ def _aggregate_data_by_requested_needs_summary(self, filtered_grants, statuses):
271272
for field in requested_needs_summary.keys():
272273
field_data = (
273274
filtered_grants.filter(**{field: True})
274-
.values("status")
275+
.values("pending_status")
275276
.annotate(total=Count("id"))
276277
)
277278
for data in field_data:
278-
status = data["status"]
279+
status = data["pending_status"]
279280
total = data["total"]
280281
requested_needs_summary[field][status] += total
281282

@@ -285,14 +286,14 @@ def _aggregate_data_by_occupation(self, filtered_grants, statuses):
285286
"""
286287
Aggregates grant data by occupation and status.
287288
"""
288-
occupation_data = filtered_grants.values("occupation", "status").annotate(
289-
total=Count("id")
290-
)
289+
occupation_data = filtered_grants.values(
290+
"occupation", "pending_status"
291+
).annotate(total=Count("id"))
291292
occupation_summary = defaultdict(lambda: {status[0]: 0 for status in statuses})
292293

293294
for data in occupation_data:
294295
occupation = data["occupation"]
295-
status = data["status"]
296+
status = data["pending_status"]
296297
total = data["total"]
297298
occupation_summary[occupation][status] += total
298299

backend/reviews/admin.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,15 +282,15 @@ def _review_grants_recap_view(self, request, review_session):
282282

283283
approved_type = approved_type_decisions.get(grant.id, "")
284284

285-
grant.status = decision
285+
grant.pending_status = decision
286286
grant.approved_type = (
287287
approved_type if decision == Grant.Status.approved else None
288288
)
289289

290290
for grant in grants:
291291
# save each to make sure we re-calculate the grants amounts
292292
# TODO: move the amount calculation in a separate function maybe?
293-
grant.save(update_fields=["status", "approved_type"])
293+
grant.save(update_fields=["pending_status", "approved_type"])
294294

295295
messages.success(
296296
request, "Decisions saved. Check the Grants Summary for more info."
@@ -406,11 +406,11 @@ def _review_proposals_recap_view(self, request, review_session):
406406

407407
for proposal in proposals:
408408
decision = decisions[proposal.id]
409-
proposal.status = decision
409+
proposal.pending_status = decision
410410

411411
Submission.objects.bulk_update(
412412
proposals,
413-
fields=["status"],
413+
fields=["pending_status"],
414414
)
415415

416416
return redirect(

backend/reviews/templates/grants-recap.html

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,12 @@ <h3>
444444
</div>
445445
<div class="clear"></div>
446446
</th>
447+
<th scope="col">
448+
<div class="text">
449+
<span>Pending Status</span>
450+
</div>
451+
<div class="clear"></div>
452+
</th>
447453
<th scope="col">
448454
<div class="text">
449455
<span>Decision</span>
@@ -463,13 +469,13 @@ <h3>
463469
<script>
464470
grantsById[{{item.id}}] = {
465471
id: {{item.id}},
466-
status: "{{ item.status }}",
467-
originalStatus: "{{ item.status }}",
472+
status: "{{ item.pending_status }}",
473+
originalStatus: "{{ item.pending_status }}",
468474
numOfVotes: {{item.userreview_set.count}},
469475
};
470476
</script>
471477
<tr
472-
data-original-status="{{ item.status }}"
478+
data-original-status="{{ item.pending_status }}"
473479
data-original-approved-type="{{ item.approved_type }}"
474480
class="grant-item"
475481
id="grant-{{ item.id }}"
@@ -593,15 +599,20 @@ <h3>
593599
<td>
594600
{{ item.get_status_display }}
595601
<br />
596-
{% if item.approved_type %}({{ item.get_approved_type_display }}){% endif %}
602+
{% if item.status == "approved" and item.approved_type %}({{ item.get_approved_type_display }}){% endif %}
603+
</td>
604+
<td>
605+
{{ item.get_pending_status_display }}
606+
<br />
607+
{% if item.pending_status == "approved" and item.approved_type %}({{ item.get_approved_type_display }}){% endif %}
597608
</td>
598609
<td>
599610
{% if perms.reviews.decision_reviewsession %}
600611
<ul class="status-choices">
601612
{% for status in all_review_statuses %}
602613
<li>
603614
<label>
604-
<input {% if item.status == status.0 %}checked{% endif %}
615+
<input {% if item.pending_status == status.0 %}checked{% endif %}
605616
type="radio"
606617
class="status-decision-radio"
607618
name="decision-{{item.id}}"
@@ -630,7 +641,7 @@ <h3>
630641
{% if perms.reviews.decision_reviewsession %}
631642
<ul
632643
data-item-id="{{ item.id }}"
633-
class="approved-type-choices {% if item.status != 'approved' %}hidden{% endif %}"
644+
class="approved-type-choices {% if item.pending_status != 'approved' %}hidden{% endif %}"
634645
>
635646
{% for approved_type in all_approved_types %}
636647
<li>
@@ -673,7 +684,7 @@ <h3>
673684
<table>
674685
<tbody>
675686
<tr>
676-
<td><h2>Pending status</h2></td>
687+
<td><h2>Changes</h2></td>
677688
{% for status in all_statuses %}
678689
<td>
679690
{% if status in all_review_statuses %}

0 commit comments

Comments
 (0)