[FIX] Attendance API: return zone name or coordinates with fallback

This commit is contained in:
Mazen Abdo 2025-10-27 19:22:51 +03:00
parent 348bee333d
commit 9d8dc0754b
2 changed files with 9 additions and 6 deletions

View File

@ -193,7 +193,8 @@ class AttendanceController(http.Controller):
'action_type':"system_checkout" if body.get('action') == 'sign_out' and system_checkout == True else 'application',
'name': fields.datetime.now(),
# 'device_id':body.get('device_id'),
'zone':zone.zone if zone else "%s,%s" % (body.get('longitude'), body.get('latitude')),
'zone': (zone.zone or zone.name) if zone else "%s,%s" % (body.get('longitude'), body.get('latitude')),
'zone_name': zone.id if zone else False,
'longitude': body.get('longitude'),
'latitude':body.get('latitude'),
})
@ -208,7 +209,7 @@ class AttendanceController(http.Controller):
"action": attendance.action,
"attendance_status": attendance.action,
"time": str(date),
"zone": attendance.zone,
"zone": (attendance.zone_name.zone or attendance.zone_name.name) if attendance.zone_name else attendance.zone,
"longitude": attendance.longitude,
"latitude": attendance.latitude,
"range": zone.allowed_range if zone else False,

View File

@ -153,7 +153,7 @@ class AttendanceController(http.Controller):
if attendance:
date = attendance.name.time()
data.update({'id': attendance.id , 'action': attendance.action,
'attendance_status': attendance.action, 'time': str(date), 'zone': attendance.zone,
'attendance_status': attendance.action, 'time': str(date), 'zone': (attendance.zone_name.zone or attendance.zone_name.name) if attendance.zone_name else attendance.zone,
'longitude': attendance.longitude, 'latitude': attendance.latitude})
_logger.error(data)
return http_helper.response(message="Refresh Successfully", data=data)
@ -229,7 +229,8 @@ class AttendanceController(http.Controller):
'action_type':"system_checkout" if body.get('action') == 'sign_out' and system_checkout == True else 'application',
'name': fields.datetime.now(),
# 'device_id':body.get('device_id'),
'zone':zone.zone if zone else "%s,%s" % (body.get('longitude'), body.get('latitude')),
'zone': (zone.zone or zone.name) if zone else "%s,%s" % (body.get('longitude'), body.get('latitude')),
'zone_name': zone.id if zone else False,
'longitude': body.get('longitude'),
'latitude':body.get('latitude'),
})
@ -245,7 +246,7 @@ class AttendanceController(http.Controller):
"action": attendance.action,
"attendance_status": attendance.action,
"time": str(date),
"zone": attendance.zone,
"zone": (attendance.zone_name.zone or attendance.zone_name.name) if attendance.zone_name else attendance.zone,
"longitude": attendance.longitude,
"latitude": attendance.latitude,
"range": zone.allowed_range if zone else False,
@ -466,7 +467,8 @@ class AttendanceController(http.Controller):
'action': 'sign_out',
'action_type': 'auto',
'name': last,
'zone': "%s,%s" % (body.get('longitude'), body.get('latitude')),
'zone': (zone.zone or zone.name) if zone else "%s,%s" % (body.get('longitude'), body.get('latitude')),
'zone_name': zone.id if zone else False,
'longitude': body.get('longitude'),
'latitude': body.get('latitude'),
})