Commit 4bb7bd46 by Félicie

Merge branch 'dev_cooperatic' into 2170-create-delete-binome

parents b22feabf 5bd03ef4
......@@ -119,6 +119,7 @@ votre nom ou numéro ci-dessous
UNSUBSCRIBED_FORM_LINK = 'https://docs.google.com/forms/d/e/1FAIpQLScWcpls-ruYIp7HdrjRF1B1TyuzdqhvlUIcUWynbEujfj3dTg/viewform'
UNSUBSCRIBED_MSG = 'Vous êtes désincrit·e, merci de remplir <a href="https://docs.google.com/forms/d/e/1FAIpQLSfPiC2PkSem9x_B5M7LKpoFNLDIz0k0V5I2W3Mra9AnqnQunw/viewform">ce formulaire</a> pour vous réinscrire sur un créneau.<br />Vous pouvez également contacter le Bureau des Membres en remplissant <a href="https://docs.google.com/forms/d/e/1FAIpQLSeZP0m5-EXPVJxEKJk6EjwSyZJtnbiGdYDuAeFI3ENsHAOikg/viewform">ce formulaire</a>'
CONFIRME_PRESENT_BTN = 'Clique ici pour valider ta présence'
BLOCK_ACTIONS_FOR_ATTACHED_PEOPLE = False
RECEPTION_PB = "Ici, vous pouvez signaler toute anomalie lors d'une réception, les produits non commandés, cassés ou pourris. \
......
......@@ -44,7 +44,7 @@ class CagetteMembersSpace(models.Model):
['state', '!=', 'replaced'],
['state', '!=', 'replacing'],
]
f = ['create_date', 'date_begin', 'shift_id', 'name', 'state', 'is_late', 'is_makeup']
f = ['create_date', 'date_begin', 'shift_id', 'name', 'state', 'is_late', 'is_makeup','associate_registered']
marshal_none_error = 'cannot marshal None unless allow_none is enabled'
try:
......
......@@ -52,7 +52,6 @@
#shifts_list {
flex-direction: column;
display: none;
width: min-content;
max-width: 100%;
white-space: nowrap;
}
......@@ -66,11 +65,13 @@
}
.selectable_shift_line {
min-width: 325px;
display: flex;
align-items: center;
margin-left: 15px;
margin: 0.75rem 0;
border-radius: 5px;
margin-right: 15px;
}
.selectable_shift_line .checkbox {
......@@ -81,6 +82,15 @@
cursor: not-allowed;
}
.affect_associate_registered {
display: flex;
align-items: center;
margin-left: 15px;
margin: 0.75rem 0;
border-radius: 5px;
}
/* -- Calendar screen, makeups message */
#need_to_select_makeups_message {
......
......@@ -55,7 +55,7 @@ $(document).ready(function() {
toggleHeader();
});
if (partner_data.is_associated_people === "True") {
if (partner_data.is_associated_people === "True" && block_actions_for_attached_people === "True") {
$(".pairs_info").show();
}
});
......@@ -66,6 +66,32 @@ function prepare_server_data(data) {
}
}
if (history_item.associate_registered == false || history_item.associate_registered == undefined) {
history_item.associate_registered = "";
}
else {
if (partner_data.associated_partner_id != "False") {
if (history_item.associate_registered==="partner") {
history_item.associate_registered = partner_data.name;
} else if (history_item.associate_registered==="associate") {
history_item.associate_registered = partner_data.associated_partner_name;
} else if (history_item.associate_registered==="both") {
history_item.associate_registered = "Les deux";
} else {
history_item.associate_registered = "";
}
} else if (partner_data.parent_id != "False") {
if (history_item.associate_registered==="partner") {
history_item.associate_registered = partner_data.parent_name;
} else if (history_item.associate_registered==="associate") {
history_item.associate_registered = partner_data.name;
} else if (history_item.associate_registered==="both") {
history_item.associate_registered = "Les deux";
} else {
history_item.associate_registered = "";
}
}
}
history_item.details = '';
if (history_item.state === 'excused' || history_item.state === 'absent') {
history_item.details = "Absent.e";
......@@ -87,7 +113,6 @@ function prepare_server_data(data) {
function init_history() {
$(".loading-history").hide();
$("#history").show();
if (partner_history.length === 0) {
$("#history").empty()
.text("Aucun historique... pour l'instant !");
......@@ -103,7 +128,7 @@ function init_history() {
{
data: "shift_name",
title: "<spans class='dt-body-center'>Service</span>",
width: "60%",
width: "50%",
orderable: false
},
{
......@@ -111,6 +136,11 @@ function init_history() {
title: "Détails",
className: "tablet-l desktop",
orderable: false
},
{
data: "associate_registered",
title: "",
orderable: false
}
],
iDisplayLength: -1,
......@@ -157,6 +187,28 @@ function init_incoming_shifts() {
for (shift of incoming_shifts) {
let shift_line_template = prepare_shift_line_template(shift.date_begin);
if (partner_data.associated_partner_id != "False") {
if (shift.associate_registered==="partner") {
shift_line_template.find(".shift_line_associate").text(' - '+partner_data.name+'');
} else if (shift.associate_registered==="associate") {
shift_line_template.find(".shift_line_associate").text(' - '+partner_data.associated_partner_name+'');
} else if (shift.associate_registered==="both") {
shift_line_template.find(".shift_line_associate").text(' - Les deux');
} else {
shift_line_template.find(".shift_line_associate").text('A définir');
}
} else if (partner_data.parent_id != "False") {
if (shift.associate_registered==="partner") {
shift_line_template.find(".shift_line_associate").text(' - '+partner_data.parent_name+'');
} else if (shift.associate_registered==="associate") {
shift_line_template.find(".shift_line_associate").text(' - '+partner_data.name+'');
} else if (shift.associate_registered==="both") {
shift_line_template.find(".shift_line_associate").text(' - Les deux');
} else {
shift_line_template.find(".shift_line_associate").text('A définir');
}
}
$("#incoming_shifts").append(shift_line_template.html());
}
}
......
......@@ -28,7 +28,8 @@ def index(request, exception=None):
context = {
'title': 'Espace Membre',
'COMPANY_LOGO': getattr(settings, 'COMPANY_LOGO', None)
'COMPANY_LOGO': getattr(settings, 'COMPANY_LOGO', None),
'block_actions_for_attached_people' : getattr(settings, 'BLOCK_ACTIONS_FOR_ATTACHED_PEOPLE', True)
}
template = loader.get_template('members_space/index.html')
......@@ -96,6 +97,9 @@ def index(request, exception=None):
if partnerData["parent_id"] is not False:
partnerData["parent_name"] = partnerData["parent_id"][1]
partnerData["parent_id"] = partnerData["parent_id"][0]
md5_calc = hashlib.md5(partnerData['parent_create_date'].encode('utf-8')).hexdigest()
partnerData['parent_verif_token'] = md5_calc
else:
partnerData["parent_name"] = False
......
......@@ -321,6 +321,9 @@
By default, is True. If False, tile showing explanations is not shown
- BLOCK_ACTIONS_FOR_ATTACHED_PEOPLE = False
Attached people can or not change his services
### Reception
- RECEPTION_ADD_ADMIN_MODE = True
......@@ -376,7 +379,6 @@
- AMNISTIE_DATE = "2021-11-24 00:00:00"
In members_space history display a special activity about amnistie
### Miscellious
- EXPORT_COMPTA_FORMAT = 'Quadratus'
......
......@@ -6,6 +6,7 @@ from django.http import JsonResponse
from django.http import HttpResponseNotFound
from django.http import HttpResponseForbidden
from django.http import HttpResponseServerError
from django.http import HttpResponseBadRequest
from django.template import loader
from django.shortcuts import render
from django.shortcuts import redirect
......
......@@ -40,8 +40,16 @@ class CagetteShift(models.Model):
'street', 'street2', 'zip', 'city', 'mobile', 'phone', 'email',
'is_associated_people', 'parent_id']
partnerData = self.o_api.search_read('res.partner', cond, fields, 1)
if partnerData:
partnerData = partnerData[0]
if partnerData['is_associated_people']:
cond = [['id', '=', partnerData['parent_id'][0]]]
fields = ['create_date']
parentData = self.o_api.search_read('res.partner', cond, fields, 1)
if parentData:
partnerData['parent_create_date'] = parentData[0]['create_date']
if partnerData['shift_type'] == 'standard':
partnerData['in_ftop_team'] = False
# Because 'in_ftop_team' doesn't seem to be reset to False in Odoo
......@@ -83,7 +91,7 @@ class CagetteShift(models.Model):
def get_shift_partner(self, id):
"""Récupère les shift du membre"""
fields = ['date_begin', 'date_end','final_standard_point',
'shift_id', 'shift_type','partner_id', "id"] # res.partner
'shift_id', 'shift_type','partner_id', "id", "associate_registered"] # res.partner
cond = [['partner_id.id', '=', id],['state', '=', 'open'],
['date_begin', '>', datetime.datetime.now().isoformat()]]
shiftData = self.o_api.search_read('shift.registration', cond, fields, order ="date_begin ASC")
......@@ -167,6 +175,25 @@ class CagetteShift(models.Model):
st_r_id = True
return st_r_id
def affect_shift(self, data):
"""Affect shift to partner, his associate or both"""
response = None
cond = [['partner_id', '=', int(data['idPartner'])],
['id', '=', int(data['idShiftRegistration'])]]
fields = ['id']
try:
print(cond)
shit_to_affect = self.o_api.search_read('shift.registration', cond, fields, 1)
print(shit_to_affect)
if (len(shit_to_affect) == 1):
shift_res = shit_to_affect[0]
print(shift_res)
fieldsDatas = { "associate_registered":data['affected_partner']}
response = self.o_api.update('shift.registration', [shift_res['id']], fieldsDatas)
except Exception as e:
coop_logger.error("Reopen shift : %s", str(e))
return response
def cancel_shift(self, idsRegisteur):
"""Annule un shift"""
fieldsDatas = { "related_shift_state": 'cancel',
......
......@@ -13,6 +13,7 @@ urlpatterns = [
url(r'^get_test', views.get_test),
# url(r'^get_list', views.get_list),
url(r'^change_shift', views.change_shift),
url(r'^affect_shift', views.affect_shift),
url(r'^add_shift', views.add_shift),
url(r'^request_delay', views.request_delay),
url(r'^reset_members_positive_points', views.reset_members_positive_points)
......
......@@ -223,15 +223,45 @@ def change_shift(request):
response = {'result': True}
else:
response = {'result': False}
response = {'msg': "Fail to create shift"}
return JsonResponse(response, status=500)
else:
response = {'result': False}
response = {'msg': "Bad arguments"}
return JsonResponse(response, status=400)
return JsonResponse(response)
else:
return HttpResponseForbidden()
else:
return HttpResponseForbidden()
def affect_shift(request):
if 'verif_token' in request.POST:
if Verification.verif_token(request.POST.get('verif_token'), int(request.POST.get('idPartner'))) is True:
cs = CagetteShift()
if 'idShiftRegistration' in request.POST and 'affected_partner' in request.POST:
data = {
"idPartner": int(request.POST['idPartner']),
"idShiftRegistration": int(request.POST['idShiftRegistration']),
"affected_partner": request.POST['affected_partner'],
}
try:
st_r_id = cs.affect_shift(data)
except Exception as e:
coop_logger.error("affect shift : %s, %s", str(e), str(data))
if st_r_id:
response = {'result': True}
else:
response = {'msg': "Internal Error"}
return JsonResponse(response, status=500)
return(JsonResponse({'result': True}))
else:
response = {'msg': "Bad args"}
return JsonResponse(response, status=400)
else:
return HttpResponseForbidden()
else:
return HttpResponseForbidden()
def add_shift(request):
if 'verif_token' in request.POST:
if Verification.verif_token(request.POST.get('verif_token'), int(request.POST.get('idPartner'))) is True:
......
......@@ -31,17 +31,34 @@
<div id="shift_line_template">
<div class="shift_line">
<i class="fas fa-chevron-right shift_line_chevron"></i>
<span class="shift_line_date"></span> - <span class="shift_line_time"></span>
<span class="shift_line_date"></span> - <span class="shift_line_time"></span> <span class="shift_line_associate"> </span>
</div>
</div>
<div id="selectable_shift_line_template">
<div class="d-flex">
<div class="selectable_shift_line btn--primary">
<input type="checkbox" class="checkbox">
<div class="selectable_shift_line_text">
<span class="shift_line_date"></span> - <span class="shift_line_time"></span>
</div>
</div>
<div class="affect_associate_registered button--warning">
</div>
</div>
</div>
<div id="modal_affect_shift">
<div>Qui sera présent.e ?</div>
<div id="shift_partner" class="btn--primary">
</div>
<div id="shift_associate" class=" btn--primary">
</div>
<div id="shift_both" class=" btn--primary">
Les deux
</div>
</div>
<div id="modal_shift_exchange_template">
......@@ -118,12 +135,14 @@
"is_associated_people" : "{{partnerData.is_associated_people}}",
"parent_id" : "{{partnerData.parent_id}}",
"parent_name" : "{{partnerData.parent_name}}",
"parent_verif_token" : "{{partnerData.parent_verif_token}}",
"associated_partner_id" : "{{partnerData.associated_partner_id}}",
"associated_partner_name" : "{{partnerData.associated_partner_name}}",
"verif_token" : "{{partnerData.verif_token}}",
"leave_stop_date": "{{partnerData.leave_stop_date}}",
"comite": "{{partnerData.comite}}"
}
};
var block_actions_for_attached_people = '{{block_actions_for_attached_people}}';
</script>
<script src="{% static "js/all_common.js" %}?v="></script>
<script src="{% static "js/members-space-home.js" %}?v="></script>
......
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