Commit 1a6574de by François C.

Allow other name for commitee shift template (equivalent for Supercoop)

parent e5d02715
Pipeline #2466 passed with stage
in 1 minute 28 seconds
...@@ -346,6 +346,7 @@ def manage_regular_shifts(request): ...@@ -346,6 +346,7 @@ def manage_regular_shifts(request):
""" Administration des créneaux des membres """ """ Administration des créneaux des membres """
template = loader.get_template('members/admin/manage_regular_shifts.html') template = loader.get_template('members/admin/manage_regular_shifts.html')
committees_shift_id = CagetteServices.get_committees_shift_id() committees_shift_id = CagetteServices.get_committees_shift_id()
committees_shift_name = getattr(settings, 'COMMITTEES_SHIFT_NAME', "service des Comités")
context = { context = {
'title': 'BDM - Créneaux', 'title': 'BDM - Créneaux',
'module': 'Membres', 'module': 'Membres',
...@@ -357,6 +358,7 @@ def manage_regular_shifts(request): ...@@ -357,6 +358,7 @@ def manage_regular_shifts(request):
'show_ftop_button': getattr(settings, 'BDM_SHOW_FTOP_BUTTON', True), 'show_ftop_button': getattr(settings, 'BDM_SHOW_FTOP_BUTTON', True),
'has_committe_shift': committees_shift_id is not None, 'has_committe_shift': committees_shift_id is not None,
'committees_shift_id': committees_shift_id, 'committees_shift_id': committees_shift_id,
'committees_shift_name': committees_shift_name,
'ASSOCIATE_MEMBER_SHIFT' : getattr(settings, 'ASSOCIATE_MEMBER_SHIFT', '') 'ASSOCIATE_MEMBER_SHIFT' : getattr(settings, 'ASSOCIATE_MEMBER_SHIFT', '')
} }
return HttpResponse(template.render(context, request)) return HttpResponse(template.render(context, request))
...@@ -582,7 +584,6 @@ def shift_subscription(request): ...@@ -582,7 +584,6 @@ def shift_subscription(request):
# First try to get committees shift # First try to get committees shift
shift_template_id = CagetteServices.get_committees_shift_id() shift_template_id = CagetteServices.get_committees_shift_id()
# If None, no committees shift, get the first ftop shift # If None, no committees shift, get the first ftop shift
if shift_template_id is None: if shift_template_id is None:
shift_template_id = CagetteServices.get_first_ftop_shift_id() shift_template_id = CagetteServices.get_first_ftop_shift_id()
...@@ -604,9 +605,10 @@ def shift_subscription(request): ...@@ -604,9 +605,10 @@ def shift_subscription(request):
) )
res["unsubscribe_member"] = m.unsubscribe_member(changing_shift = True) res["unsubscribe_member"] = m.unsubscribe_member(changing_shift = True)
m.create_coop_shift_subscription(shift_template_id, shift_type) reg_id = m.create_coop_shift_subscription(shift_template_id, shift_type)
# Return necessary data # Return necessary data
if reg_id is not None:
api = OdooAPI() api = OdooAPI()
c = [['id', '=', shift_template_id]] c = [['id', '=', shift_template_id]]
f = ['id', 'name'] f = ['id', 'name']
...@@ -615,9 +617,11 @@ def shift_subscription(request): ...@@ -615,9 +617,11 @@ def shift_subscription(request):
c = [['id', '=', partner_id]] c = [['id', '=', partner_id]]
f = ['cooperative_state'] f = ['cooperative_state']
res["cooperative_state"] = api.search_read('res.partner', c, f)[0]['cooperative_state'] res["cooperative_state"] = api.search_read('res.partner', c, f)[0]['cooperative_state']
coop_logger.info("Resultat shift_subscription : %s (données reçues = %s)", str(res), str(data))
response = JsonResponse(res) response = JsonResponse(res)
else: else:
response = JsonResponse({"message": "Subscription failed"}, status=500)
else:
response = JsonResponse({"message": "Unauthorized"}, status=403) response = JsonResponse({"message": "Unauthorized"}, status=403)
return response return response
......
...@@ -317,7 +317,7 @@ class CagetteMember(models.Model): ...@@ -317,7 +317,7 @@ class CagetteMember(models.Model):
[invoice_id]) [invoice_id])
return [invoice_id, invoice_line_id] return [invoice_id, invoice_line_id]
def create_coop_shift_subscription(self, shift_t_id, stype): def create_coop_shift_subscription(self, shift_t_id, stype, call_nb=1):
"""Store coop shift subscription.""" """Store coop shift subscription."""
# Get shift template ticket corresponding to given shift temp. id # Get shift template ticket corresponding to given shift temp. id
sti = None sti = None
...@@ -345,7 +345,11 @@ class CagetteMember(models.Model): ...@@ -345,7 +345,11 @@ class CagetteMember(models.Model):
} }
st_r_id = self.o_api.create('shift.template.registration', st_r_id = self.o_api.create('shift.template.registration',
st_r_fields) st_r_fields)
except: except Exception as ex:
if 'seules les inscriptions ABCD sont possibles' in str(ex) and call_nb < 2:
return self.create_coop_shift_subscription(shift_t_id, 1, call_nb + 1)
else:
coop_logger.error("Error while creating shift.template.registration : %s, (fields =%s)", str(ex), str(st_r_fields))
st_r_id = None st_r_id = None
return st_r_id return st_r_id
......
...@@ -193,7 +193,7 @@ function set_subscription_area() { ...@@ -193,7 +193,7 @@ function set_subscription_area() {
$(document).on("click", "#shifts_calendar_area button[data-select='Volant']", function() { $(document).on("click", "#shifts_calendar_area button[data-select='Volant']", function() {
// Subscribe to comitee/ftop shift // Subscribe to comitee/ftop shift
msg = (has_committe_shift === "True") msg = (has_committe_shift === "True")
? `Inscrire ${selected_member.name} au service des Comités ?` ? `Inscrire ${selected_member.name} au ${committees_shift_name} ?`
: `Inscrire ${selected_member.name} en Volant ?`; : `Inscrire ${selected_member.name} en Volant ?`;
openModal( openModal(
...@@ -281,7 +281,7 @@ $(document).ready(function() { ...@@ -281,7 +281,7 @@ $(document).ready(function() {
$(".page_content").show(); $(".page_content").show();
if (has_committe_shift === "True") { if (has_committe_shift === "True") {
$("#shifts_calendar_area button[data-select='Volant']").text("Comités"); $("#shifts_calendar_area button[data-select='Volant']").text(committees_shift_name);
} }
// Set action to search for the member // Set action to search for the member
......
...@@ -354,6 +354,9 @@ ...@@ -354,6 +354,9 @@
By default 1. Extension type id (from shift_extension_type table) used to create extension By default 1. Extension type id (from shift_extension_type table) used to create extension
- COMMITTEES_SHIFT_NAME = 'Coolisses'
By default "service des Comités"
### Reception ### Reception
- RECEPTION_ADD_ADMIN_MODE = True - RECEPTION_ADD_ADMIN_MODE = True
......
...@@ -447,8 +447,11 @@ function shift_loc_selection() { ...@@ -447,8 +447,11 @@ function shift_loc_selection() {
if (clicked.data('select') != 'Volant') { if (clicked.data('select') != 'Volant') {
retrieve_and_draw_shift_tempates(); retrieve_and_draw_shift_tempates();
} else { } else {
//shift_templates[volant] is not always set (when call from bdm interface)
if (typeof volant !== "undefined" && typeof shift_templates[volant] !== "undefined") {
subscribe_shift(volant); subscribe_shift(volant);
} }
}
} }
......
...@@ -96,6 +96,7 @@ ...@@ -96,6 +96,7 @@
var couchdb_dbname = '{{db}}'; var couchdb_dbname = '{{db}}';
var couchdb_server = '{{couchdb_server}}' + couchdb_dbname; var couchdb_server = '{{couchdb_server}}' + couchdb_dbname;
var committees_shift_id = '{{committees_shift_id}}'; var committees_shift_id = '{{committees_shift_id}}';
const committees_shift_name = '{{committees_shift_name}}';
var ASSOCIATE_MEMBER_SHIFT = '{{ASSOCIATE_MEMBER_SHIFT}}'; var ASSOCIATE_MEMBER_SHIFT = '{{ASSOCIATE_MEMBER_SHIFT}}';
</script> </script>
<script src='{% static "js/common.js" %}?v=1651853225'></script> <script src='{% static "js/common.js" %}?v=1651853225'></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