Commit 2c65a595 by Damien Moulard

fix merge conflict

parents 6fc24383 67c384d5
Pipeline #2102 passed with stage
in 1 minute 30 seconds
......@@ -758,7 +758,13 @@ def delete_pair(request):
POST:
payload example:
{
"child": {"id": 3075}
"child": {
"id": "1620"
},
"gone": [
"parent",
"child"
]
}
"""
if request.method == 'GET':
......@@ -775,10 +781,14 @@ def delete_pair(request):
child_accounts = api.search_read('res.partner', [['email', '=', child['email']]], ['id', 'email'])
prev_child = [x['id'] for x in child_accounts if x['id'] != child_id]
parent = api.search_read('res.partner', [['id', '=', child['parent_id'][0]]], ['cooperative_state'])[0]
api.update('res.partner', [child_id], {"parent_id": False, "is_associated_people": False})
api.delete('res.partner', [child_id])
api.update('res.partner', [child_id], {"parent_id": False, "is_associated_people": False, "active": False, "is_former_associated_people": True})
child_update_fields = {'cooperative_state': "unsubscribed", "is_former_associated_people": True}
if 'gone' in data and 'child' in data['gone']:
child_update_fields['cooperative_state'] = "gone"
for id in prev_child:
api.update("res.partner", [id], {'cooperative_state': "unsubscribed"})
api.update("res.partner", [id], child_update_fields)
if 'gone' in data and 'parent' in data['gone']:
api.update("res.partner", [parent['id']], {'cooperative_state': "gone", "is_former_associated_people": True})
response = JsonResponse({"message": "Succesfuly unpaired members"}, status=200)
......
......@@ -116,3 +116,7 @@
.spinner {
height:40px;
}
/* Modale */
.attached-members .member div {width: 50px; display: inline-block;}
.attached-members .member div.name {width: 80%;}
\ No newline at end of file
......@@ -195,8 +195,14 @@ function display_attached_members() {
}
function delete_pair(childId) {
var payload = {"child": {"id": childId}};
function delete_pair(childId, gone_checked) {
var payload = {"child": {"id": childId}, "gone": []};
if (gone_checked.length > 0) {
$.each(gone_checked, function(i,e) {
const elts = $(e).attr('name').split("_")
payload['gone'].push(elts[0])
});
}
$.ajax({
type: "POST",
......@@ -230,9 +236,10 @@ function confirmDeletion(childId) {
modalContent = modalContent.html();
openModal(modalContent, () => {
if (is_time_to('delete_pair')) {
const gone_checked = $('input.after_unattached_state:checked');
closeModal();
openModal();
delete_pair(childId);
delete_pair(childId, gone_checked);
}
}, 'Valider', false);
}
......
......@@ -230,9 +230,11 @@ function _really_save_new_coop(email, fname, lname, cap, pm, cn, bc, msex) {
function store_new_coop(event) {
event.preventDefault();
var errors = [],
bc = '', // barcode may not be present
msex = ''; // sex may not be present
msex = '', // sex may not be present
active_asso_area = $('#associate_area .choice_active'); // need to ckeck if associated data are available
// 1- Un coop avec le meme mail ne doit pas exister dans odoo (dans base intermediaire, le cas est géré par l'erreur à l'enregistrement)
let email = $('input[name="email"]').val()
.trim(),
......@@ -257,6 +259,19 @@ function store_new_coop(event) {
}
}
if (active_asso_area.length > 0) {
// If user click as if a "binôme" is beeing created, data about parent member must exist
let associated_data_ok = false;
if (
($(active_asso_area[0]).attr('id') === "new_member_choice" && $('#new_member_input').val().trim().length > 0)
||
($(active_asso_area[0]).attr('id') === "existing_member_choice" && $('#existing_member_choice_action .chosen_associate div.member').length > 0)
) {
associated_data_ok = true;
}
if (associated_data_ok === false) errors.push("Le membre 'titulaire' du binôme n'est pas défini");
}
$.ajax({url : '/members/exists/' + email,
dataType :'json'
})
......@@ -294,7 +309,6 @@ function store_new_coop(event) {
}
}
});
}
......@@ -670,7 +684,7 @@ function display_possible_members() {
if (member.id == $(this).attr('member_id')) {
selected_associate = member;
var member_button = '<div member_id="' + member.id + '">' + member.barcode_base + ' - ' + member.name + '</button>';
var member_button = '<div member_id="' + member.id + '" class="member">' + member.barcode_base + ' - ' + member.name + '</div>';
$('.chosen_associate').html(member_button);
$('.chosen_associate_area').show();
......
......@@ -29,6 +29,11 @@ footer { position: fixed;
z-index: 10;
}
.warning_instruction {
font-weight: bold;
font-style: italic;
color: blue;
}
#deconnect, #password_change {float:right; margin-left: 5px;}
/* The Overlay (background) */
......
......@@ -16,15 +16,26 @@
{% block content %}
<div id="template" style="display:None;">
<div id="confirmModal">
<div class="mconfirm">
<h3>Le binôme est sur le point d'être désolidarisé</h3>
<br />
<p>Êtes-vous sur de vouloir désolidariser <b><span id="parentName"></span></b> et
<b><span id="childName"></span></b>
<div>
Êtes-vous sur de vouloir désolidariser
<div class="attached-members">
<div class="member">
<div class="name"><strong><span id="parentName"></span></strong> (titulaire)</div>
<div><input type="checkbox" name="parent_gone" class="after_unattached_state" /></div>
</div>
<div class="member">
<div class="name"><strong><span id="childName"></span></strong></div>
<div><input type="checkbox" name="child_gone" class="after_unattached_state" /></div>
</div>
</div>
</div>
<p class="warning_instruction">
Dans le cas d'une désolidarisation liée à une démission de la coopérative,<br/> cochez le membre que vous souhaitez mettre en statut "Parti·e"
</p>
<hr/>
</div>
</div>
</div>
<div class="page_body">
<div id="back_to_admin_index">
......
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