Jul 29 - Photo absolute media URLs for mobile; add photo retention purge
This commit is contained in:
@@ -96,6 +96,13 @@ def _parse_datetime(value):
|
||||
return None
|
||||
|
||||
|
||||
def _media(key):
|
||||
"""Absolute display URL for a storage key (presigned on R2, absolute-static
|
||||
on local). '' for falsy keys. Used for iPad image rendering."""
|
||||
from app.utils import storage
|
||||
return storage.media_url(key, external=True) if key else ''
|
||||
|
||||
|
||||
def _inspection_payload(inspection):
|
||||
"""Serialize an Inspection to the dict returned in API responses."""
|
||||
# Extract form responses from the notes JSON blob.
|
||||
@@ -137,6 +144,14 @@ def _inspection_payload(inspection):
|
||||
if inspection.completed_at else None,
|
||||
'mobile_local_id': inspection.mobile_local_id,
|
||||
'form_data': form_data,
|
||||
# Absolute display URLs for image form fields (presigned on R2,
|
||||
# absolute-static on local): {field_id: url}. The iPad prefers this
|
||||
# over building ServerConfig + /static/ + value.
|
||||
'form_media': {
|
||||
fid: _media(v)
|
||||
for fid, v in (form_data or {}).items()
|
||||
if isinstance(v, str) and v.startswith('uploads/')
|
||||
},
|
||||
'form_schema': form_schema,
|
||||
'inspector_notes': inspector_notes,
|
||||
# ── Follow-up / re-inspection fields ──────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user