Display and overwrite task order uploads correctly.

- Populate the POSTed form with additional data from the existing TO
  model. This way the pdf attachment has to be explicitly overwritten.
- Adjust the frontend so that if there is an existing PDF, it only sends
  a file input back if the user removes the existing PDF.
This commit is contained in:
dandds
2019-06-11 09:58:32 -04:00
parent 49332c5d6e
commit 0e89a55c07
4 changed files with 18 additions and 7 deletions

View File

@@ -42,7 +42,12 @@ def edit(portfolio_id, task_order_id=None):
def update(portfolio_id, task_order_id=None):
form_data = {**http_request.form, **http_request.files}
form = TaskOrderForm(form_data)
form = None
if task_order_id:
task_order = TaskOrders.get(task_order_id)
form = TaskOrderForm(form_data, obj=task_order)
else:
form = TaskOrderForm(form_data)
if form.validate():
task_order = None