06/11 Update API to support Mobile GPS

This commit is contained in:
Nguyen Ngo
2026-06-11 15:53:56 -04:00
parent fc3e50c669
commit 8f7f8dbaff
+15
View File
@@ -322,6 +322,19 @@ def create_inspection():
if completed_at is None and status == 'completed':
completed_at = now_eastern()
# ── GPS (mobile submission) ───────────────────────────────────────────
# The iPad sends submit_latitude / submit_longitude when CoreLocation
# granted permission and a fix was obtained before the inspector confirmed
# submission. Both fields are nullable — absence is silently ignored.
_lat = data.get('submit_latitude')
_lng = data.get('submit_longitude')
try:
submit_latitude = float(_lat) if _lat is not None else None
submit_longitude = float(_lng) if _lng is not None else None
except (ValueError, TypeError):
submit_latitude = None
submit_longitude = None
inspection = Inspection(
template_id = template_id,
facility_id = facility_id,
@@ -334,6 +347,8 @@ def create_inspection():
completed_at = completed_at if status == 'completed' else None,
mobile_local_id = mobile_local_id,
parent_inspection_id = parent_inspection_id,
submit_latitude = submit_latitude,
submit_longitude = submit_longitude,
)
db.session.add(inspection)