Skip to content

Commit d04086a

Browse files
Add invitation letter request flag to Grant admin
Display a boolean flag in the Grant admin change list view that indicates whether a request for an invitation letter has been submitted. This helps administrators quickly identify which grants have associated invitation letter requests. Changes: - Added has_invitation_letter_request() method to Grant model - Added has_invitation_letter_request_flag display method to GrantAdmin - Added flag to admin list_display with 📧 emoji icon Fixes #4384 Co-authored-by: Marco Acierno <[email protected]>
1 parent f8a87d3 commit d04086a

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

backend/grants/admin.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ class GrantAdmin(ExportMixin, ConferencePermissionMixin, admin.ModelAdmin):
402402
"country",
403403
"is_proposed_speaker",
404404
"is_confirmed_speaker",
405+
"has_invitation_letter_request_flag",
405406
"emoji_gender",
406407
"conference",
407408
"status",
@@ -584,6 +585,11 @@ def user_has_ticket(self, obj: Grant) -> bool:
584585
def has_voucher(self, obj: Grant) -> bool:
585586
return obj.has_voucher
586587

588+
@admin.display(description="📧", boolean=True)
589+
def has_invitation_letter_request_flag(self, obj: Grant) -> bool:
590+
"""Display flag indicating if user has submitted an invitation letter request"""
591+
return obj.has_invitation_letter_request()
592+
587593
def get_queryset(self, request):
588594
qs = (
589595
super()

backend/grants/models.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,17 @@ def has_approved_accommodation(self):
333333
def current_or_pending_status(self):
334334
return self.pending_status or self.status
335335

336+
def has_invitation_letter_request(self):
337+
"""Check if user has submitted an invitation letter request for this conference"""
338+
if not self.user_id:
339+
return False
340+
341+
from visa.models import InvitationLetterRequest
342+
return InvitationLetterRequest.objects.filter(
343+
conference=self.conference,
344+
requester=self.user
345+
).exists()
346+
336347

337348
class GrantConfirmPendingStatusProxy(Grant):
338349
class Meta:

0 commit comments

Comments
 (0)