Commit a381cc47 by Damien Moulard

Merge branch 'evolution_bdm' of…

Merge branch 'evolution_bdm' of gl.cooperatic.fr:cooperatic-foodcoops/third-party into evolution_bdm
parents 4ddae949 26fc2d5d
...@@ -1142,6 +1142,12 @@ class CagetteServices(models.Model): ...@@ -1142,6 +1142,12 @@ class CagetteServices(models.Model):
# let authorized people time to set presence for those who came in late # let authorized people time to set presence for those who came in late
end_date = now - datetime.timedelta(hours=3) end_date = now - datetime.timedelta(hours=3)
api = OdooAPI() api = OdooAPI()
absence_status = 'excused'
res_c = api.search_read('ir.config_parameter',
[['key', '=', 'lacagette_membership.absence_status']],
['value'])
if len(res_c) == 1:
absence_status = res_c[0]['value']
cond = [['date_begin', '>=', date_24h_before.isoformat()], cond = [['date_begin', '>=', date_24h_before.isoformat()],
['date_begin', '<=', end_date.isoformat()], ['date_begin', '<=', end_date.isoformat()],
['state', '=', 'open']] ['state', '=', 'open']]
...@@ -1165,7 +1171,7 @@ class CagetteServices(models.Model): ...@@ -1165,7 +1171,7 @@ class CagetteServices(models.Model):
(_h, _m, _s) = h.split(':') (_h, _m, _s) = h.split(':')
if int(_h) < 21: if int(_h) < 21:
ids.append(int(r['id'])) ids.append(int(r['id']))
f = {'state': 'excused'} f = {'state': absence_status}
return {'update': api.update('shift.registration', ids, f), 'reg_shift': res} return {'update': api.update('shift.registration', ids, f), 'reg_shift': res}
@staticmethod @staticmethod
......
...@@ -246,11 +246,9 @@ def request_delay(request): ...@@ -246,11 +246,9 @@ def request_delay(request):
} }
if ('extension_beginning' in request.POST): if ('extension_beginning' in request.POST):
data['extension_beginning'] = request.POST['extension_beginning'] data['extension_beginning'] = request.POST['extension_beginning']
duration = 28
if ('duration' in request.POST): if ('duration' in request.POST):
duration = int(request.POST['duration']) duration = int(request.POST['duration'])
else:
duration = None
response = {'result': False} response = {'result': False}
...@@ -259,8 +257,10 @@ def request_delay(request): ...@@ -259,8 +257,10 @@ def request_delay(request):
if (new_id): if (new_id):
response = {'result': True} response = {'result': True}
else: else:
coop_logger.error("request delay : %s, %s", str(new_id), str(data))
return HttpResponseServerError() return HttpResponseServerError()
except Exception as e: except Exception as e:
coop_logger.error("request delay : %s, %s", str(e), str(data))
return HttpResponseServerError() return HttpResponseServerError()
return JsonResponse(response) return JsonResponse(response)
......
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