Commit 2bafd38f by Etienne Freiss

Merge branch 'evolution_bdm' into ticket_1738

parents 2f953b53 e0e7021d
Pipeline #1527 passed with stage
in 1 minute 31 seconds
......@@ -357,13 +357,31 @@ def update_members_makeups(request):
res["res"].append(cm.update_member_makeups(member_data))
if "decrement_pts" in member_data and member_data["decrement_pts"] is True:
# Update member standard points, for standard members only
if member_data["member_shift_type"] == "standard":
# Set points to minus the number of makeups to do (limited to -2)
target_points = - int(member_data["target_makeups_nb"])
if (target_points < -2) :
target_points = -2
member_points = cm.get_member_points("standard")
points_diff = abs(member_points - target_points)
# Don't update if no change
if points_diff == 0:
continue
if member_points > target_points:
points_update = - points_diff
else:
points_update = points_diff
data = {
'name': "Ajout manuel d'un rattrapage depuis l'admin BDM",
'name': "Modif manuelle des rattrapages depuis l'admin BDM",
'shift_id': False,
'type': member_data["member_shift_type"],
'partner_id': int(member_data["member_id"]),
'point_qty': -1
'point_qty': points_update
}
cm.update_member_points(data)
......
......@@ -61,6 +61,18 @@ class CagetteMember(models.Model):
image = res[0]['image_medium']
return image
def get_member_points(self, shift_type):
points_field = 'final_standard_point' if shift_type == "standard" else 'final_ftop_point'
cond = [['id', '=', self.id]]
fields = ['id', points_field]
res = self.o_api.search_read('res.partner', cond, fields)
if res and len(res) == 1:
return res[0][points_field]
else:
return None
def update_member_points(self, data):
"""
ex:
......
......@@ -165,7 +165,7 @@ function display_makeups_members() {
openModal(
`Enlever un rattrapage à ${member.name} ?`,
() => {
decrement_makeups([member_id]);
update_members_makeups([member_id], "decrement");
},
"Confirmer",
false
......@@ -182,7 +182,7 @@ function display_makeups_members() {
openModal(
`Ajouter un rattrapage à ${member.name} ?`,
() => {
increment_makeups([member_id]);
update_members_makeups([member_id], "increment");
},
"Confirmer",
false
......@@ -212,7 +212,7 @@ function display_makeups_members() {
openModal(
`Enlever un rattrapage aux membres sélectionnés ?`,
() => {
decrement_makeups(selected_rows);
update_members_makeups(selected_rows, "decrement");
},
"Confirmer",
false
......@@ -228,64 +228,25 @@ function display_makeups_members() {
/**
* Send request to update members nb of makeups to do
*
* @param {Array} member_ids
* @param {String} action increment | decrement
*/
function decrement_makeups(member_ids) {
function update_members_makeups(member_ids, action) {
openModal();
data = [];
for (mid of member_ids) {
member_index = makeups_members.findIndex(m => m.id == mid);
if (action === "increment") {
makeups_members[member_index].makeups_to_do += 1;
} else {
makeups_members[member_index].makeups_to_do -= 1;
data.push({
member_id: mid,
target_makeups_nb: makeups_members[member_index].makeups_to_do
});
}
$.ajax({
type: 'POST',
url: "/members/update_members_makeups",
data: JSON.stringify(data),
dataType:"json",
traditional: true,
contentType: "application/json; charset=utf-8",
success: function() {
selected_rows = [];
display_makeups_members();
closeModal();
},
error: function(data) {
err = {msg: "erreur serveur pour décrémenter les rattrapages", ctx: 'decrement_makeups'};
if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') {
err.msg += ' : ' + data.responseJSON.error;
}
report_JS_error(err, 'members_admin');
closeModal();
alert('Erreur serveur pour décrémenter les rattrapages. Ré-essayez plus tard.');
}
});
}
/**
* Send request to update members nb of makeups to do
* @param {Array} member_ids
*/
function increment_makeups(member_ids) {
openModal();
data = [];
for (mid of member_ids) {
member_index = makeups_members.findIndex(m => m.id == mid);
makeups_members[member_index].makeups_to_do += 1;
console.log(makeups_members[member_index]);
data.push({
member_id: mid,
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
});
}
......@@ -303,14 +264,14 @@ function increment_makeups(member_ids) {
closeModal();
},
error: function(data) {
err = {msg: "erreur serveur pour incrémenter les rattrapages", ctx: 'increment_makeups'};
err = {msg: "erreur serveur pour décrémenter les rattrapages", ctx: 'decrement_makeups'};
if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') {
err.msg += ' : ' + data.responseJSON.error;
}
report_JS_error(err, 'members_admin');
closeModal();
alert('Erreur serveur pour incrémenter les rattrapages. Ré-essayez plus tard.');
alert('Erreur serveur pour crémenter les rattrapages. Ré-essayez plus tard.');
}
});
}
......@@ -360,7 +321,7 @@ function display_possible_members() {
openModal(
`Ajouter un rattrapage à ${member.name} ?`,
() => {
increment_makeups([member.id]);
update_members_makeups([member.id], "increment");
members_search_results = [];
$('#search_member_input').val('');
$('.search_member_results_area').hide();
......
......@@ -125,11 +125,23 @@
margin: 1px 10px !important;
}
.fc-event {
background-color: #008AD9;
border-color: #008AD9;
color: white;
}
td{
--fc-list-event-hover-bg-color:#005BA6;
}
.fc-event.shift_booked {
background-color: #585858;
cursor: auto;
border-color: #585858;
}
.fc-event.shift_booked td {
--fc-list-event-hover-bg-color:#585858;
}
.fc-list-event.shift_booked {
color: white;
......
<div id="my_info">
<div class="page_title txtcenter">
<h1>Mes Infos Perso</h1>
<h1>Mes Infos</h1>
</div>
<div class="tiles_container">
<div class="tile full_width_tile" id="my_info_area">
......
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