Skip to content

Commit

Permalink
FS-4200-fix-cosmetic-issues-for-export-applicat-information-data (#581)
Browse files Browse the repository at this point in the history
* fix cosmetic issues for export applicant information for cof-eoi

* FS-4236-remove-current-assessment-status-text-from-cof-eoi-fund for activity trail page
  • Loading branch information
ramsharma-prog committed Mar 5, 2024
1 parent 7136bd7 commit 5ea7090
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
40 changes: 39 additions & 1 deletion app/blueprints/assessments/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from app.blueprints.services.models.fund import Fund
from app.blueprints.shared.helpers import determine_display_status
from app.blueprints.tagging.models.tag import AssociatedTag
from bs4 import BeautifulSoup
from config import Config
from config.display_value_mappings import assessment_statuses
from flask import Response
Expand Down Expand Up @@ -162,7 +163,9 @@ def generate_csv_of_application(q_and_a: dict, fund: Fund, application_json):

def generate_assessment_info_csv(data: dict):
output = StringIO()
headers = list(OrderedDict.fromkeys(key for d in data for key in d.keys()))
headers = list(
OrderedDict.fromkeys(key for d in data for key in d.keys() if key not in exclude_header(["COF-EOI"]))
)
csv_writer = csv.writer(output)

if len(data) == 0:
Expand Down Expand Up @@ -228,3 +231,38 @@ def get_files_for_application_upload_fields(application_id: str, short_id: str,
files = [(file.filename, generate_url(file, short_id)) for file in client_side_upload_files]

return legacy_files + files


def convert_bool_value(value):
if value:
return "Yes"
if not value:
return "No"
if value is None:
return "Not sure"


def strip_tags(text):
if text == ["none"]:
return "Not sure"
soup = BeautifulSoup(text, "html.parser")
return soup.get_text()


def sanitise_export_data(data):
if isinstance(data, dict):
for key, value in data.items():
data[key] = sanitise_export_data(value)
if isinstance(data, list):
data = [sanitise_export_data(d) for d in data]

if isinstance(data, bool):
data = convert_bool_value(data)
if isinstance(data, str):
data = strip_tags(data)
return data


def exclude_header(fund_names: list):
if "COF-EOI" in fund_names:
return ["Help with insolvency", "Help with organisation type", "Help with public authority"]
3 changes: 2 additions & 1 deletion app/blueprints/assessments/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
)
from app.blueprints.assessments.helpers import get_tag_map_and_tag_options
from app.blueprints.assessments.helpers import get_team_flag_stats
from app.blueprints.assessments.helpers import sanitise_export_data
from app.blueprints.assessments.helpers import (
set_application_status_in_overview,
)
Expand Down Expand Up @@ -740,7 +741,7 @@ def assessor_export(fund_short_name: str, round_short_name: str, report_type: st
ttl_hash=get_ttl_hash(Config.LRU_CACHE_TIME),
)
export = get_applicant_export(_round.fund_id, _round.id, report_type)

export = sanitise_export_data(export)
en_export_data = generate_assessment_info_csv(export["en_list"])
cy_export_data = generate_assessment_info_csv(export["cy_list"])

Expand Down
2 changes: 2 additions & 0 deletions app/blueprints/assessments/templates/activity_trail.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<div>
<div class="govuk-!-padding-left-3">
<h1 class="govuk-heading-l">Activity trail</h1>
{% if not state.fund_short_name=="COF-EOI" %}
<p class="govuk-body">Current assessment status:
{% if display_status == "Stopped" %}
<span class="stopped-tag">
Expand All @@ -77,6 +78,7 @@ <h1 class="govuk-heading-l">Activity trail</h1>
</span>
{% endif %}
</p>
{% endif %}
</div>


Expand Down

0 comments on commit 5ea7090

Please sign in to comment.