Commit e0331aec by Etienne Freiss

Merge branch 'evolution_bdm' of…

Merge branch 'evolution_bdm' of https://gl.cooperatic.fr/cooperatic-foodcoops/third-party into ticket_1677
parents baa689f0 10ef839e
Pipeline #1502 passed with stage
in 1 minute 33 seconds
...@@ -345,12 +345,28 @@ def get_makeups_members(request): ...@@ -345,12 +345,28 @@ def get_makeups_members(request):
return JsonResponse({ 'res' : res }) return JsonResponse({ 'res' : res })
def update_members_makeups(request): def update_members_makeups(request):
""" Décrémente les rattrapages des membres passés dans la requête """ """ Met à jour les rattrapages des membres passés dans la requête """
res = {} res = {}
is_connected_user = CagetteUser.are_credentials_ok(request) is_connected_user = CagetteUser.are_credentials_ok(request)
if is_connected_user is True: if is_connected_user is True:
members_data = json.loads(request.body.decode()) members_data = json.loads(request.body.decode())
res["res"] = CagetteMembers.update_members_makeups(members_data)
res["res"] = []
for member_data in members_data:
cm = CagetteMember(int(member_data["member_id"]))
res["res"].append(cm.update_member_makeups(member_data))
if "decrement_pts" in member_data and member_data["decrement_pts"] is True:
data = {
'name': "Ajout manuel d'un rattrapage depuis l'admin BDM",
'shift_id': False,
'type': member_data["member_shift_type"],
'partner_id': int(member_data["member_id"]),
'point_qty': -1
}
cm.update_member_points(data)
response = JsonResponse(res) response = JsonResponse(res)
else: else:
......
...@@ -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")
try:
# f = { 'cooperative_state': "delay" } return self.o_api.create('shift.counter.event', data)
# return self.o_api.update('res.partner', [self.id], f) except Exception as e:
print(str(e))
# # # BDM # # # BDM
...@@ -826,6 +827,19 @@ class CagetteMember(models.Model): ...@@ -826,6 +827,19 @@ class CagetteMember(models.Model):
except: except:
return None return None
def update_member_makeups(self, member_data):
api = OdooAPI()
res = {}
f = { 'makeups_to_do': int(member_data["target_makeups_nb"]) }
res_item = api.update('res.partner', [self.id], f)
res = {
'mid': self.id,
'update': res_item
}
return res
class CagetteMembers(models.Model): class CagetteMembers(models.Model):
"""Class to manage operations on all members or part of them.""" """Class to manage operations on all members or part of them."""
...@@ -1051,25 +1065,10 @@ class CagetteMembers(models.Model): ...@@ -1051,25 +1065,10 @@ class CagetteMembers(models.Model):
def get_makeups_members(): def get_makeups_members():
api = OdooAPI() api = OdooAPI()
cond = [['makeups_to_do','>', 0]] cond = [['makeups_to_do','>', 0]]
fields = ['id', 'name', 'makeups_to_do'] fields = ['id', 'name', 'makeups_to_do','shift_type']
res = api.search_read('res.partner', cond, fields) res = api.search_read('res.partner', cond, fields)
return res return res
@staticmethod
def update_members_makeups(members_data):
api = OdooAPI()
res = []
for member_data in members_data:
member_id = int(member_data["member_id"])
f = { 'makeups_to_do': int(member_data["target_makeups_nb"]) }
res_item = api.update('res.partner', [member_id], f)
res.append({
'mid': member_id,
'update': res_item
})
return res
class CagetteServices(models.Model): class CagetteServices(models.Model):
"""Class to handle cagette Odoo services.""" """Class to handle cagette Odoo services."""
...@@ -1174,7 +1173,7 @@ class CagetteServices(models.Model): ...@@ -1174,7 +1173,7 @@ class CagetteServices(models.Model):
dateutil.parser.parse(s['date_begin_tz']).replace(tzinfo=None) dateutil.parser.parse(s['date_begin_tz']).replace(tzinfo=None)
).total_seconds() / 60 > default_acceptable_minutes_after_shift_begins ).total_seconds() / 60 > default_acceptable_minutes_after_shift_begins
if with_members is True: if with_members is True:
cond = [['id', 'in', s['registration_ids']], ['state', '!=', 'cancel']] cond = [['id', 'in', s['registration_ids']], ['state', 'not in', ['cancel', 'waiting', 'draft']]]
fields = ['partner_id', 'shift_type', 'state', 'is_late'] fields = ['partner_id', 'shift_type', 'state', 'is_late']
members = api.search_read('shift.registration', cond, fields) members = api.search_read('shift.registration', cond, fields)
s['members'] = sorted(members, key=lambda x: x['partner_id'][0]) s['members'] = sorted(members, key=lambda x: x['partner_id'][0])
......
...@@ -123,7 +123,7 @@ function display_makeups_members() { ...@@ -123,7 +123,7 @@ function display_makeups_members() {
"Tout" "Tout"
] ]
], ],
iDisplayLength: -1, iDisplayLength: 25,
oLanguage: { oLanguage: {
"sProcessing": "Traitement en cours...", "sProcessing": "Traitement en cours...",
"sSearch": "Rechercher dans le tableau", "sSearch": "Rechercher dans le tableau",
...@@ -280,9 +280,13 @@ function increment_makeups(member_ids) { ...@@ -280,9 +280,13 @@ function increment_makeups(member_ids) {
member_index = makeups_members.findIndex(m => m.id == mid); member_index = makeups_members.findIndex(m => m.id == mid);
makeups_members[member_index].makeups_to_do += 1; makeups_members[member_index].makeups_to_do += 1;
console.log(makeups_members[member_index]);
data.push({ data.push({
member_id: mid, member_id: mid,
target_makeups_nb: makeups_members[member_index].makeups_to_do target_makeups_nb: makeups_members[member_index].makeups_to_do,
decrement_pts: (makeups_members[member_index].makeups_to_do == 1),
member_shift_type: makeups_members[member_index].shift_type
}); });
} }
...@@ -349,7 +353,8 @@ function display_possible_members() { ...@@ -349,7 +353,8 @@ function display_possible_members() {
makeups_members.unshift({ makeups_members.unshift({
id: member.id, id: member.id,
name: member.name, name: member.name,
makeups_to_do: 0 makeups_to_do: 0,
shift_type: member.shift_type
}); });
openModal( openModal(
......
...@@ -204,33 +204,23 @@ body { ...@@ -204,33 +204,23 @@ body {
color: #d9534f; color: #d9534f;
} }
.member_shift_name_area {
margin-top: 10px;
}
.member_shift_name_area, .member_shift_name_area,
.member_coop_number_area { .member_coop_number_area {
margin-bottom: 10px; margin-bottom: 10px;
} }
.member_shift_name_area,
.member_coop_number_area,
.member_associated_partner_area { .member_associated_partner_area {
font-size: 1.9rem; font-size: 1.9rem;
line-height: 1.3; line-height: 1.3;
} }
@media screen and (max-width: 380px) { @media screen and (max-width: 380px) {
.member_shift_name_area,
.member_coop_number_area,
.member_associated_partner_area { .member_associated_partner_area {
font-size: 1.6rem; font-size: 1.6rem;
} }
} }
@media screen and (max-width: 992px) { @media screen and (max-width: 992px) {
.member_shift_name_area,
.member_coop_number_area,
.member_associated_partner_area { .member_associated_partner_area {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
......
...@@ -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))
......
...@@ -216,7 +216,7 @@ ...@@ -216,7 +216,7 @@
</div> </div>
<div class="grp_text"> <div class="grp_text">
Si tu ne comprends pas pourquoi tu es désinscrit.e ou suspendu.e, tu peux le signaler au bureau des membres pour qu'il règle ton problème. N'hésite pas à renseigner un maximum d'information sur ta situation pour nous aider à régler ton problème : <br /> Si tu ne comprends pas pourquoi tu es désinscrit.e ou en rattrapage, tu peux le signaler au bureau des membres pour qu'il règle ton problème. N'hésite pas à renseigner un maximum d'information sur ta situation pour nous aider à régler ton problème : <br />
</div> </div>
<div class="faq_link_button_area"> <div class="faq_link_button_area">
<a <a
......
...@@ -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>
......
...@@ -41,9 +41,7 @@ ...@@ -41,9 +41,7 @@
Numéro de coop Numéro de coop
</div> </div>
<div class="my_info_line_right member_coop_number_area"> <div class="my_info_line_right member_coop_number_area">
<div class="member_coop_number_area"> <span class="member_coop_number member_info"></span>
<span class="member_coop_number member_info"></span>
</div>
</div> </div>
</div> </div>
<div class="my_info_line member_email_line"> <div class="my_info_line member_email_line">
...@@ -105,4 +103,4 @@ ...@@ -105,4 +103,4 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>
\ No newline at end of file
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