added user request details below creator in django admin

This commit is contained in:
David Kennedy 2024-04-03 06:49:29 -04:00
parent e4a8773e56
commit cf946004c0
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B
3 changed files with 34 additions and 0 deletions

View file

@ -67,6 +67,24 @@ class User(AbstractUser):
def is_restricted(self):
return self.status == self.RESTRICTED
def get_approved_domains_count(self):
"""Return count of approved domains"""
allowed_states = ['unknown', 'dns needed', 'ready', 'on hold']
approved_domains_count = self.domains.filter(state__in=allowed_states).count()
return approved_domains_count
def get_active_requests_count(self):
"""Return count of active requests"""
allowed_states = ['submitted', 'in review', 'action needed']
active_requests_count = self.domain_requests_created.filter(status__in=allowed_states).count()
return active_requests_count
def get_rejected_requests_count(self):
"""Return count of rejected or ineligible requests"""
allowed_states = ['rejected', 'ineligible']
rejected_requests_count = self.domain_requests_created.filter(status__in=allowed_states).count()
return rejected_requests_count
@classmethod
def needs_identity_verification(cls, email, uuid):
"""A method used by our oidc classes to test whether a user needs email/uuid verification

View file

@ -65,6 +65,10 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html)
<label aria-label="Creator contact details"></label>
{% include "django/admin/includes/contact_detail_list.html" with user=original.creator no_title_top_padding=field.is_readonly %}
</div>
<div class="flex-container">
<label aria-label="User summary details"></label>
{% include "django/admin/includes/user_detail_list.html" with user=original.creator no_title_top_padding=field.is_readonly %}
</div>
{% elif field.field.name == "submitter" %}
<div class="flex-container">
<label aria-label="Submitter contact details"></label>

View file

@ -0,0 +1,12 @@
{% load i18n static %}
<address class="{% if no_title_top_padding %}margin-top-neg-1__detail-list{% endif %} dja-address-contact-list">
{# Approved domains #}
Approved domains: {{ user.get_approved_domains_count }}<br>
{# Active requests #}
Active requests: {{ user.get_active_requests_count }}<br>
{# Rejected or ineligible requests #}
Rejected or ineligible: {{ user.get_rejected_requests_count }}<br>
</address>