Add new filter for rendering FileStorage name in case of invalid financial form submission
This commit is contained in:
parent
6df897191c
commit
be080ed205
@ -1,4 +1,6 @@
|
|||||||
import re
|
import re
|
||||||
|
from flask import current_app as app
|
||||||
|
from werkzeug.datastructures import FileStorage
|
||||||
|
|
||||||
|
|
||||||
def iconSvg(name):
|
def iconSvg(name):
|
||||||
@ -31,9 +33,20 @@ def getOptionLabel(value, options):
|
|||||||
return next(tup[1] for tup in options if tup[0] == value)
|
return next(tup[1] for tup in options if tup[0] == value)
|
||||||
|
|
||||||
|
|
||||||
|
def enhancedToJson(value):
|
||||||
|
if (
|
||||||
|
isinstance(value, dict)
|
||||||
|
and "task_order" in value
|
||||||
|
and isinstance(value["task_order"], FileStorage)
|
||||||
|
):
|
||||||
|
value["task_order"] = value["task_order"].filename
|
||||||
|
return app.jinja_env.filters["tojson"](value)
|
||||||
|
|
||||||
|
|
||||||
def register_filters(app):
|
def register_filters(app):
|
||||||
app.jinja_env.filters["iconSvg"] = iconSvg
|
app.jinja_env.filters["iconSvg"] = iconSvg
|
||||||
app.jinja_env.filters["dollars"] = dollars
|
app.jinja_env.filters["dollars"] = dollars
|
||||||
app.jinja_env.filters["usPhone"] = usPhone
|
app.jinja_env.filters["usPhone"] = usPhone
|
||||||
app.jinja_env.filters["readableInteger"] = readableInteger
|
app.jinja_env.filters["readableInteger"] = readableInteger
|
||||||
app.jinja_env.filters["getOptionLabel"] = getOptionLabel
|
app.jinja_env.filters["getOptionLabel"] = getOptionLabel
|
||||||
|
app.jinja_env.filters["enhancedToJson"] = enhancedToJson
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<financial inline-template v-bind:initial-data='{{ f.data|tojson }}'>
|
<financial inline-template v-bind:initial-data='{{ f.data|enhancedToJson }}'>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
|
|
||||||
{% if extended %}
|
{% if extended %}
|
||||||
|
@ -37,6 +37,7 @@ def test_nonexistent_task_order_raises_with_client(monkeypatch):
|
|||||||
with pytest.raises(NotFoundError):
|
with pytest.raises(NotFoundError):
|
||||||
TaskOrders.get("some other fake numer")
|
TaskOrders.get("some other fake numer")
|
||||||
|
|
||||||
|
|
||||||
def test_create_attachment(extended_financial_verification_data):
|
def test_create_attachment(extended_financial_verification_data):
|
||||||
task_order_data = extended_financial_verification_data.copy()
|
task_order_data = extended_financial_verification_data.copy()
|
||||||
task_order_data["pdf"] = task_order_data.pop("task_order")
|
task_order_data["pdf"] = task_order_data.pop("task_order")
|
||||||
|
@ -130,3 +130,18 @@ class TestPENumberInForm:
|
|||||||
|
|
||||||
assert response.status_code == 302
|
assert response.status_code == 302
|
||||||
assert "/projects/new" in response.headers.get("Location")
|
assert "/projects/new" in response.headers.get("Location")
|
||||||
|
|
||||||
|
def test_submit_invalid_extended_financial_form(
|
||||||
|
self, monkeypatch, user_session, client, extended_financial_verification_data
|
||||||
|
):
|
||||||
|
request = RequestFactory.create()
|
||||||
|
monkeypatch.setattr("atst.domain.requests.Requests.get", lambda i: request)
|
||||||
|
monkeypatch.setattr("atst.forms.financial.validate_pe_id", lambda *args: True)
|
||||||
|
user_session()
|
||||||
|
data = {**self.required_data, **extended_financial_verification_data}
|
||||||
|
data["task_order_number"] = "1234567"
|
||||||
|
del (data["clin_0001"])
|
||||||
|
|
||||||
|
response = self.submit_data(client, data, extended=True)
|
||||||
|
|
||||||
|
assert response.status_code == 200
|
||||||
|
Loading…
x
Reference in New Issue
Block a user