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

Commit

Permalink
fs-1968-score-history
Browse files Browse the repository at this point in the history
  • Loading branch information
gio-karunakaran committed Dec 6, 2022
1 parent 7c12201 commit fb8029f
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .flaskenv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FLASK_APP=app.py
FLASK_ENV=development
FLASK_RUN_PORT=5001
FLASK_RUN_PORT=5000
20 changes: 13 additions & 7 deletions app/assess/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
from app.assess.models.round import Round
from app.assess.models.sub_criteria import SubCriteria
from config import Config
from dateutil import parser
from flask import abort
from flask import current_app


def get_data(
endpoint: str,
use_local_data: bool = Config.USE_LOCAL_DATA,
payload: Dict = None,
use_local_data: bool = Config.USE_LOCAL_DATA,
):
if use_local_data:
current_app.logger.info(f"Fetching local data from '{endpoint}'.")
Expand Down Expand Up @@ -144,17 +145,22 @@ def get_round_with_applications(
return None


def get_score_and_justification(application_id, sub_criteria_id):
def get_score_and_justification(
application_id, sub_criteria_id, score_history=True
):
url = Config.ASSESSMENT_SCORES_ENDPOINT
params = {
"application_id": application_id,
"sub_criteria_id": sub_criteria_id,
"score_history": score_history,
}
response_json = get_data(url, params)
current_app.logger.info(
f"Response from Assessment Store: '{response_json}'."
)
return response_json
response = get_data(url, params)
current_app.logger.info(f"Response from Assessment Store: '{response}'.")
for score in response:
date_created = parser.parse(score["date_created"])
formated_date_created = date_created.strftime("%d/%m/%Y at %H:%M")
score["date_created"] = formated_date_created
return response


def submit_score_and_justification(
Expand Down
6 changes: 5 additions & 1 deletion app/assess/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ def application_sub_crit_scoring(application_id: str, sub_criteria_id: str):
True if not form.justification.data else False
)
# call to assessment store to get latest score
latest_score = get_score_and_justification(application_id, sub_criteria_id)
score_list = get_score_and_justification(
application_id, sub_criteria_id, score_history=True
)
latest_score = score_list.pop(0)
# TODO make COF_score_list extendable to other funds
COF_score_list = [
(5, "Strong"),
Expand All @@ -87,6 +90,7 @@ def application_sub_crit_scoring(application_id: str, sub_criteria_id: str):
"sub_criteria.html",
scores_submitted=scores_submitted,
form=form,
score_list=score_list if len(score_list) > 0 else None,
latest_score=latest_score,
fund=fund,
application_id=application_id,
Expand Down
2 changes: 1 addition & 1 deletion app/assess/templates/macros/scores.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</p>
{% endif %}
<div class="govuk-radios" data-module="govuk-radios">
{% for score, description in score_tuple %}
{% for score, description in score_list %}
<div class="govuk-radios__item">
<input class="govuk-radios__input" id={{"score-{}".format(score)}} name={{score_form_name}}
type="radio" value={{score}}>
Expand Down
24 changes: 23 additions & 1 deletion app/assess/templates/macros/scores_justification.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{% from "macros/justification.html" import justification %}
{%- from "govuk_frontend_jinja/components/button/macro.html" import govukButton -%}

{% macro scores_justification(scores_submitted, form, latest_score, application_id, sub_criteria_id, COF_score_list, score_error, justification_error) %}
{% macro scores_justification(scores_submitted, form, score_list, latest_score, application_id, sub_criteria_id, COF_score_list, score_error, justification_error) %}

<div class="govuk-grid-column-two-thirds s26-scoring">
{% if latest_score %}
Expand All @@ -15,6 +15,28 @@ <h2 class="govuk-heading-m">Current score: {{ latest_score['score'] }}</h2>
<p class="govuk-body-s"> <strong>Date/time:</strong> {{ latest_score['date_created'] }}</p>
</div>
</div>

<details class="govuk-details govuk-!-margin-top-4" data-module="govuk-details">
<summary class="govuk-details__summary">
<span class="govuk-details__summary-text">
Score history
</span>
</summary>
<div class="govuk-details__text">
<div id="anchor">
{% if score_list %}
{% for score in score_list %}
<p><strong>Score: </strong>{{ score["score"] }}</p>
<p><strong>Rationale: </strong>{{ score["justification"] }}</p>
<p class="govuk-body-s"><strong>Your name: </strong> (Assessor) {{ score["user_id"] }}</p>
<p class="govuk-body-s"><strong>Date/time:</strong> {{ score["date_created"] }}</p>
<hr>
{% endfor %}
{% endif %}
</div>
</div>
</details>

{% endif %}

{% if scores_submitted %}
Expand Down
2 changes: 1 addition & 1 deletion app/assess/templates/sub_criteria.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ <h1 class="govuk-heading-l scoring-heading">Score engagement</h1>
</nav>
</div>

{{scores_justification(scores_submitted, form, latest_score, application_id, sub_criteria_id, COF_score_list, score_error, justification_error)}}
{{scores_justification(scores_submitted, form, score_list, latest_score, application_id, sub_criteria_id, COF_score_list, score_error, justification_error)}}

<h2 class="govuk-heading govuk-heading-l" id="comments-heading">Comments</h2>
<section class="comment-section">
Expand Down
1 change: 0 additions & 1 deletion config/envs/development.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class DevelopmentConfig(DefaultConfig):
# for local testing with flask run and USE_LOCAL_DATA = True:
# USE_LOCAL_DATA = True
FSD_LOG_LEVEL = logging.INFO

# FUND_STORE_API_HOST = "fund_store"
# ASSESSMENT_STORE_API_HOST = "assessment_store"
# APPLICATION_STORE_API_HOST = "application_store"
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ axe-selenium-python==2.1.6
json2html==1.3.0
selenium==4.2.0
webdriver-manager==3.7.0
python-dateutil==2.8.2
79 changes: 59 additions & 20 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ async-generator==1.10
# via
# trio
# trio-websocket
attrs==21.4.0
atomicwrites==1.4.1
# via pytest
attrs==22.1.0
# via
# -r requirements.txt
# jsonschema
# openapi-schema-validator
# outcome
# pytest
# trio
Expand All @@ -35,7 +38,7 @@ brotli==1.0.9
# flask-compress
build==0.8.0
# via pip-tools
certifi==2022.6.15
certifi==2022.9.24
# via
# -r requirements.txt
# requests
Expand All @@ -45,13 +48,14 @@ cffi==1.15.1
# via
# -r requirements.txt
# cryptography
# trio
cfgv==3.3.1
# via pre-commit
chardet==4.0.0
# via
# -r requirements.txt
# prance
charset-normalizer==2.1.0
charset-normalizer==2.1.1
# via
# -r requirements.txt
# requests
Expand All @@ -66,13 +70,21 @@ clickclick==20.10.2
# via
# -r requirements.txt
# connexion
colorama==0.4.6
# via
# -r requirements.txt
# bandit
# build
# click
# pytest
# tqdm
commonmark==0.9.1
# via
# -r requirements.txt
# rich
connexion==2.14.0
connexion==2.14.1
# via -r requirements.txt
cryptography==37.0.4
cryptography==38.0.4
# via
# -r requirements.txt
# pyjwt
Expand Down Expand Up @@ -131,13 +143,17 @@ h11==0.13.0
# via wsproto
identify==2.5.1
# via pre-commit
idna==3.3
idna==3.4
# via
# -r requirements.txt
# email-validator
# requests
# trio
# urllib3
importlib-resources==5.10.0
# via
# -r requirements.txt
# openapi-spec-validator
inflection==0.5.1
# via
# -r requirements.txt
Expand All @@ -163,26 +179,36 @@ jsmin==3.0.1
# via -r requirements.txt
json2html==1.3.0
# via -r requirements-dev.in
jsonschema==4.6.1
jsonschema==4.17.3
# via
# -r requirements.txt
# connexion
# jsonschema-spec
# openapi-schema-validator
# openapi-spec-validator
jsonschema-spec==0.1.2
# via
# -r requirements.txt
# openapi-spec-validator
lazy-object-proxy==1.8.0
# via
# -r requirements.txt
# openapi-spec-validator
markupsafe==2.1.1
# via
# -r requirements.txt
# jinja2
# werkzeug
# wtforms
mypy-extensions==0.4.3
# via black
nodeenv==1.7.0
# via pre-commit
openapi-schema-validator==0.2.3
openapi-schema-validator==0.3.4
# via
# -r requirements.txt
# openapi-spec-validator
openapi-spec-validator==0.4.0
openapi-spec-validator==0.5.1
# via -r requirements.txt
ordered-set==4.1.0
# via deepdiff
Expand All @@ -193,7 +219,12 @@ packaging==21.3
# -r requirements.txt
# build
# connexion
# prance
# pytest
pathable==0.4.3
# via
# -r requirements.txt
# jsonschema-spec
pathspec==0.9.0
# via black
pbr==5.9.0
Expand All @@ -208,7 +239,7 @@ platformdirs==2.5.2
# virtualenv
pluggy==1.0.0
# via pytest
prance==0.21.8.0
prance==0.22.11.4.0
# via -r requirements.txt
pre-commit==2.19.0
# via -r requirements-dev.in
Expand All @@ -218,11 +249,11 @@ pycparser==2.21
# via
# -r requirements.txt
# cffi
pygments==2.12.0
pygments==2.13.0
# via
# -r requirements.txt
# rich
pyjwt[crypto]==2.4.0
pyjwt[crypto]==2.6.0
# via
# -r requirements.txt
# funding-service-design-utils
Expand All @@ -232,7 +263,7 @@ pyparsing==3.0.9
# via
# -r requirements.txt
# packaging
pyrsistent==0.18.1
pyrsistent==0.19.2
# via
# -r requirements.txt
# jsonschema
Expand Down Expand Up @@ -268,16 +299,18 @@ pytest-selenium==2.0.1
# via -r requirements-dev.in
pytest-variables==2.0.0
# via pytest-selenium
python-dateutil==2.8.2
# via -r requirements-dev.in
python-dotenv==0.20.0
# via
# -r requirements.txt
# funding-service-design-utils
# webdriver-manager
python-json-logger==2.0.2
python-json-logger==2.0.4
# via
# -r requirements.txt
# funding-service-design-utils
pytz==2022.1
pytz==2022.6
# via
# -r requirements.txt
# babel
Expand All @@ -290,6 +323,7 @@ pyyaml==6.0
# clickclick
# connexion
# funding-service-design-utils
# jsonschema-spec
# openapi-spec-validator
# pre-commit
requests==2.28.1
Expand All @@ -300,15 +334,15 @@ requests==2.28.1
# pytest-base-url
# pytest-selenium
# webdriver-manager
rich==12.4.4
rich==12.6.0
# via
# -r requirements.txt
# funding-service-design-utils
ruamel-yaml==0.17.21
# via
# -r requirements.txt
# prance
ruamel-yaml-clib==0.2.6
ruamel-yaml-clib==0.2.7
# via
# -r requirements.txt
# ruamel-yaml
Expand All @@ -321,7 +355,7 @@ semver==2.13.0
# via
# -r requirements.txt
# prance
sentry-sdk[flask]==1.10.1
sentry-sdk[flask]==1.11.1
# via
# -r requirements.txt
# funding-service-design-utils
Expand All @@ -331,6 +365,7 @@ six==1.16.0
# flask-talisman
# prance
# pyscss
# python-dateutil
# tenacity
# virtualenv
smmap==5.0.0
Expand Down Expand Up @@ -363,7 +398,11 @@ trio==0.21.0
# trio-websocket
trio-websocket==0.9.2
# via selenium
urllib3[secure,socks]==1.26.12
typing-extensions==4.4.0
# via
# -r requirements.txt
# jsonschema-spec
urllib3[secure,socks]==1.26.13
# via
# -r requirements.txt
# requests
Expand All @@ -381,7 +420,7 @@ webdriver-manager @ git+https://github.com/SergeyPirogov/webdriver_manager@dc73f
# via
# -r requirements-dev.in
# -r requirements.txt
werkzeug==2.1.2
werkzeug==2.2.2
# via
# -r requirements.txt
# connexion
Expand Down
Loading

0 comments on commit fb8029f

Please sign in to comment.