06/08 Fix inspection photo issues
This commit is contained in:
@@ -94,17 +94,26 @@ def _collect_form_responses(form_fields, existing_responses=None):
|
||||
responses[fid] = request.form.getlist(key)
|
||||
|
||||
elif ftype == 'image':
|
||||
# Priority 1: a new file was selected and submitted with the form
|
||||
photo_file = request.files.get(key)
|
||||
path = _save_photo(photo_file, subfolder='inspection_photos')
|
||||
if path:
|
||||
responses[fid] = path
|
||||
else:
|
||||
existing_path = (
|
||||
existing_responses.get(str(fid))
|
||||
or existing_responses.get(fid)
|
||||
or ''
|
||||
)
|
||||
responses[fid] = existing_path
|
||||
# Priority 2: the named hidden input carries the AJAX-uploaded
|
||||
# server path directly in the POST body — covers the case where
|
||||
# the photo was uploaded via AJAX but no draft save captured it
|
||||
# (e.g., uploaded after the last flag-issue page reload).
|
||||
submitted_path = request.form.get(f'{key}_server_path', '').strip()
|
||||
if submitted_path:
|
||||
responses[fid] = submitted_path
|
||||
else:
|
||||
# Priority 3: fall back to the most recent draft in the DB
|
||||
responses[fid] = (
|
||||
existing_responses.get(str(fid))
|
||||
or existing_responses.get(fid)
|
||||
or ''
|
||||
)
|
||||
|
||||
elif ftype == 'table':
|
||||
cols = field.get('col_headers') or ['Column 1']
|
||||
|
||||
Reference in New Issue
Block a user