Skip to content

Commit

Permalink
add base assessir dashbaord with default view, to be extended in futu…
Browse files Browse the repository at this point in the history
…re (#650)
  • Loading branch information
Adam-W1 committed Jul 5, 2024
1 parent 5f358d7 commit 785d921
Show file tree
Hide file tree
Showing 23 changed files with 473 additions and 380 deletions.
40 changes: 7 additions & 33 deletions app/blueprints/assessments/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@
from app.blueprints.authentication.validation import (
check_access_fund_short_name_round_sn,
)
from app.blueprints.authentication.validation import get_countries_from_roles
from app.blueprints.authentication.validation import has_access_to_fund
from app.blueprints.authentication.validation import has_devolved_authority_validation
from app.blueprints.scoring.helpers import get_scoring_class
from app.blueprints.services.aws import get_file_for_download_from_aws
from app.blueprints.services.data_services import (
Expand Down Expand Up @@ -123,12 +121,7 @@
from config.display_value_mappings import funding_types
from config.display_value_mappings import joint_application_options
from config.display_value_mappings import landing_filters
from config.display_value_mappings import search_params_cof
from config.display_value_mappings import search_params_cof_eoi
from config.display_value_mappings import search_params_cyp
from config.display_value_mappings import search_params_dpif
from config.display_value_mappings import search_params_hsra
from config.display_value_mappings import search_params_nstf
from config.display_value_mappings import search_params_default

assessment_bp = Blueprint(
"assessment_bp",
Expand Down Expand Up @@ -220,20 +213,8 @@ def landing():
)
@check_access_fund_short_name_round_sn
def fund_dashboard(fund_short_name: str, round_short_name: str):
if fund_short_name.upper() == "NSTF":
search_params = {**search_params_nstf}
elif fund_short_name.upper() == "COF":
search_params = {**search_params_cof}
elif fund_short_name.upper() == "CYP":
search_params = {**search_params_cyp}
elif fund_short_name.upper() == "DPIF":
search_params = {**search_params_dpif}
elif fund_short_name.upper() == "COF-EOI":
search_params = {**search_params_cof_eoi}
elif fund_short_name.upper() == "HSRA":
search_params = {**search_params_hsra}
else:
search_params = {**search_params_cof}

search_params = {**search_params_default}

fund = get_fund(
fund_short_name,
Expand All @@ -252,15 +233,6 @@ def fund_dashboard(fund_short_name: str, round_short_name: str):
return redirect("/assess/assessor_tool_dashboard/")
fund_id, round_id = fund.id, _round.id

countries = {"ALL"}
if has_devolved_authority_validation(fund_id=fund_id):
countries = get_countries_from_roles(fund.short_name)

search_params = {
**search_params,
"countries": ",".join(countries),
}

# matches the query parameters provided in the search and filter form
search_params, show_clear_filters = match_search_params(search_params, request.args)

Expand All @@ -271,7 +243,7 @@ def fund_dashboard(fund_short_name: str, round_short_name: str):
)

# The first call is to get the location data such as country, region and local_authority
# from all the existing applications (i.e withou search parameters as we don't want to filter
# from all the existing applications (i.e without search parameters as we don't want to filter
# the stats at all). see https://dluhcdigital.atlassian.net/browse/FS-3249
future_all_applications_metadata = thread_executor.submit(
get_application_overviews, fund_id, round_id, ""
Expand Down Expand Up @@ -306,7 +278,8 @@ def fund_dashboard(fund_short_name: str, round_short_name: str):

# this is only used for querying applications, so remove it from the search params,
# so it's not reflected on the user interface
del search_params["countries"]
if "countries" in search_params:
del search_params["countries"]

round_details = {
"assessment_deadline": _round.assessment_deadline,
Expand Down Expand Up @@ -400,6 +373,7 @@ def get_sorted_application_overviews(application_overviews, column, reverse=Fals
local_authorities=all_application_locations._local_authorities,
migration_banner_enabled=Config.MIGRATION_BANNER_ENABLED,
dpi_filters=dpi_filters,
users=["All"], # TODO: Add users api call
)


Expand Down
159 changes: 59 additions & 100 deletions app/blueprints/assessments/templates/assessor_dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
{%- from 'govuk_frontend_jinja/components/inset-text/macro.html' import govukInsetText -%}
{%- from "govuk_frontend_jinja/components/button/macro.html" import govukButton -%}
{%- from 'govuk_frontend_jinja/components/back-link/macro.html' import govukBackLink -%}
{% import "macros/application_overviews_table_cyp.html" as application_overviews_table_cyp -%}
{% import "macros/application_overviews_table_nstf.html" as application_overviews_table_nstf -%}
{% import "macros/application_overviews_table_cof.html" as application_overviews_table_cof -%}
{% import "macros/application_overviews_table_cof_eoi.html" as application_overviews_table_cof_eoi -%}
{% import "macros/application_overviews_table_dpif.html" as application_overviews_table_dpif -%}
{% import "macros/application_overviews_table_hsra.html" as application_overviews_table_hsra -%}
{%- from 'govuk_frontend_jinja/components/tabs/macro.html' import govukTabs -%}
{% import "macros/application_overviews_table_all.html" as application_overviews_table -%}
{% from "macros/banner_summary.html" import banner_summary %}
{% from "macros/logout_partial.html" import logout_partial %}
{% from "macros/migration_banner.html" import migration_banner %}
Expand Down Expand Up @@ -75,116 +71,79 @@ <h2 class="govuk-heading-l fsd-banner-content"> {% if is_active_status %}All act
{% block content %}
{# CLOSE THE GOVUK-WIDTH-CONTAINER AND OPEN A WIDER CONTAINER FOR THE TABLE VIEW #}


<div class="govuk-grid-row">
{% if migration_banner_enabled %}
{{ migration_banner() }}
{% endif %}
<section class="govuk-width-container govuk-grid-column-full">
{% if round_details.fund_short_name.upper() == 'CYP' %}
{{ application_overviews_table_cyp.render(
application_overviews,
round_details,
query_params,
cohort,
assessment_statuses,
countries,
regions,
local_authorities,
show_clear_filters,
sort_column,
sort_order,
tag_option_groups,
tags,
tagging_purpose_config
) }}
{% elif round_details.fund_short_name.upper() == 'NSTF' %}
{{ application_overviews_table_nstf.render(
application_overviews,
round_details,
query_params,
funding_types,
assessment_statuses,
countries,
regions,
local_authorities,
show_clear_filters,
sort_column,
sort_order,
tag_option_groups,
tags,
tagging_purpose_config
) }}
{% elif round_details.fund_short_name.upper() == "COF" %}
{{ application_overviews_table_cof.render(
<section id="application-overview" class="govuk-width-container govuk-grid-column-full">
{% set applicationsOverviewHtml %}
<header class="govuk-body ">
<!--
TODO: Add later
<section class="govuk-phase-banner govuk-grid-row">
<span id="empty-positioning-child" class="govuk-grid-column-two-thirds empty-positioning-child">&nbsp;</span>
<span class="govuk-grid-column-one-third">
<a href="." class="govuk-link govuk-!-margin-right-4">
Edit table columns</a>
<a href="." class="govuk-link">
Assign assessments
</a>
</span>
</section>
-->
<h1 class="govuk-heading-l">All applications</h1>
</header>
{{ application_overviews_table.render(
application_overviews,
round_details,
query_params,
asset_types,
assessment_statuses,
countries,
regions,
local_authorities,
show_clear_filters,
sort_column,
sort_order,
tag_option_groups,
tags,
tagging_purpose_config
) }}
{% elif round_details.fund_short_name.upper() == "DPIF" %}
{{ application_overviews_table_dpif.render(
application_overviews,
round_details,
query_params,
asset_types,
assessment_statuses,
countries,
regions,
local_authorities,
show_clear_filters,
sort_column,
sort_order,
tag_option_groups,
tags,
tagging_purpose_config,
dpi_filters
users
) }}
{% elif round_details.fund_short_name.upper() == "COF-EOI" %}
{{ application_overviews_table_cof_eoi.render(
application_overviews,
round_details,
query_params,
asset_types,
assessment_statuses,
countries,
regions,
local_authorities,
show_clear_filters,
sort_column,
sort_order,
tag_option_groups,
tags,
tagging_purpose_config
) }}
{% elif round_details.fund_short_name.upper() == "HSRA" %}
{{ application_overviews_table_hsra.render(
application_overviews,
round_details,
query_params,
asset_types,
assessment_statuses,
joint_application_options,
countries,
regions,
local_authorities,
show_clear_filters,
sort_column,
sort_order,
tag_option_groups,
tags,
tagging_purpose_config
) }}
{% endif %}
{% endset -%}

{{ govukTabs({
"items": [
{
"label": "All applications",
"id": "all-applications",
"panel": {
"html": applicationsOverviewHtml
}
},
]
}) }}
<!--
TODO: Add to tabs later
[{
"label": "Reporting to you",
"id": "reporting-to-you",
"panel": {
"html": "TBC"
}
},
{
"label": "Assigned to you",
"id": "past-week",
"panel": {
"html": "TBC"
}
},
{
"label": "Scoring",
"id": "scoring",
"panel": {
"html": "TBC"
}
}] -->
</section>
</div>
{% endblock content %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{% from "govuk_frontend_jinja/components/input/macro.html" import govukInput %}
{% from "macros/sortable_table_header.html" import sortable_table_header %}
{% from "macros/filter_options_all.html" import filter_options %}
{% from "macros/application_status_column.html" import application_status_column %}
{% from "macros/tags_table.html" import tags_table %}

{% macro render(application_overviews, round_details, query_params, asset_types,
assessment_statuses, show_clear_filters,
sort_column, sort_order, tag_option_groups, tags, tagging_purpose_config, users) -%}
<nav class="search-bar-flex-container">
<form method="get" class="govuk-!-width-full">
{{ filter_options(
query_params,
'Search reference or project name',
assessment_statuses,
round_details,
show_clear_filters,
tag_option_groups,
users
) }}
</form>
</nav>

{% if not application_overviews %}
<div role="status" aria-live="assertive" class="govuk-!-margin-top-4">
<p class="govuk-body" autofocus>
<strong>No matching results.</strong>
</p>
<p class="govuk-body">Improve your results by:</p>
<ul class="govuk-list govuk-list--bullet">
<li>removing filters</li>
<li>double-checking your spelling</li>
</ul>
</div>
{% else %}
<table class="govuk-table govuk-!-margin-top-4" id="application_overviews_table">
<thead class="govuk-table__head">
<tr class="govuk-table__row">
<th scope="col" class="govuk-table__header">
Reference
</th>
{{ sortable_table_header('project_name', 'Project name', sort_order, sort_column, round_details, query_params) }}
{{ sortable_table_header('funding_requested', 'Funding requested', sort_order, sort_column, round_details,
query_params) }}
{{ sortable_table_header('asset_type', 'Asset type', sort_order, sort_column, round_details, query_params) }}
{{ sortable_table_header('location', 'Location', sort_order, sort_column, round_details, query_params) }}
{{ sortable_table_header('tags', 'Tags', sort_order, sort_column, round_details, query_params) }}
{% if g.access_controller.has_any_assessor_role %}
{{ sortable_table_header('status', 'Status', sort_order, sort_column, round_details, query_params) }}
{% endif %}
{{ sortable_table_header('assigned_to', 'Assigned to', sort_order, sort_column, round_details, query_params) }}
{{ sortable_table_header('last_action', 'Last action', sort_order, sort_column, round_details, query_params) }}
{{ sortable_table_header('time_since_last_action', 'Time since last action', sort_order, sort_column,
round_details, query_params) }}
</tr>
</thead>
<tbody class="govuk-table__body">
{% for overview in application_overviews %}
<tr class="govuk-table__row">

<td class="govuk-table__cell">{{ overview.short_id[-6:] }}</td>
<td class="govuk-table__cell"><a class="govuk-link" data-qa="project_name"
href="{{ url_for('assessment_bp.application',application_id=overview.application_id) }}">{{
overview.project_name }}</a></td>
<td class="govuk-table__cell">£{{ "{:,.2f}".format(overview.funding_amount_requested|int|round) }}</td>
<td class="govuk-table__cell">{{ asset_types[overview.asset_type] }}</td>
<td class="govuk-table__cell">{{ overview.location_json_blob.get('country') or "Not found" }}</td>
{{ tags_table(tags[overview.application_id], tagging_purpose_config, query_params.show_tags == "ON") }}
{% if g.access_controller.has_any_assessor_role %}
{{ application_status_column(overview.application_status, overview.get("progress", ""), assessment_statuses) }}
{% endif %}
<!-- TODO: requires 'assigned to' API -->
<td class="govuk-table__cell">-</td>
<td class="govuk-table__cell">-</td>
<td class="govuk-table__cell">-</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{%- endmacro %}
Loading

0 comments on commit 785d921

Please sign in to comment.