Formatting

This commit is contained in:
Montana 2018-08-27 10:59:40 -04:00
parent 4f9e7c3408
commit cfe9b7589e
9 changed files with 18 additions and 13 deletions

View File

@ -146,11 +146,12 @@ def make_crl_validator(app):
def make_eda_client(app):
app.eda_client = MockEDAClient()
def make_upload_storage(app):
uploader = Uploader(
provider=app.config.get("STORAGE_PROVIDER"),
container=app.config.get("STORAGE_CONTAINER"),
key=app.config.get("STORAGE_KEY"),
secret=app.config.get("STORAGE_SECRET")
)
provider=app.config.get("STORAGE_PROVIDER"),
container=app.config.get("STORAGE_CONTAINER"),
key=app.config.get("STORAGE_KEY"),
secret=app.config.get("STORAGE_SECRET"),
)
app.uploader = uploader

View File

@ -251,7 +251,9 @@ WHERE requests_with_status.status = :status
else:
task_order_number = request_data.get("task_order_number")
if "task_order" in request_data and isinstance(request_data["task_order"], FileStorage):
if "task_order" in request_data and isinstance(
request_data["task_order"], FileStorage
):
task_order_data["pdf"] = request_data.pop("task_order")
task_order = TaskOrders.get_or_create_task_order(

View File

@ -58,5 +58,8 @@ class TaskOrders(object):
# should catch the error here
attachment = Attachment.attach(pdf_file)
return TaskOrders.create(
**task_order_data, number=number, source=Source.MANUAL, pdf=attachment
**task_order_data,
number=number,
source=Source.MANUAL,
pdf=attachment,
)

View File

@ -216,4 +216,7 @@ class ExtendedFinancialForm(BaseFinancialForm):
filters=[number_to_int],
)
task_order = FileField("Upload a copy of your Task Order", validators=[FileAllowed(['pdf'], 'Only PDF documents can be uploaded.')])
task_order = FileField(
"Upload a copy of your Task Order",
validators=[FileAllowed(["pdf"], "Only PDF documents can be uploaded.")],
)

View File

@ -30,7 +30,6 @@ def update_financial_verification(request_id):
post_data = http_request.form
existing_request = Requests.get(request_id)
form = financial_form(post_data)
rerender_args = dict(
request_id=request_id, f=form, extended=http_request.args.get("extended")
)

View File

@ -7,7 +7,7 @@ class UploadError(Exception):
pass
class Uploader():
class Uploader:
_PERMITTED_MIMETYPES = ["application/pdf"]
def __init__(self, provider, container=None, key=None, secret=None):

View File

@ -26,7 +26,6 @@ def app(request):
ctx = _app.app_context()
ctx.push()
yield _app
upload_dir.cleanup()

View File

@ -13,4 +13,3 @@ MOCK_VALID_PE_ID = "8675309U"
FIXTURE_EMAIL_ADDRESS = "artgarfunkel@uso.mil"
PDF_FILENAME = "tests/fixtures/sample.pdf"

View File

@ -31,4 +31,3 @@ def test_upload_fails_for_non_pdfs(uploader):
fs = FileStorage(fp, content_type="text/plain")
with pytest.raises(UploadError):
uploader.upload(fs)