Jul 14 - Using CDN - Phase 4a
This commit is contained in:
@@ -51,6 +51,13 @@ _UUID_RE = re.compile(
|
||||
)
|
||||
|
||||
|
||||
def _photo_urls(keys):
|
||||
"""Map storage keys to absolute display URLs (presigned on R2, absolute-static
|
||||
on local). Falsy keys are skipped. Used for iPad photo rendering."""
|
||||
from app.utils import storage
|
||||
return [storage.media_url(k, external=True) for k in keys if k]
|
||||
|
||||
|
||||
def _issue_payload(issue):
|
||||
"""Serialise an Issue to the dict returned in list/detail responses."""
|
||||
facility = issue.resolved_facility
|
||||
@@ -71,6 +78,14 @@ def _issue_payload(issue):
|
||||
'photo_path': issue.photo_path or None,
|
||||
'mobile_photo_paths': issue.mobile_photo_paths or [],
|
||||
'result_photos': issue.result_photos or [],
|
||||
# Absolute display URLs (presigned on R2, absolute-static on local) for
|
||||
# the iPad, which loads photos off-origin. Relative keys above stay as
|
||||
# keys. photo_urls order mirrors the iPad's evidence merge:
|
||||
# [photo_path] + mobile_photo_paths.
|
||||
'photo_urls': _photo_urls(
|
||||
([issue.photo_path] if issue.photo_path else [])
|
||||
+ (issue.mobile_photo_paths or [])),
|
||||
'result_photo_urls': _photo_urls(issue.result_photos or []),
|
||||
# Resolution details — set by web staff after fixing the issue.
|
||||
'result_notes': issue.result_notes or None,
|
||||
# Verification fields — set after a director/admin confirms fix.
|
||||
|
||||
Reference in New Issue
Block a user