Make file size limit configurable
This commit is contained in:
parent
62d8a89eb1
commit
dff9924c95
@ -3,7 +3,7 @@
|
|||||||
"files": "^.secrets.baseline$|^.*pgsslrootcert.yml$",
|
"files": "^.secrets.baseline$|^.*pgsslrootcert.yml$",
|
||||||
"lines": null
|
"lines": null
|
||||||
},
|
},
|
||||||
"generated_at": "2020-01-29T16:40:16Z",
|
"generated_at": "2020-01-27T19:24:43Z",
|
||||||
"plugins_used": [
|
"plugins_used": [
|
||||||
{
|
{
|
||||||
"base64_limit": 4.5,
|
"base64_limit": 4.5,
|
||||||
@ -82,7 +82,7 @@
|
|||||||
"hashed_secret": "afc848c316af1a89d49826c5ae9d00ed769415f3",
|
"hashed_secret": "afc848c316af1a89d49826c5ae9d00ed769415f3",
|
||||||
"is_secret": false,
|
"is_secret": false,
|
||||||
"is_verified": false,
|
"is_verified": false,
|
||||||
"line_number": 31,
|
"line_number": 32,
|
||||||
"type": "Secret Keyword"
|
"type": "Secret Keyword"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -26,6 +26,7 @@ from atst.utils.localization import translate
|
|||||||
from flask import current_app as app
|
from flask import current_app as app
|
||||||
|
|
||||||
MAX_CLIN_AMOUNT = 1_000_000_000
|
MAX_CLIN_AMOUNT = 1_000_000_000
|
||||||
|
FILE_SIZE_LIMIT = 64
|
||||||
|
|
||||||
|
|
||||||
def coerce_enum(enum_inst):
|
def coerce_enum(enum_inst):
|
||||||
@ -164,8 +165,14 @@ class TaskOrderForm(BaseForm):
|
|||||||
)
|
)
|
||||||
pdf = FormField(
|
pdf = FormField(
|
||||||
AttachmentForm,
|
AttachmentForm,
|
||||||
label=translate("task_orders.form.supporting_docs_size_limit"),
|
label=translate(
|
||||||
description=translate("task_orders.form.supporting_docs_size_limit"),
|
"task_orders.form.supporting_docs_size_limit",
|
||||||
|
{"file_size_limit": FILE_SIZE_LIMIT},
|
||||||
|
),
|
||||||
|
description=translate(
|
||||||
|
"task_orders.form.supporting_docs_size_limit",
|
||||||
|
{"file_size_limit": FILE_SIZE_LIMIT},
|
||||||
|
),
|
||||||
)
|
)
|
||||||
clins = FieldList(FormField(CLINForm))
|
clins = FieldList(FormField(CLINForm))
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ def render_task_orders_edit(
|
|||||||
|
|
||||||
render_args["contract_start"] = app.config.get("CONTRACT_START_DATE")
|
render_args["contract_start"] = app.config.get("CONTRACT_START_DATE")
|
||||||
render_args["contract_end"] = app.config.get("CONTRACT_END_DATE")
|
render_args["contract_end"] = app.config.get("CONTRACT_END_DATE")
|
||||||
|
render_args["file_size_limit"] = int(app.config.get("FILE_SIZE_LIMIT"))
|
||||||
|
|
||||||
if task_order_id:
|
if task_order_id:
|
||||||
task_order = TaskOrders.get(task_order_id)
|
task_order = TaskOrders.get(task_order_id)
|
||||||
|
@ -18,6 +18,7 @@ DEBUG = true
|
|||||||
DEBUG_MAILER = false
|
DEBUG_MAILER = false
|
||||||
DISABLE_CRL_CHECK = false
|
DISABLE_CRL_CHECK = false
|
||||||
ENVIRONMENT = dev
|
ENVIRONMENT = dev
|
||||||
|
FILE_SIZE_LIMIT = 64000000
|
||||||
LIMIT_CONCURRENT_SESSIONS = false
|
LIMIT_CONCURRENT_SESSIONS = false
|
||||||
LOG_JSON = false
|
LOG_JSON = false
|
||||||
MAIL_PASSWORD
|
MAIL_PASSWORD
|
||||||
|
@ -20,6 +20,9 @@ export default {
|
|||||||
portfolioId: {
|
portfolioId: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
|
sizeLimit: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
data: function() {
|
data: function() {
|
||||||
@ -31,6 +34,7 @@ export default {
|
|||||||
sizeError: false,
|
sizeError: false,
|
||||||
filenameError: false,
|
filenameError: false,
|
||||||
downloadLink: '',
|
downloadLink: '',
|
||||||
|
fileSizeLimit: parseInt(this.sizeLimit),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -48,7 +52,7 @@ export default {
|
|||||||
this.clearErrors()
|
this.clearErrors()
|
||||||
|
|
||||||
const file = e.target.files[0]
|
const file = e.target.files[0]
|
||||||
if (file.size > 64000000) {
|
if (file.size > this.fileSizeLimit) {
|
||||||
this.sizeError = true
|
this.sizeError = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{% from "components/icon.html" import Icon %}
|
{% from "components/icon.html" import Icon %}
|
||||||
|
|
||||||
{% macro UploadInput(field, portfolio_id, show_label=False) -%}
|
{% macro UploadInput(field, portfolio_id, file_size_limit, show_label=False) -%}
|
||||||
<uploadinput
|
<uploadinput
|
||||||
inline-template
|
inline-template
|
||||||
{% if not field.errors %}
|
{% if not field.errors %}
|
||||||
@ -11,6 +11,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
v-bind:portfolio-id="'{{ portfolio_id }}'"
|
v-bind:portfolio-id="'{{ portfolio_id }}'"
|
||||||
name='{{ field.name }}'
|
name='{{ field.name }}'
|
||||||
|
v-bind:size-limit='{{ file_size_limit }}'
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
<div v-show="valid" class="uploaded-file">
|
<div v-show="valid" class="uploaded-file">
|
||||||
@ -47,7 +48,7 @@
|
|||||||
<span class="usa-input__message">{{ "forms.task_order.upload_error" | translate }}</span>
|
<span class="usa-input__message">{{ "forms.task_order.upload_error" | translate }}</span>
|
||||||
</template>
|
</template>
|
||||||
<template v-if="sizeError">
|
<template v-if="sizeError">
|
||||||
<span class="usa-input__message">{{ "forms.task_order.size_error" | translate }}</span>
|
<span class="usa-input__message">{{ "forms.task_order.size_error" | translate({"file_size_limit": (file_size_limit//1000000)}) }}</span>
|
||||||
</template>
|
</template>
|
||||||
<template v-if="filenameError">
|
<template v-if="filenameError">
|
||||||
<span class="usa-input__message">{{ "forms.task_order.filename_error" | translate }}</span>
|
<span class="usa-input__message">{{ "forms.task_order.filename_error" | translate }}</span>
|
||||||
|
@ -19,5 +19,5 @@
|
|||||||
title='task_orders.form.step_1.title' | translate,
|
title='task_orders.form.step_1.title' | translate,
|
||||||
description='task_orders.form.step_1.description' | translate,
|
description='task_orders.form.step_1.description' | translate,
|
||||||
) }}
|
) }}
|
||||||
{{ UploadInput(form.pdf, portfolio.id) }}
|
{{ UploadInput(form.pdf, portfolio.id, file_size_limit) }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from flask import Markup
|
from flask import Markup, current_app as app
|
||||||
from wtforms import Form, FormField
|
from wtforms import Form, FormField
|
||||||
from wtforms.fields import StringField
|
from wtforms.fields import StringField
|
||||||
from wtforms.validators import InputRequired
|
from wtforms.validators import InputRequired
|
||||||
@ -111,13 +111,17 @@ def test_make_multi_checkbox_input_template(
|
|||||||
|
|
||||||
|
|
||||||
def test_make_upload_input_template(upload_input_macro, task_order_form):
|
def test_make_upload_input_template(upload_input_macro, task_order_form):
|
||||||
rendered_upload_macro = upload_input_macro(task_order_form.pdf)
|
rendered_upload_macro = upload_input_macro(
|
||||||
|
task_order_form.pdf, file_size_limit=int(app.config.get("FILE_SIZE_LIMIT")),
|
||||||
|
)
|
||||||
write_template(rendered_upload_macro, "upload_input_template.html")
|
write_template(rendered_upload_macro, "upload_input_template.html")
|
||||||
|
|
||||||
|
|
||||||
def test_make_upload_input_error_template(upload_input_macro, task_order_form):
|
def test_make_upload_input_error_template(upload_input_macro, task_order_form):
|
||||||
task_order_form.validate()
|
task_order_form.validate()
|
||||||
rendered_upload_macro = upload_input_macro(task_order_form.pdf)
|
rendered_upload_macro = upload_input_macro(
|
||||||
|
task_order_form.pdf, file_size_limit=int(app.config.get("FILE_SIZE_LIMIT")),
|
||||||
|
)
|
||||||
write_template(rendered_upload_macro, "upload_input_error_template.html")
|
write_template(rendered_upload_macro, "upload_input_error_template.html")
|
||||||
|
|
||||||
|
|
||||||
|
@ -308,7 +308,7 @@ forms:
|
|||||||
length_error: Filename may be no longer than 100 characters.
|
length_error: Filename may be no longer than 100 characters.
|
||||||
task_order:
|
task_order:
|
||||||
upload_error: There was an error uploading your file. Please try again. If you encounter repeated problems uploading this file, please contact CCPO.
|
upload_error: There was an error uploading your file. Please try again. If you encounter repeated problems uploading this file, please contact CCPO.
|
||||||
size_error: The file you have selected is too large. Please choose a file no larger than 64MB.
|
size_error: "The file you have selected is too large. Please choose a file no larger than {file_size_limit}MB."
|
||||||
filename_error: File names can only contain the characters A-Z, 0-9, space, hyphen, underscore, and period.
|
filename_error: File names can only contain the characters A-Z, 0-9, space, hyphen, underscore, and period.
|
||||||
number_description: 13-Digit Task Order Number
|
number_description: 13-Digit Task Order Number
|
||||||
pop_errors:
|
pop_errors:
|
||||||
@ -552,7 +552,7 @@ task_orders:
|
|||||||
pop_end_alert: "A CLIN's period of performance must end before {end_date}."
|
pop_end_alert: "A CLIN's period of performance must end before {end_date}."
|
||||||
pop_example: "For example: 07 04 1776"
|
pop_example: "For example: 07 04 1776"
|
||||||
pop_start: Start Date
|
pop_start: Start Date
|
||||||
supporting_docs_size_limit: Your file may not exceed 64MB
|
supporting_docs_size_limit: "Your file may not exceed {file_size_limit}MB"
|
||||||
step_1:
|
step_1:
|
||||||
title: Upload your approved Task Order (TO)
|
title: Upload your approved Task Order (TO)
|
||||||
description: Upload your approved Task Order here. You are required to confirm you have the appropriate signature. You will have the ability to add additional approved Task Orders with more funding to this Portfolio in the future.
|
description: Upload your approved Task Order here. You are required to confirm you have the appropriate signature. You will have the ability to add additional approved Task Orders with more funding to this Portfolio in the future.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user