06/11 Update API to support Mobile GPS
This commit is contained in:
@@ -322,6 +322,19 @@ def create_inspection():
|
|||||||
if completed_at is None and status == 'completed':
|
if completed_at is None and status == 'completed':
|
||||||
completed_at = now_eastern()
|
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(
|
inspection = Inspection(
|
||||||
template_id = template_id,
|
template_id = template_id,
|
||||||
facility_id = facility_id,
|
facility_id = facility_id,
|
||||||
@@ -334,6 +347,8 @@ def create_inspection():
|
|||||||
completed_at = completed_at if status == 'completed' else None,
|
completed_at = completed_at if status == 'completed' else None,
|
||||||
mobile_local_id = mobile_local_id,
|
mobile_local_id = mobile_local_id,
|
||||||
parent_inspection_id = parent_inspection_id,
|
parent_inspection_id = parent_inspection_id,
|
||||||
|
submit_latitude = submit_latitude,
|
||||||
|
submit_longitude = submit_longitude,
|
||||||
)
|
)
|
||||||
|
|
||||||
db.session.add(inspection)
|
db.session.add(inspection)
|
||||||
|
|||||||
Reference in New Issue
Block a user