Commit 3c00ed51 by Thibault Grandjean

retrieve member info

parent b22feabf
Pipeline #1851 passed with stage
in 1 minute 30 seconds
......@@ -405,4 +405,56 @@ def delete_shift_registration(request):
else:
res["message"] = "Unauthorized"
response = JsonResponse(res, status=403)
return response
\ No newline at end of file
return response
# Gestion des binômes
def get_member_info(request, member_id):
"""Retrieve information about a member."""
res = {}
is_connected_user = CagetteUser.are_credentials_ok(request)
if is_connected_user:
api = OdooAPI()
fields = [
'id',
'sex',
'cooperative_state',
'email',
'street',
'street2',
'zip',
'city',
'current_template_name',
'shift_type',
'parent_id',
'is_associated_people',
]
member = api.search_read('res.partner', [['id', '=', member_id]], fields)
# get incomming shifts
fields = [
"date_begin",
"date_end",
"final_standard_point",
"shift_id",
"shift_type",
"partner_id",
"id",
]
cond = [
["partner_id.id", "=", member_id],
["state", "=", "open"],
["date_begin", ">", datetime.datetime.now().isoformat()],
]
shifts = api.search_read('shift.registration', cond, fields, order="date_begin ASC")
if member:
res['member'] = member[0]
res['member']['incoming_shifts'] = shifts
response = JsonResponse(res)
else:
response = JsonResponse({"message": "Not found"}, status=404)
else:
res['message'] = "Unauthorized"
response = JsonResponse(res, status=403)
print(response.content)
return response
......@@ -61,4 +61,6 @@ urlpatterns = [
url(r'^get_makeups_members$', admin.get_makeups_members),
url(r'^update_members_makeups$', admin.update_members_makeups),
url(r'^delete_shift_registration$', admin.delete_shift_registration),
url(r'^get_member_info/(\d+)$', admin.get_member_info),
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment