Commit a8b0fcb4 by François

Merge branch 'evolution_bdm' of…

Merge branch 'evolution_bdm' of https://gl.cooperatic.fr/cooperatic-foodcoops/third-party into evolution_bdm
parents 5fcff4ae 955948ad
Pipeline #1332 failed with stage
in 1 minute 22 seconds
......@@ -17,3 +17,4 @@ db.sqlite3
shop/shop_admin_settings.json
shop/errors.log
.idea
members/settings.json
\ No newline at end of file
......@@ -19,7 +19,12 @@ default_msettings = {'msg_accueil': {'title': 'Message borne accueil',
'title': 'Horaires ouverture magasin',
'type': 'textarea',
'value': ''
}
},
'abcd_calendar_link' : {
'title': 'Lien vers le calendrier ABCD',
'type': 'text',
'value': ''
}
}
def config(request):
......
......@@ -61,6 +61,22 @@ class CagetteMember(models.Model):
image = res[0]['image_medium']
return image
# def update_member_points(self, status):
# fields = {'name': reason,
# 'shift_id': False,
# 'type': stype,
# 'partner_id': self.id,
# 'point_qty': pts
# }
# return self.o_api.create('shift.counter.event', fields)
# if status not in ["suspended", "delay", "up_to_date", "unsuscribed", "alert"]:
# raise Exception("Bad status")
# f = { 'cooperative_state': "delay" }
# return self.o_api.update('res.partner', [self.id], f)
@staticmethod
def retrieve_data_according_keys(keys, full=False):
api = OdooAPI()
......
......@@ -11,12 +11,13 @@ class CagetteMembersSpace(models.Model):
"""Init with odoo id."""
self.o_api = OdooAPI()
def get_points_history(self, partner_id, limit, offset, date_from):
def get_points_history(self, partner_id, limit, offset, date_from, shift_type):
""" Get partner points history with related shift registration if needed """
cond = [
['partner_id', '=', partner_id],
['type', '=', 'ftop'],
['create_date', '>', date_from]
['type', '=', shift_type],
['create_date', '>', date_from],
['point_qty', '!=', 0]
]
f = ['create_date', 'create_uid', 'shift_id', 'name', 'point_qty']
......
......@@ -3,6 +3,7 @@
margin: 3rem auto;
display: flex;
flex-direction: column;
position: relative;
}
/* -- Suspended screen */
......@@ -16,6 +17,21 @@
margin: 1.5rem 0;
}
/* -- Calendar screen, area on top of the calendar */
#calendar_top_info {
display: flex;
justify-content: space-between;
}
@media screen and (max-width:768px) {
#calendar_top_info {
display: flex;
flex-direction: column;
justify-content: space-between;
}
}
/* -- Calendar screen, shifts list */
#shifts_list {
......@@ -119,4 +135,35 @@
.date_old_shift, .time_old_shift, .date_new_shift, .time_new_shift {
font-weight: bold;
}
/* -- Explainations */
#calendar_explaination_area {
max-width: 33%;
border: 2px solid #585858;
border-radius: 15px;
padding: 1rem;
}
.example-event {
max-width: 200px;
margin: 2rem 0 0.5rem 0;
font-size: 1.4rem !important;
padding: 0 !important;
}
@media screen and (max-width:768px) {
.example-event {
margin: 2rem auto 0.5rem auto;
}
}
.arrow_explanation_numbers {
margin: 0 3px;
}
#calendar_explaination_button {
max-width: 60%;
margin: 2rem auto -1rem auto;
}
\ No newline at end of file
......@@ -18,7 +18,9 @@ $(document).ready(function() {
if (current_location !== "home") {
goto('home');
}
toggleHeader();
if (document.getElementById("topnav").className !== "topnav") {
toggleHeader();
}
});
$('#nav_my_info').on('click', (e) => {
e.preventDefault();
......@@ -41,4 +43,8 @@ $(document).ready(function() {
}
toggleHeader();
});
$('#nav_calendar').prop("href", abcd_calendar_link);
$('#nav_calendar').on('click', () => {
toggleHeader();
});
});
......@@ -30,7 +30,7 @@ function request_delay() {
verif_token: partner_data.verif_token,
idPartner: partner_data.partner_id,
start_date: delay_start,
duration: diff_days
duration: diff_days,
},
success: function() {
partner_data.cooperative_state = 'delay';
......@@ -44,7 +44,7 @@ function request_delay() {
&& data.responseJSON.message === "delays limit reached") {
closeModal();
alert("Vous avez mis plus de 6 mois pour rattraper un service, " +
"vous ne pouvez plus sélectionner de rattrapage depuis l'espace membre. " +
"vous ne pouvez plus rien faire depuis l'espace membre. " +
"Merci de contacter le BDM.");
} else {
err = {msg: "erreur serveur lors de la création du délai", ctx: 'request_delay'};
......
......@@ -14,7 +14,8 @@ function load_partner_history(offset = 0) {
partner_id: partner_data.concerned_partner_id,
verif_token: partner_data.verif_token,
limit: history_items_limit,
offset: offset
offset: offset,
shift_type: (partner_data.in_ftop_team === "True") ? "ftop" : "standard"
},
dataType:"json",
traditional: true,
......
......@@ -94,8 +94,8 @@ function add_or_change_shift(new_shift_id) {
alert(`Désolé ! Le service que vous souhaitez échanger démarre dans moins de 24h. ` +
`Il n'est plus possible de l'échanger.`);
} else {
alert(`Une erreur est survenue.` +
`Il est néanmoins possible que la requête ait abouti,` +
alert(`Une erreur est survenue. ` +
`Il est néanmoins possible que la requête ait abouti, ` +
`veuillez patienter quelques secondes puis vérifier vos services enregistrés.`);
}
......@@ -176,8 +176,22 @@ function init_shifts_list() {
* Inits the page when the calendar is displayed
*/
function init_calendar_page() {
let template_explanations = $("#calendar_explaination_template");
if (vw <= 768) {
$(".loading-calendar").show();
$("#calendar_explaination_area").hide();
$("#calendar_explaination_button").on("click", () => {
openModal(
template_explanations.html(),
closeModal,
"J'ai compris"
)
})
} else {
$("#calendar_explaination_button").hide();
$("#calendar_explaination_area").html(template_explanations.html());
}
if (incoming_shifts !== null) {
......@@ -199,7 +213,7 @@ function init_calendar_page() {
default_initial_view = 'listWeek';
header_toolbar = {
left: 'title',
center: 'dayGridMonth,listWeek,timeGridDay',
center: '',
right: 'prev,next today'
};
} else {
......@@ -271,6 +285,16 @@ function init_calendar_page() {
);
} else if (can_select_makeup()) {
/* choose a makeup service */
// Check if selected new shift is in less than 6 months
if (partner_data.date_delay_stop !== 'False') {
date_partner_delay_stop = new Date(partner_data.date_delay_stop);
if ( datetime_new_shift > date_partner_delay_stop ) {
let msg = `Vous avez jusqu'au ${date_partner_delay_stop.toLocaleDateString("fr-fr", date_options)} ` +
`pour sélectionner un rattrapage (soit une période de 6 mois depuis votre absence).`;
alert(msg);
return;
}
}
let modal_template = $("#modal_add_shift_template");
modal_template.find(".date_new_shift").text(new_shift_date);
......
......@@ -165,7 +165,11 @@ function init_my_info_data() {
});
}
if (partner_data.makeups_to_do > 0 && partner_data.is_associated_people === "False") {
if (
partner_data.makeups_to_do > 0
&& partner_data.is_associated_people === "False"
&& partner_data.cooperative_state !== 'unsubscribed'
) {
$(".choose_makeups").show();
if (
......
......@@ -91,7 +91,6 @@ def index(request, exception=None):
context['partnerData'] = partnerData
# TODO test with partner who's not attached
if partnerData["parent_id"] is not False:
partnerData["parent_name"] = partnerData["parent_id"][1]
partnerData["parent_id"] = partnerData["parent_id"][0]
......@@ -104,6 +103,10 @@ def index(request, exception=None):
if hasattr(settings, 'SHIFT_EXCHANGE_DAYS_TO_HIDE'):
days_to_hide = settings.SHIFT_EXCHANGE_DAYS_TO_HIDE
context['daysToHide'] = days_to_hide
msettings = MConfig.get_settings('members')
if 'abcd_calendar_link' in msettings:
context['abcd_calendar_link'] = msettings['abcd_calendar_link']['value']
else:
# may arrive when switching database without cleaning cookie
......@@ -160,7 +163,8 @@ def get_points_history(request):
limit = int(request.GET.get('limit'))
offset = int(request.GET.get('offset'))
shift_type = request.GET.get('shift_type')
date_from = getattr(settings, 'START_DATE_FOR_POINTS_HISTORY', '2018-01-01')
res["data"] = m.get_points_history(partner_id, limit, offset, date_from)
res["data"] = m.get_points_history(partner_id, limit, offset, date_from, shift_type)
return JsonResponse(res)
\ No newline at end of file
......@@ -311,7 +311,7 @@ class CagetteShift(models.Model):
makeups_to_do -= 1
f = { "makeups_to_do": makeups_to_do }
return self.o_api.update('res.partner', partner_id, f)
return self.o_api.update('res.partner', [partner_id], f)
else:
return "makeups already at 0"
......
......@@ -3,6 +3,7 @@ from outils.for_view_imports import *
from outils.common import Verification
from shifts.models import CagetteShift
from members.models import CagetteMember
# working_state = ['up_to_date', 'alert', 'exempted', 'delay', 'suspended']
state_shift_allowed = ["up_to_date", "alert", "delay"]
......@@ -267,13 +268,12 @@ def request_delay(request):
if Verification.verif_token(request.POST.get('verif_token'), int(request.POST.get('idPartner'))) is True:
cs = CagetteShift()
# TODO do we need this?
# use_new_members_space = getattr(settings, 'USE_NEW_MEMBERS_SPACE', False)
# if use_new_members_space is True:
# member_can_have_delay = cs.member_can_have_delay(int(request.POST.get('idPartner')))
# if member_can_have_delay is False:
# res = { 'message' : 'delays limit reached'}
# return JsonResponse(res, status=403)
use_new_members_space = getattr(settings, 'USE_NEW_MEMBERS_SPACE', False)
if use_new_members_space is True:
member_can_have_delay = cs.member_can_have_delay(int(request.POST.get('idPartner')))
if member_can_have_delay is False:
res = { 'message' : 'delays limit reached'}
return JsonResponse(res, status=403)
data = {
"idPartner": int(request.POST['idPartner']),
......
......@@ -10,9 +10,16 @@
<a href="#" class="nav_item" id="nav_my_info">Mes Infos</a>
<a href="#" class="nav_item" id="nav_my_shifts">Mes Services</a>
<a href="#" class="nav_item" id="nav_shifts_exchange">Échange de services</a>
<a href="#" class="nav_item" id="nav_calendar">Calendrier ABCD</a>
<a
href="javascript:void(0);"
target="_blank"
class="nav_item"
id="nav_calendar"
>
Calendrier ABCD
</a>
{# Disconnection button must have this id (logic in all_common.js) #}
<a href="#" id="deconnect">Déconnexion</a>
<a href="javascript:void(0);" id="deconnect">Déconnexion</a>
<a href="javascript:void(0);" class="icon" onclick="toggleHeader()">
<i class="fa fa-bars"></i>
</a>
......
......@@ -49,9 +49,20 @@
<div>par celui du : </div>
<div><span class="date_new_shift"></span> à <span class="time_new_shift"></span></div>
</div>
<div id="modal_add_shift_template">
<div>Je suis sur le point de m'inscrire au service du : <span class="date_new_shift"></span> à <span class="time_new_shift"></span></div>
</div>
<div id="calendar_explaination_template">
<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"> Clemenceau -- 9/12</div></div></div></div></a>
<p>Un service colorié en noir : je suis déjà inscrit à 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"> Clemenceau -- 3/12</div></div></div></div></a>
<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.
<b>Plus le chiffre de gauche est petit, plus on a besoin de coopérateurs.rices à ce service !</b></p>
</div>
</div>
</div>
......@@ -62,16 +73,8 @@
"partner_id":"{{partnerData.id}}",
"name":"{{partnerData.display_name}}",
"in_ftop_team":"{{partnerData.in_ftop_team}}",
"final_standard_point":"{{partnerData.final_standard_point}}",
"final_ftop_point":"{{partnerData.final_ftop_point}}",
"date_delay_stop":"{{partnerData.date_delay_stop}}",
"date_alert_stop":"{{partnerData.date_alert_stop}}",
"cooperative_state":"{{partnerData.cooperative_state}}",
"is_leave": "{{partnerData.is_leave}}",
"leave_start_date": "{{partnerData.leave_start_date}}",
"leave_stop_date": "{{partnerData.leave_stop_date}}",
"next_regular_shift_date": "{{partnerData.next_regular_shift_date}}",
"regular_shift_name": "{{partnerData.regular_shift_name}}",
"verif_token" : "{{partnerData.verif_token}}",
"makeups_to_do" : "{{partnerData.makeups_to_do}}",
"barcode_base" : "{{partnerData.barcode_base}}",
......@@ -87,6 +90,7 @@
"parent_name" : "{{partnerData.parent_name}}",
}
var days_to_hide = "{{daysToHide}}"
var abcd_calendar_link = "{{abcd_calendar_link}}"
</script>
<script src="{% static "js/all_common.js" %}?v="></script>
<script src="{% static "js/members-space-home.js" %}?v="></script>
......
......@@ -19,12 +19,16 @@
<span class="select_makeups_message_block">Je dois les sélectionner dans le calendrier. </span>
<span class="select_makeups_message_block">Je ne peux pas échanger de service tant que je n'ai pas choisi mes rattrapages. </span>
</div>
<div id="partner_shifts_list">
<h4>Liste de mes services :</h4>
<div class="loading-incoming-shifts">
<i class="fas fa-spinner fa-spin fa-lg"></i>
<div id="calendar_top_info">
<div id="partner_shifts_list">
<h4>Liste de mes services :</h4>
<div class="loading-incoming-shifts">
<i class="fas fa-spinner fa-spin fa-lg"></i>
</div>
<div id="shifts_list"></div>
</div>
<div id="shifts_list"></div>
<div id="calendar_explaination_area"></div>
<button id="calendar_explaination_button" class="btn--success">Légende du calendrier</button>
</div>
<div class="loading-calendar">
<i class="fas fa-spinner fa-spin fa-2x"></i>
......
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