Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
add dashboard for cyp
Browse files Browse the repository at this point in the history
  • Loading branch information
RamuniN committed Oct 12, 2023
1 parent 90a0998 commit d355319
Show file tree
Hide file tree
Showing 7 changed files with 177 additions and 3 deletions.
9 changes: 8 additions & 1 deletion app/blueprints/assessments/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@
from config import Config
from config.display_value_mappings import assessment_statuses
from config.display_value_mappings import asset_types
from config.display_value_mappings import cohort
from config.display_value_mappings import funding_types
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_cyp
from config.display_value_mappings import search_params_nstf
from flask import abort
from flask import Blueprint
Expand Down Expand Up @@ -195,8 +197,12 @@ def landing():
def fund_dashboard(fund_short_name: str, round_short_name: str):
if fund_short_name.upper() == "NSTF":
search_params = {**search_params_nstf}
else:
elif fund_short_name.upper() == "COF":
search_params = {**search_params_cof}
elif fund_short_name.upper() == "CYP":
search_params = {**search_params_cyp}
else:
search_params = {}

fund = get_fund(
fund_short_name,
Expand Down Expand Up @@ -317,6 +323,7 @@ def get_sorted_application_overviews(
query_params=search_params,
asset_types=asset_types,
funding_types=funding_types,
cohort=cohort,
assessment_statuses=assessment_statuses,
show_clear_filters=show_clear_filters,
stats=stats,
Expand Down
20 changes: 19 additions & 1 deletion app/blueprints/assessments/templates/assessor_dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{%- 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 -%}
{% from "macros/banner_summary.html" import banner_summary %}
Expand Down Expand Up @@ -61,7 +62,24 @@ <h2 class="govuk-heading-l fsd-banner-content"> {% if is_active_status %}All act

<div class="govuk-grid-row">
<section class="govuk-width-container govuk-grid-column-full">
{% if round_details.fund_short_name.upper() == 'NSTF' %}
{% 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,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
{% from "govuk_frontend_jinja/components/input/macro.html" import govukInput %}
{% from "macros/sortable_table_header.html" import sortable_table_header %}
{% from "macros/filter_options.html" import filter_options %}
{% from "macros/tags_table.html" import tags_table %}


{% macro 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) -%}
<nav class="search-bar-flex-container">
<form method="get" class="govuk-!-width-full">
{{ filter_options(
query_params,
cohort,
'cohort',
'Search reference or organisation name',
assessment_statuses,
countries,
regions,
local_authorities,
round_details,
show_clear_filters,
tag_option_groups
) }}
</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('organisation_name', 'Organisation name', sort_order, sort_column, round_details, query_params) }}

{{ sortable_table_header('cohort', 'Cohort', 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('national_or_regional', 'National or regional', 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 %}

</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="organisation_name" href="{{ url_for('assessment_bp.application',application_id=overview.application_id) }}">{{ overview.organisation_name }}</a></td>

{% set cohort_display_list = [] %}
{% set cohort_list = overview.cohort | ast_literal_eval %}
{% for cohrt in cohort_list %}
{% set _ = cohort_display_list.append(cohort.get(cohrt)) %}
{% endfor %}

<td class="govuk-table__cell">{{ cohort_display_list | join(' ') }}</td>

<td class="govuk-table__cell">£{{ "{:,.2f}".format(overview.funding_amount_requested|int|round) }}</td>
<td class="govuk-table__cell">{{ "Regional" if overview.is_project_regional else "National"}}</td>

{{ tags_table(tags[overview.application_id], tagging_purpose_config, query_params.show_tags == "ON") }}

{% if g.access_controller.has_any_assessor_role %}
<td class="govuk-table__cell">
{% if overview.application_status == "QA_COMPLETED" %}
<span>{{ assessment_statuses[overview.application_status] }}</span>
{% elif overview.application_status == "STOPPED" %}
<span class="stopped-tag">
{{ assessment_statuses[overview.application_status] }}
</span>
{% elif overview.application_status == "FLAGGED" %}
<span class="flagged-tag">
{{ assessment_statuses[overview.application_status] }}
</span>
{% elif "Flagged" in overview.application_status %}
<span class="flagged-tag">
{{ overview.application_status }}
</span>
{% elif overview.application_status == "NOT_STARTED" %}
<span class="not-started-tag">
{{ assessment_statuses[overview.application_status] }}
</span>
{% elif overview.application_status == "COMPLETED" %}
<span>
{{ assessment_statuses[overview.application_status] }}
</span>
{% elif overview.application_status == "MULTIPLE_FLAGS" %}
<span class="flagged-tag">
{{ assessment_statuses[overview.application_status] }}
</span>
{% else %}
<span>
{{ assessment_statuses[overview.application_status] }}
{{ '(' + overview.progress|string + '%)' if 'progress' in overview else '(0%)' }}
</span>
{% endif %}
</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{%- endmacro %}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<div>
<div class="govuk-form-group govuk-!-display-inline-block govuk-!-margin-bottom-0 govuk-!-margin-right-2">
<label class="govuk-label" for="filter_{{ item_type }}">
Filter by {{ "asset type" if item_type == "asset_type" else "funding type" }}
Filter by {{ item_type | replace("_", " ") }}
</label>
<select class="govuk-select" id="filter_{{ item_type }}" name="{{ item_type }}">
{% for item in item_types %}
Expand Down
6 changes: 6 additions & 0 deletions app/blueprints/shared/filters.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ast
from datetime import datetime

from pytz import timezone
Expand Down Expand Up @@ -69,3 +70,8 @@ def all_caps_to_human(word):
def format_project_ref(value: str):
secions = value.split("-")
return secions[len(secions) - 1]


def ast_literal_eval(value):
"""Evaluate an expression node or a string containing only a Python literal or container display"""
return ast.literal_eval(value)
17 changes: 17 additions & 0 deletions config/display_value_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
"revenue": "Revenue",
}

cohort = {
ALL_VALUE: "All",
"ukrainian-schemes": "Ukraine",
"hong-kong-british-nationals": "Hong Kong",
"afghan-citizens-resettlement-scheme": "Afghanistan",
}

search_params_cof = {
"search_term": "",
"search_in": "project_name,short_id",
Expand All @@ -58,6 +65,16 @@
"region": ALL_VALUE,
"local_authority": ALL_VALUE,
}
search_params_cyp = {
"search_term": "",
"search_in": "organisation_name,short_id",
"cohort": ALL_VALUE,
"status": ALL_VALUE,
"filter_by_tag": ALL_VALUE,
"country": ALL_VALUE,
"region": ALL_VALUE,
"local_authority": ALL_VALUE,
}

search_params_tag = {
"search_term": "",
Expand Down
2 changes: 2 additions & 0 deletions create_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from app.blueprints.flagging.routes import flagging_bp
from app.blueprints.scoring.routes import scoring_bp
from app.blueprints.shared.filters import all_caps_to_human
from app.blueprints.shared.filters import ast_literal_eval
from app.blueprints.shared.filters import datetime_format
from app.blueprints.shared.filters import datetime_format_24hr
from app.blueprints.shared.filters import format_address
Expand Down Expand Up @@ -81,6 +82,7 @@ def create_app() -> Flask:

flask_app.jinja_env.trim_blocks = True
flask_app.jinja_env.lstrip_blocks = True
flask_app.jinja_env.filters["ast_literal_eval"] = ast_literal_eval
flask_app.jinja_env.filters["datetime_format"] = datetime_format
flask_app.jinja_env.filters["utc_to_bst"] = utc_to_bst
flask_app.jinja_env.filters[
Expand Down

0 comments on commit d355319

Please sign in to comment.