Commit 67c384d5 by François C.

#2836 : Can set status as 'gone' for members who are unassociated (via members/admin interface)

parent bc637211
Pipeline #2099 passed with stage
in 1 minute 27 seconds
......@@ -710,7 +710,13 @@ def delete_pair(request):
POST:
payload example:
{
"child": {"id": 3075}
"child": {
"id": "1620"
},
"gone": [
"parent",
"child"
]
}
"""
if request.method == 'GET':
......@@ -727,10 +733,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",
......@@ -229,9 +235,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);
}
......
......@@ -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