-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a dashboard of pending requests.
- Loading branch information
Showing
3 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import django.db.models | ||
import django.views.generic | ||
|
||
from .. import models as js_models | ||
|
||
|
||
class AdminDashboardView(django.views.generic.base.TemplateView): | ||
template_name = "admin/jasmin_services/dashboard.html" | ||
|
||
def get_context_data(self, **kwargs): | ||
context = super().get_context_data(**kwargs) | ||
|
||
roles_with_pending_requests = ( | ||
js_models.Role.objects.all() | ||
.annotate( | ||
num_pending=django.db.models.Count( | ||
"access", | ||
filter=django.db.models.Q( | ||
access__request__state=js_models.RequestState.PENDING | ||
), | ||
) | ||
) | ||
.filter(num_pending__gt=0) | ||
) | ||
ceda_managed_pending = roles_with_pending_requests # .filter(service__ceda_managed=True) # TODO: Reinstate this check. | ||
longer_than_a_week_pending = roles_with_pending_requests # TODO: write this check. | ||
no_approver_pending = roles_with_pending_requests # TODO: write this check. | ||
|
||
extra_context = { | ||
"ceda_managed_pending": ceda_managed_pending, | ||
"longer_than_a_week_pending": longer_than_a_week_pending, | ||
"no_approver_pending": no_approver_pending, | ||
} | ||
return context | extra_context |
31 changes: 31 additions & 0 deletions
31
jasmin_services/templates/admin/jasmin_services/dashboard.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{% extends "admin/base_site.html" %} | ||
{% load i18n static %} | ||
|
||
{% block extrastyle %}{{ block.super }}<link rel="stylesheet" href="{% static "admin/css/dashboard.css" %}">{% endblock %} | ||
|
||
{% block coltype %}colMS{% endblock %} | ||
|
||
{% block bodyclass %}{{ block.super }} dashboard{% endblock %} | ||
|
||
{% block nav-breadcrumbs %}{% endblock %} | ||
|
||
{% block nav-sidebar %}{% endblock %} | ||
|
||
{% block content %} | ||
<table> | ||
<tr> | ||
<th>Service</th> | ||
<th>Role</th> | ||
<th>Number of Pending Requests</th> | ||
{% for role in ceda_managed_pending %} | ||
<tr> | ||
<td><a href="{% url 'jasmin_services:service_details' category=role.service.category.name service=role.service.name %}">{{role.service.category.name}}/{{ role.service.name }}</a></td> | ||
<td>{{ role.name }}</td> | ||
<td>{{ role.num_pending }}</td> | ||
</tr> | ||
{% endfor %} | ||
</table> | ||
{% endblock %} | ||
|
||
{% block sidebar %} | ||
{% endblock %} |