Commit c1ebf735 by Damien Moulard

display comittees shifts in shifts history

parent e0e7021d
Pipeline #1529 passed with stage
in 1 minute 30 seconds
...@@ -27,7 +27,7 @@ class CagetteMembersSpace(models.Model): ...@@ -27,7 +27,7 @@ class CagetteMembersSpace(models.Model):
['state', '!=', 'replaced'], ['state', '!=', 'replaced'],
['state', '!=', 'replacing'], ['state', '!=', 'replacing'],
] ]
f = ['create_date', 'shift_id', 'name', 'state', 'is_late', 'is_makeup'] f = ['date_begin', 'shift_id', 'name', 'state', 'is_late', 'is_makeup']
marshal_none_error = 'cannot marshal None unless allow_none is enabled' marshal_none_error = 'cannot marshal None unless allow_none is enabled'
try: try:
...@@ -36,10 +36,45 @@ class CagetteMembersSpace(models.Model): ...@@ -36,10 +36,45 @@ class CagetteMembersSpace(models.Model):
except Exception as e: except Exception as e:
if not (marshal_none_error in str(e)): if not (marshal_none_error in str(e)):
res['error'] = repr(e) res['error'] = repr(e)
coop_logger.error(res['error'] + ' : %s', str(payment_id)) coop_logger.error(res['error'] + ' : %s', str(partner_id))
else: else:
res = [] res = []
# Get committees shifts
committees_shifts_name = getattr(settings, 'ENTRANCE_ADD_PT_EVENT_NAME', 'Validation service comité')
cond = [
['partner_id', '=', partner_id],
['name', '=', committees_shifts_name]
]
f = ['create_date']
try:
# Don't bother having a global pagination, use the same
res_committees_shifts = self.o_api.search_read('shift.counter.event', cond, f, limit=limit, offset=offset,
order='create_date DESC')
for committee_shift in res_committees_shifts:
item = {
"date_begin": committee_shift["create_date"],
"shift_id": False,
"name": "Services des comités",
"state": "done",
"is_late": False,
"is_makeup": False,
}
for index, res_item in enumerate(res):
if (res_item["date_begin"] < item["date_begin"]):
res.insert(index, item)
break
except Exception as e:
if not (marshal_none_error in str(e)):
res['error'] = repr(e)
coop_logger.error(res['error'] + ' : %s', str(partner_id))
else:
res = res + []
except Exception as e: except Exception as e:
print(str(e)) print(str(e))
......
...@@ -48,6 +48,16 @@ function prepare_server_data(data) { ...@@ -48,6 +48,16 @@ function prepare_server_data(data) {
res = []; res = [];
for (history_item of data) { for (history_item of data) {
history_item.shift_name = (history_item.shift_id === false) ? '' : history_item.shift_id[1];
if (history_item.name === "Services des comités") {
let shift_datetime = new Date(history_item.date_begin);
let str_shift_datetime = `${("0" + shift_datetime.getDate()).slice(-2)}/${("0" + (shift_datetime.getMonth() + 1)).slice(-2)}/${shift_datetime.getFullYear()}`
str_shift_datetime = str_shift_datetime + " " + shift_datetime.toLocaleTimeString("fr-fr", time_options);
history_item.shift_name = `Services des comités ${str_shift_datetime}`
}
history_item.details = ''; history_item.details = '';
if (history_item.state === 'excused' || history_item.state === 'absent') { if (history_item.state === 'excused' || history_item.state === 'absent') {
history_item.details = "Absent"; history_item.details = "Absent";
...@@ -58,8 +68,6 @@ function prepare_server_data(data) { ...@@ -58,8 +68,6 @@ function prepare_server_data(data) {
} else if (history_item.state === 'cancel') { } else if (history_item.state === 'cancel') {
history_item.details = "Annulé"; history_item.details = "Annulé";
} }
history_item.shift_name = (history_item.shift_id === false) ? '' : history_item.shift_id[1];
} }
return data; return data;
......
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