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

Commit

Permalink
Merge pull request #81 from communitiesuk/fs-2000-dynamic-score-and-s…
Browse files Browse the repository at this point in the history
…tatus

FS-2000: Dynamically pull score & status from database (front-end)
  • Loading branch information
tferns authored Dec 21, 2022
2 parents adc460e + 432fe79 commit 2920ab0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
10 changes: 4 additions & 6 deletions app/assess/templates/macros/criteria_element.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@
sub_criteria.name
)
},
{ "text": sub_criteria.theme_count, "format": "numeric" },
{ "text": sub_criteria.score, "format": "numeric" },
{ "html": '<span class="govuk-tag--scored-criteria">{}</span>'.format(sub_criteria.status), "format": "numeric" }
{ "text": sub_criteria.score or "", "format": "numeric" },
{ "html": '<span class="govuk-tag--scored-criteria">{}</span>'.format(sub_criteria.status|status_to_human),
"format": "numeric" }
]) %}
{% endfor %}

{% set _ = rows.append([
{ "html": "<strong>Total criteria score</strong>" },
{ "text": "" },
{ "text": "" },
{ "text": "{} of {}".format(criteria.total_criteria_score, criteria.total_criteria_score_possible), "format": "numeric" },
]) %}

Expand All @@ -36,8 +35,7 @@ <h3 class="{{ name_classes or '' }}">{{ criteria.name }}</h3>
"firstCellIsHeader":false,
"head":[
{ "text": "Assessment sub criteria" },
{ "text": "Number of sections", "format": "numeric" },
{ "text": "Score", "format": "numeric" },
{ "text": "Score out of 5", "format": "numeric" },
{ "text": "Status", "format": "numeric" }
],
"rows": rows,
Expand Down
6 changes: 3 additions & 3 deletions app/assess/views/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

def status_to_human(status: str):
status_to_human_map = {
"NOT_STARTED": "Not started",
"IN_PROGRESS": "In progress",
"NOT_STARTED": "Not Started",
"IN_PROGRESS": "In Progress",
"SUBMITTED": "Submitted",
"COMPLETED": "Completed",
}
Expand Down Expand Up @@ -40,7 +40,7 @@ def remove_dashes_underscores_capitalize(s: str) -> str:
return s.replace("-", " ").replace("_", " ").capitalize()


def format_address(address: str) -> str:
def format_address(address: str) -> list[str]:
address_parts = address.split(", ")
address_parts = [part for part in address_parts if part != "null"]
return address_parts
Expand Down
2 changes: 1 addition & 1 deletion tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_caps_to_human(self):
def test_status_to_human(self):
status_in = "NOT_STARTED"
result = status_to_human(status_in)
assert "Not started" == result, "Wrong format returned"
assert "Not Started" == result, "Wrong format returned"

def test_slash_separated_day_month_year(self):
date_in = "2023-01-30T12:00:00.500"
Expand Down
4 changes: 2 additions & 2 deletions tests/test_jinja_macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ def test_criteria_macro(self, request_ctx):
_CriteriaSubCriteria(
id="1",
name="Sub Criteria 1",
status="Not started",
status="NOT_STARTED",
theme_count=1,
score=2,
),
_CriteriaSubCriteria(
id="2",
name="Sub Criteria 2",
status="Not started",
status="NOT_STARTED",
theme_count=2,
score=2,
),
Expand Down

0 comments on commit 2920ab0

Please sign in to comment.