Commit e5d02715 by François C.

Merge branch 'ticket_3965' into 'dev_cooperatic'

Ticket 3965

See merge request !215
parents 06bf7b9c 1fc30fb1
Pipeline #2465 passed with stage
in 1 minute 26 seconds
...@@ -7,6 +7,7 @@ from members.models import CagetteMembers ...@@ -7,6 +7,7 @@ from members.models import CagetteMembers
from members.models import CagetteMember from members.models import CagetteMember
from shifts.models import CagetteServices from shifts.models import CagetteServices
from shifts.models import CagetteShift from shifts.models import CagetteShift
from members_space.models import CagetteMembersSpace
from outils.common import MConfig from outils.common import MConfig
from datetime import datetime, date from datetime import datetime, date
...@@ -120,7 +121,7 @@ default_msettings = {'msg_accueil': {'title': 'Message borne accueil', ...@@ -120,7 +121,7 @@ default_msettings = {'msg_accueil': {'title': 'Message borne accueil',
'sort_order': 16 'sort_order': 16
}, },
'member_cant_have_delay_form_link': { 'member_cant_have_delay_form_link': {
'title': 'Lien vers le formulaire pour les membres n\'ayant pas rattrapé leur service après 6 mois', 'title': 'Lien vers le formulaire pour les membres n\'ayant pas rattrapé leur service après la durée de l\'extension',
'type': 'text', 'type': 'text',
'value': '', 'value': '',
'class': 'link', 'class': 'link',
...@@ -320,8 +321,11 @@ def admin(request): ...@@ -320,8 +321,11 @@ def admin(request):
def manage_makeups(request): def manage_makeups(request):
""" Administration des membres """ """ Administration des membres """
template = loader.get_template('members/admin/manage_makeups.html') template = loader.get_template('members/admin/manage_makeups.html')
m = CagetteMembersSpace()
context = {'title': 'BDM - Rattrapages', context = {'title': 'BDM - Rattrapages',
'module': 'Membres'} 'module': 'Membres',
'extension_duration': m.get_extension_duration()
}
return HttpResponse(template.render(context, request)) return HttpResponse(template.render(context, request))
def manage_shift_registrations(request): def manage_shift_registrations(request):
...@@ -443,7 +447,6 @@ def regenerate_member_delay(request): ...@@ -443,7 +447,6 @@ def regenerate_member_delay(request):
duration = raw_data["duration"] duration = raw_data["duration"]
ext_name = "Délai étendue depuis l'admin BDM" ext_name = "Délai étendue depuis l'admin BDM"
res["create_delay"] = cs.create_delay(data=data, duration=duration, ext_name=ext_name) res["create_delay"] = cs.create_delay(data=data, duration=duration, ext_name=ext_name)
if (res["create_delay"]): if (res["create_delay"]):
......
...@@ -351,10 +351,9 @@ function extend_member_delay(member) { ...@@ -351,10 +351,9 @@ function extend_member_delay(member) {
openModal(); openModal();
let today = new Date(); let today = new Date();
let today_plus_six_month = new Date(); let today_plus_extension_duration = new Date();
today_plus_extension_duration.setMonth(today_plus_extension_duration.getMonth()+ extension_duration);
today_plus_six_month.setMonth(today_plus_six_month.getMonth()+6); const diff_time = Math.abs(today_plus_extension_duration - today);
const diff_time = Math.abs(today_plus_six_month - today);
const diff_days = Math.ceil(diff_time / (1000 * 60 * 60 * 24)); const diff_days = Math.ceil(diff_time / (1000 * 60 * 60 * 24));
let data = { let data = {
......
...@@ -27,6 +27,13 @@ class CagetteMembersSpace(models.Model): ...@@ -27,6 +27,13 @@ class CagetteMembersSpace(models.Model):
answer = True answer = True
return answer return answer
def get_extension_duration(self):
"""Return nb of months"""
# TODO : add a unit parameter and convert if not month
extension_duration = OdooAPI().get_system_param('lacagette_membership.extension_duration')
nb, unit = extension_duration.split(' ')
return nb
def get_shifts_history(self, partner_id, limit, offset, date_from): def get_shifts_history(self, partner_id, limit, offset, date_from):
""" Get partner shifts history """ """ Get partner shifts history """
res = [] res = []
......
...@@ -613,12 +613,12 @@ function init_calendar_page() { ...@@ -613,12 +613,12 @@ function init_calendar_page() {
} else if (should_select_makeup()) { } else if (should_select_makeup()) {
/* choose a makeup service */ /* choose a makeup service */
// Check if selected new shift is in less than 6 months // Check if selected new shift is in less than extension end
if (partner_data.date_delay_stop !== 'False') { if (partner_data.date_delay_stop !== 'False') {
date_partner_delay_stop = new Date(partner_data.date_delay_stop); date_partner_delay_stop = new Date(partner_data.date_delay_stop);
if (datetime_new_shift > date_partner_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)} ` + 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).`; `pour sélectionner un rattrapage (soit une période de ${extension_duration} mois depuis votre absence).`;
alert(msg); alert(msg);
......
...@@ -139,10 +139,10 @@ function request_delay() { ...@@ -139,10 +139,10 @@ function request_delay() {
const delay_start = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate(); const delay_start = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
let today_plus_six_month = new Date(); let today_plus_extension_duration = new Date();
today_plus_six_month.setMonth(today_plus_six_month.getMonth()+6); today_plus_extension_duration.setMonth(today_plus_extension_duration.getMonth()+ extension_duration);
const diff_time = Math.abs(today_plus_six_month - today); const diff_time = Math.abs(today_plus_extension_duration - today);
const diff_days = Math.ceil(diff_time / (1000 * 60 * 60 * 24)); const diff_days = Math.ceil(diff_time / (1000 * 60 * 60 * 24));
$.ajax({ $.ajax({
...@@ -157,7 +157,7 @@ function request_delay() { ...@@ -157,7 +157,7 @@ function request_delay() {
}, },
success: function() { success: function() {
partner_data.cooperative_state = 'delay'; partner_data.cooperative_state = 'delay';
partner_data.date_delay_stop = today_plus_six_month.getFullYear()+'-'+(today_plus_six_month.getMonth()+1)+'-'+today_plus_six_month.getDate(); partner_data.date_delay_stop = today_plus_extension_duration.getFullYear()+'-'+(today_plus_extension_duration.getMonth()+1)+'-'+today_plus_extension_duration.getDate();
resolve(); resolve();
}, },
......
...@@ -121,6 +121,7 @@ def index(request, exception=None): ...@@ -121,6 +121,7 @@ def index(request, exception=None):
partnerData["associated_partner_name"] = str(associated_partner["barcode_base"]) + ' - ' + partnerData["associated_partner_name"] partnerData["associated_partner_name"] = str(associated_partner["barcode_base"]) + ' - ' + partnerData["associated_partner_name"]
m = CagetteMembersSpace() m = CagetteMembersSpace()
context['extension_duration'] = m.get_extension_duration()
context['show_faq'] = getattr(settings, 'MEMBERS_SPACE_FAQ_TEMPLATE', 'members_space/faq.html') context['show_faq'] = getattr(settings, 'MEMBERS_SPACE_FAQ_TEMPLATE', 'members_space/faq.html')
context['show_abcd_calendar'] = getattr(settings, 'SHOW_ABCD_CALENDAR_TAB', True) context['show_abcd_calendar'] = getattr(settings, 'SHOW_ABCD_CALENDAR_TAB', True)
partnerData["comite"] = m.is_comite(partner_id) partnerData["comite"] = m.is_comite(partner_id)
...@@ -221,9 +222,11 @@ def my_shifts(request): ...@@ -221,9 +222,11 @@ def my_shifts(request):
def shifts_exchange(request): def shifts_exchange(request):
""" Endpoint the front-end will call to load the "Shifts exchange" page. """ """ Endpoint the front-end will call to load the "Shifts exchange" page. """
template = loader.get_template('members_space/shifts_exchange.html') template = loader.get_template('members_space/shifts_exchange.html')
m = CagetteMembersSpace()
context = { context = {
'title': 'Échange de Services', 'title': 'Échange de Services',
'canAddShift': getattr(settings, 'CAN_ADD_SHIFT', False) 'canAddShift': getattr(settings, 'CAN_ADD_SHIFT', False),
'extension_duration': m.get_extension_duration()
} }
return HttpResponse(template.render(context, request)) return HttpResponse(template.render(context, request))
......
...@@ -350,6 +350,10 @@ ...@@ -350,6 +350,10 @@
By default, False. By default, False.
- EXTENSION_TYPE_ID = 6
By default 1. Extension type id (from shift_extension_type table) used to create extension
### Reception ### Reception
- RECEPTION_ADD_ADMIN_MODE = True - RECEPTION_ADD_ADMIN_MODE = True
......
...@@ -345,7 +345,6 @@ class CagetteShift(models.Model): ...@@ -345,7 +345,6 @@ class CagetteShift(models.Model):
fields = ['extension_ids'] fields = ['extension_ids']
partner_extensions = self.o_api.search_read('res.partner', cond, fields) partner_extensions = self.o_api.search_read('res.partner', cond, fields)
response = False response = False
# If has extensions # If has extensions
if 'extension_ids' in partner_extensions[0]: if 'extension_ids' in partner_extensions[0]:
# Look for current extension: started before today and ends after # Look for current extension: started before today and ends after
...@@ -378,7 +377,7 @@ class CagetteShift(models.Model): ...@@ -378,7 +377,7 @@ class CagetteShift(models.Model):
else: else:
# Get the 'Extension' type id # Get the 'Extension' type id
extension_types = self.o_api.search_read('shift.extension.type') extension_types = self.o_api.search_read('shift.extension.type')
ext_type_id = 1 # Default ext_type_id = getattr(settings, 'EXTENSION_TYPE_ID', 1)
for val in extension_types: for val in extension_types:
if val['name'] == 'Extension': if val['name'] == 'Extension':
ext_type_id = val['id'] ext_type_id = val['id']
...@@ -396,7 +395,7 @@ class CagetteShift(models.Model): ...@@ -396,7 +395,7 @@ class CagetteShift(models.Model):
"date_stop": ending_date.isoformat(), "date_stop": ending_date.isoformat(),
"name": ext_name "name": ext_name
} }
response = self.o_api.create('shift.extension', fields) response = self.o_api.create('shift.extension', fields)
return response return response
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
<p> <p>
Vous vous apprêtez à rallonger le délai de Vous vous apprêtez à rallonger le délai de
<span class="member_name"></span> <span class="member_name"></span>
pour une durée de 6 mois à partir d'aujourd'hui. pour une durée de {{extension_duration}} mois à partir d'aujourd'hui.
</p> </p>
</div> </div>
<div id="modal_incr_makeup_counter"> <div id="modal_incr_makeup_counter">
...@@ -84,4 +84,7 @@ ...@@ -84,4 +84,7 @@
<script src='{% static "js/all_common.js" %}?v=1651853225'></script> <script src='{% static "js/all_common.js" %}?v=1651853225'></script>
<script src='{% static "js/admin/manage_makeups.js" %}?v=1651853225'></script> <script src='{% static "js/admin/manage_makeups.js" %}?v=1651853225'></script>
<script>
const extension_duration = {{extension_duration}};
</script>
{% endblock %} {% endblock %}
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
</div> </div>
<div id="cant_have_delay_msg_template"> <div id="cant_have_delay_msg_template">
<h3>Bonjour, tu avais 6 mois pour rattraper tes services manqués et il semblerait que tu ne l'aies pas fait.</h3> <h3>Bonjour, tu avais {{extension_duration}} mois pour rattraper tes services manqués et il semblerait que tu ne l'aies pas fait.</h3>
<h3>Tu ne peux plus sélectionner de rattrapages sur ton espace membre pour le moment, <h3>Tu ne peux plus sélectionner de rattrapages sur ton espace membre pour le moment,
merci de contacter le bureau des membres pour résoudre ce problème en remplissant ce formulaire : </h3> merci de contacter le bureau des membres pour résoudre ce problème en remplissant ce formulaire : </h3>
</div> </div>
...@@ -156,6 +156,7 @@ ...@@ -156,6 +156,7 @@
var block_actions_for_attached_people = '{{block_actions_for_attached_people}}'; var block_actions_for_attached_people = '{{block_actions_for_attached_people}}';
var block_service_exchange_24h_before = '{{block_service_exchange_24h_before}}'; var block_service_exchange_24h_before = '{{block_service_exchange_24h_before}}';
const canAddShift = {{canAddShift}}; const canAddShift = {{canAddShift}};
const extension_duration = {{extension_duration}};
</script> </script>
<script src="{% static "js/all_common.js" %}?v=1651853225"></script> <script src="{% static "js/all_common.js" %}?v=1651853225"></script>
<script src="{% static "js/common.js" %}?v=1651853225"></script> <script src="{% static "js/common.js" %}?v=1651853225"></script>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<div id="suspended_content" class="shifts_exchange_page_content"> <div id="suspended_content" class="shifts_exchange_page_content">
<h3> <h3>
J'ai <span class="makeups_nb"></span> rattrapage(s) à effectuer, je dois le(s) sélectionner pour pouvoir refaire mes courses. J'ai <span class="makeups_nb"></span> rattrapage(s) à effectuer, je dois le(s) sélectionner pour pouvoir refaire mes courses.
J'ai 6 mois de délai pour le(s) rattraper. J'ai {{extension_duration}} mois de délai pour le(s) rattraper.
</h3> </h3>
<h3> <h3>
Si besoin, je peux contacter le Bureau des membres via la rubrique "J'ai une demande" pour expliquer ma situation. Si besoin, je peux contacter le Bureau des membres via la rubrique "J'ai une demande" pour expliquer ma situation.
......
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