Commit 2804d911 by François C.

Merge branch 'ticket_3968' into 'dev_cooperatic'

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

See merge request !216
parents e5d02715 1a6574de
Pipeline #2467 passed with stage
in 1 minute 25 seconds
......@@ -346,6 +346,7 @@ def manage_regular_shifts(request):
""" Administration des créneaux des membres """
template = loader.get_template('members/admin/manage_regular_shifts.html')
committees_shift_id = CagetteServices.get_committees_shift_id()
committees_shift_name = getattr(settings, 'COMMITTEES_SHIFT_NAME', "service des Comités")
context = {
'title': 'BDM - Créneaux',
'module': 'Membres',
......@@ -357,6 +358,7 @@ def manage_regular_shifts(request):
'show_ftop_button': getattr(settings, 'BDM_SHOW_FTOP_BUTTON', True),
'has_committe_shift': committees_shift_id is not None,
'committees_shift_id': committees_shift_id,
'committees_shift_name': committees_shift_name,
'ASSOCIATE_MEMBER_SHIFT' : getattr(settings, 'ASSOCIATE_MEMBER_SHIFT', '')
}
return HttpResponse(template.render(context, request))
......@@ -582,7 +584,6 @@ def shift_subscription(request):
# First try to get committees shift
shift_template_id = CagetteServices.get_committees_shift_id()
# If None, no committees shift, get the first ftop shift
if shift_template_id is None:
shift_template_id = CagetteServices.get_first_ftop_shift_id()
......@@ -604,19 +605,22 @@ def shift_subscription(request):
)
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
api = OdooAPI()
c = [['id', '=', shift_template_id]]
f = ['id', 'name']
res["shift_template"] = api.search_read('shift.template', c, f)[0]
c = [['id', '=', partner_id]]
f = ['cooperative_state']
res["cooperative_state"] = api.search_read('res.partner', c, f)[0]['cooperative_state']
response = JsonResponse(res)
if reg_id is not None:
api = OdooAPI()
c = [['id', '=', shift_template_id]]
f = ['id', 'name']
res["shift_template"] = api.search_read('shift.template', c, f)[0]
c = [['id', '=', partner_id]]
f = ['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)
else:
response = JsonResponse({"message": "Subscription failed"}, status=500)
else:
response = JsonResponse({"message": "Unauthorized"}, status=403)
......
......@@ -317,7 +317,7 @@ class CagetteMember(models.Model):
[invoice_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."""
# Get shift template ticket corresponding to given shift temp. id
sti = None
......@@ -345,8 +345,12 @@ class CagetteMember(models.Model):
}
st_r_id = self.o_api.create('shift.template.registration',
st_r_fields)
except:
st_r_id = None
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
return st_r_id
......
......@@ -193,7 +193,7 @@ function set_subscription_area() {
$(document).on("click", "#shifts_calendar_area button[data-select='Volant']", function() {
// Subscribe to comitee/ftop shift
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 ?`;
openModal(
......@@ -281,7 +281,7 @@ $(document).ready(function() {
$(".page_content").show();
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
......
......@@ -354,6 +354,9 @@
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_ADD_ADMIN_MODE = True
......
......@@ -447,7 +447,10 @@ function shift_loc_selection() {
if (clicked.data('select') != 'Volant') {
retrieve_and_draw_shift_tempates();
} else {
subscribe_shift(volant);
//shift_templates[volant] is not always set (when call from bdm interface)
if (typeof volant !== "undefined" && typeof shift_templates[volant] !== "undefined") {
subscribe_shift(volant);
}
}
}
......
......@@ -96,6 +96,7 @@
var couchdb_dbname = '{{db}}';
var couchdb_server = '{{couchdb_server}}' + couchdb_dbname;
var committees_shift_id = '{{committees_shift_id}}';
const committees_shift_name = '{{committees_shift_name}}';
var ASSOCIATE_MEMBER_SHIFT = '{{ASSOCIATE_MEMBER_SHIFT}}';
</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