Skip to content

Commit ed56b85

Browse files
committed
Updated ordering of invites, limit no of coapplicants
1 parent 20f4695 commit ed56b85

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

hypha/apply/funds/templates/funds/includes/co-applicant-block.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class="flex items-center py-1 px-2 font-bold rounded-sm transition-colors hover:bg-gray-100 text-dark-blue -me-2"
88
hx-get="{% url 'apply:submissions:invite_co_applicant' pk=object.id %}"
99
hx-target="#htmx-modal"
10-
{% if object.co_applicant_invites.count >= 100 %}disabled{% endif %}
10+
{% if object.co_applicant_invites.count >= 20 %}disabled{% endif %}
1111
role="button"
1212
aria-label="{% trans "Invite CoApplicant" %}"
1313
>
@@ -16,7 +16,7 @@
1616
</button>
1717
</div>
1818
<div class="flex flex-col gap-2 justify-between">
19-
{% for invite in object.co_applicant_invites.all %}
19+
{% for invite in co_applicants %}
2020

2121
<div>
2222
<a

hypha/apply/funds/views/co_applicants.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from django.contrib.auth import login
77
from django.contrib.auth.decorators import login_required
88
from django.contrib.auth.models import Group
9+
from django.db.models import Case, IntegerField, Value, When
910
from django.http import HttpResponse, HttpResponseRedirect
1011
from django.shortcuts import get_object_or_404, render
1112
from django.urls import reverse_lazy
@@ -304,7 +305,19 @@ def list_coapplicant_invites(request, pk):
304305
has_permission(
305306
"co_applicants_view", user=request.user, object=submission, raise_exception=True
306307
)
307-
co_applicant_invites = CoApplicantInvite.objects.filter(submission=submission)
308+
status_order = Case(
309+
When(status="accepted", then=Value(0)),
310+
When(status="pending", then=Value(1)),
311+
When(status="rejected", then=Value(2)),
312+
When(status="expired", then=Value(3)),
313+
default=Value(4),
314+
output_field=IntegerField(),
315+
)
316+
co_applicant_invites = (
317+
CoApplicantInvite.objects.filter(submission=submission)
318+
.annotate(status_priority=status_order)
319+
.order_by("status_priority", "-responded_on", "-created_at")
320+
)
308321
return render(
309322
request,
310323
"funds/includes/co-applicant-block.html",

0 commit comments

Comments
 (0)