Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "PAFs for review" table for paf approvers #3645

Merged
merged 8 commits into from
Dec 13, 2023
28 changes: 28 additions & 0 deletions hypha/apply/dashboard/services.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from django.db.models import Count

from hypha.apply.projects.models import PAFApprovals


def get_paf_for_review(user, is_paf_approval_sequential):
"""Return a list of paf approvals ready for user's review"""

paf_approvals = PAFApprovals.objects.annotate(
roles_count=Count("paf_reviewer_role__user_roles")
).filter(
roles_count=len(list(user.groups.all())),
approved=False,
)

for role in user.groups.all():
paf_approvals = paf_approvals.filter(paf_reviewer_role__user_roles__id=role.id)

if is_paf_approval_sequential:
all_matched_paf_approvals = list(paf_approvals)
for matched_paf_approval in all_matched_paf_approvals:
if matched_paf_approval.project.paf_approvals.filter(
paf_reviewer_role__sort_order__lt=matched_paf_approval.paf_reviewer_role.sort_order,
approved=False,
).exists():
paf_approvals = paf_approvals.exclude(id=matched_paf_approval.id)

return paf_approvals
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@
{% endadminbar %}

<div class="wrapper wrapper--large wrapper--inner-space-medium">
{% if paf_waiting_for_approval.count %}
{% include "dashboard/includes/paf_waiting_for_approval.html" with paf_waiting_for_approval=paf_waiting_for_approval %}
{% endif %}

{% if paf_waiting_for_assignment.count %}
<div id="paf_waiting_for_assignment" class="wrapper wrapper--bottom-space">
<h4 class="heading heading--normal">{% trans "PAF waiting for assignee" %}</h4>
{% render_table paf_waiting_for_assignment.table %}
{% if paf_for_review.count %}
<div id="paf_for_review" class="wrapper wrapper--bottom-space">
<h4 class="heading heading--normal">{% trans "PAFs for review" %}</h4>
{% render_table paf_for_review.table %}
</div>
{% endif %}

Expand Down
22 changes: 5 additions & 17 deletions hypha/apply/dashboard/templates/dashboard/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,6 @@
<div class="stat-block__view">{% trans "View" %}</div>
{% endif %}
</a>
{% if not paf_waiting_for_approval.count is None%}
<a href="#paf-awaiting-approval" class="stat-block__item border">
<p class="stat-block__number">{{ paf_waiting_for_approval.count }}</p>
<p class="stat-block__text">{% trans "Projects awaiting approval" %}</p>
{% if paf_waiting_for_approval.count %}
<div class="stat-block__view">{% trans "View" %}</div>
{% endif %}
</a>
{% endif %}
<a href="#active-invoices" class="stat-block__item border">
<p class="stat-block__number">{{ active_invoices.count }}</p>
<p class="stat-block__text">{% trans "Requests for invoices requiring your attention" %}</p>
Expand All @@ -72,14 +63,10 @@
{% include "funds/includes/round-block.html" with can_export=can_export closed_rounds=rounds.closed open_rounds=rounds.open title="Your rounds and labs" page_type='dashboard' %}
{% endif %}

{% if paf_waiting_for_approval.count %}
{% include "dashboard/includes/paf_waiting_for_approval.html" with paf_waiting_for_approval=paf_waiting_for_approval %}
{% endif %}

{% if paf_waiting_for_assignment.count %}
<div id="paf_waiting_for_assignment" class="wrapper wrapper--bottom-space">
<h4 class="heading heading--normal">{% trans "PAF waiting for assignee" %}</h4>
{% render_table paf_waiting_for_assignment.table %}
{% if paf_for_review.count %}
<div id="paf_for_review" class="wrapper wrapper--bottom-space">
<h4 class="heading heading--normal">{% trans "PAFs for review" %}</h4>
{% render_table paf_for_review.table %}
</div>
{% endif %}

Expand Down Expand Up @@ -125,6 +112,7 @@ <h4 class="heading heading--normal">{% trans "Active Invoices" %}</h4>
{% block extra_js %}
{{ my_reviewed.filterset.form.media.js }}
<script src="{% static 'js/apply/url-search-params.js' %}"></script>
<script src="{% static 'js/apply/all-submissions-table.js' %}"></script>
<script src="{% static 'js/apply/submission-filters.js' %}"></script>
<script src="{% static 'js/apply/tabs.js' %}"></script>
<script src="{% static 'js/apply/flag.js' %}"></script>
Expand Down
13 changes: 5 additions & 8 deletions hypha/apply/dashboard/templates/dashboard/finance_dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,13 @@ <h4 class="heading heading--normal heading--no-margin">{% trans 'Invoices' %} </

</div>

{% if paf_waiting_for_approval.count %}
{% include "dashboard/includes/paf_waiting_for_approval.html" with paf_waiting_for_approval=paf_waiting_for_approval %}
{% endif %}

{% if paf_waiting_for_assignment.count %}
<div id="paf_waiting_for_assignment" class="wrapper wrapper--bottom-space">
<h4 class="heading heading--normal">{% trans "PAF waiting for assignee" %}</h4>
{% render_table paf_waiting_for_assignment.table %}
{% if paf_for_review.count %}
<div id="paf_for_review" class="wrapper wrapper--bottom-space">
<h4 class="heading heading--normal">{% trans "PAFs for review" %}</h4>
{% render_table paf_for_review.table %}
</div>
{% endif %}

</div>
{% endblock %}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,6 @@ <h6 class="heading heading--no-margin heading--submission-meta"><span>{% trans "
</div>
{% endif %}

{% if paf_waiting_for_assignment.count %}
<div id="paf_waiting_for_assignment" class="wrapper wrapper--bottom-space">
<h2 class="text-xl mb-2">
{% trans "PAF waiting for assignee" %}
</h2>
{% render_table paf_waiting_for_assignment.table %}
</div>
{% endif %}

{% if my_inactive_submissions.data %}
<div class="wrapper wrapper--bottom-space">
<h2 class="text-xl mb-2">
Expand Down
Loading