Commit 4d3070db by Damien Moulard

force status update after delay creation

parent 0825e1e6
...@@ -61,21 +61,22 @@ class CagetteMember(models.Model): ...@@ -61,21 +61,22 @@ class CagetteMember(models.Model):
image = res[0]['image_medium'] image = res[0]['image_medium']
return image return image
# def update_member_points(self, status): def update_member_points(self, data):
"""
# fields = {'name': reason, ex:
# 'shift_id': False, data = {
# 'type': stype, 'name': reason,
# 'partner_id': self.id, 'shift_id': False,
# 'point_qty': pts 'type': stype,
# } 'partner_id': self.id,
# return self.o_api.create('shift.counter.event', fields) 'point_qty': pts
}
# if status not in ["suspended", "delay", "up_to_date", "unsuscribed", "alert"]: """
# raise Exception("Bad status")
# f = { 'cooperative_state': "delay" } try:
# return self.o_api.update('res.partner', [self.id], f) return self.o_api.create('shift.counter.event', data)
except Exception as e:
print(str(e))
# # # BDM # # # BDM
......
...@@ -276,6 +276,7 @@ def request_delay(request): ...@@ -276,6 +276,7 @@ def request_delay(request):
if 'verif_token' in request.POST: if 'verif_token' in request.POST:
if Verification.verif_token(request.POST.get('verif_token'), int(request.POST.get('idPartner'))) is True: if Verification.verif_token(request.POST.get('verif_token'), int(request.POST.get('idPartner'))) is True:
cs = CagetteShift() cs = CagetteShift()
partner_id = int(request.POST['idPartner'])
use_new_members_space = getattr(settings, 'USE_NEW_MEMBERS_SPACE', False) use_new_members_space = getattr(settings, 'USE_NEW_MEMBERS_SPACE', False)
if use_new_members_space is True: if use_new_members_space is True:
...@@ -285,7 +286,7 @@ def request_delay(request): ...@@ -285,7 +286,7 @@ def request_delay(request):
return JsonResponse(res, status=403) return JsonResponse(res, status=403)
data = { data = {
"idPartner": int(request.POST['idPartner']), "idPartner": partner_id,
"start_date" : request.POST['start_date'] "start_date" : request.POST['start_date']
} }
if ('extension_beginning' in request.POST): if ('extension_beginning' in request.POST):
...@@ -299,6 +300,30 @@ def request_delay(request): ...@@ -299,6 +300,30 @@ def request_delay(request):
try: try:
new_id = cs.create_delay(data, duration) new_id = cs.create_delay(data, duration)
if (new_id): if (new_id):
try:
cm = CagetteMember(partner_id)
# Add 0 pt to counter so odoo updates member status
data = {
'name': "Forcer l'entrée en délai",
'shift_id': False,
'type': "standard",
'partner_id': partner_id,
'point_qty': 0
}
cm.update_member_points(data)
data = {
'name': "Forcer l'entrée en délai",
'shift_id': False,
'type': "ftop",
'partner_id': partner_id,
'point_qty': 0
}
cm.update_member_points(data)
except Exception as e:
print(str(e))
response = {'result': True} response = {'result': True}
else: else:
coop_logger.error("request delay : %s, %s", str(new_id), str(data)) coop_logger.error("request delay : %s, %s", str(new_id), str(data))
......
...@@ -57,9 +57,9 @@ ...@@ -57,9 +57,9 @@
<div id="calendar_explaination_template"> <div id="calendar_explaination_template">
<h4>Légende du calendrier</h4> <h4>Légende du calendrier</h4>
<a class="example-event fc-daygrid-event fc-daygrid-block-event fc-h-event fc-event fc-event-start fc-event-end fc-event-future shift_booked"><div class="fc-event-main"><div class="fc-event-main-frame"><div class="fc-event-time">06:00</div><div class="fc-event-title-container"><div class="fc-event-title fc-sticky">&nbsp;-- 9/12</div></div></div></div></a> <a class="example-event fc-daygrid-event fc-daygrid-block-event fc-h-event fc-event fc-event-start fc-event-end fc-event-future shift_booked"><div class="fc-event-main"><div class="fc-event-main-frame"><div class="fc-event-time">06:00</div><div class="fc-event-title-container"><div class="fc-event-title fc-sticky">&nbsp;- 9/12</div></div></div></div></a>
<p>Un service colorié en noir : je suis déjà inscrit.e à ce service.</p> <p>Un service colorié en noir : je suis déjà inscrit.e à ce service.</p>
<a class="example-event fc-daygrid-event fc-daygrid-block-event fc-h-event fc-event fc-event-start fc-event-end fc-event-future shift_less_alf"><div class="fc-event-main"><div class="fc-event-main-frame"><div class="fc-event-time">10:45</div><div class="fc-event-title-container"><div class="fc-event-title fc-sticky">&nbsp;-- 3/12</div></div></div></div></a> <a class="example-event fc-daygrid-event fc-daygrid-block-event fc-h-event fc-event fc-event-start fc-event-end fc-event-future shift_less_alf"><div class="fc-event-main"><div class="fc-event-main-frame"><div class="fc-event-time">10:45</div><div class="fc-event-title-container"><div class="fc-event-title fc-sticky">&nbsp;- 3/12</div></div></div></div></a>
<p>Un service colorié en bleu : je peux m'inscrire à ce service.</p> <p>Un service colorié en bleu : je peux m'inscrire à ce service.</p>
<p>3/12 <i class="arrow_explanation_numbers fas fa-arrow-right"></i> il y a déjà 3 places réservées à ce service sur 12 disponibles. <p>3/12 <i class="arrow_explanation_numbers fas fa-arrow-right"></i> il y a déjà 3 places réservées à ce service sur 12 disponibles.
<b>Plus le chiffre de gauche est petit, plus on a besoin de coopérateurs.rices à ce service !</b></p> <b>Plus le chiffre de gauche est petit, plus on a besoin de coopérateurs.rices à ce service !</b></p>
......
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