Commit b820309d by Damien Moulard

retrieve exemptions shift id and create button to register to it

parent 236ebbfc
Pipeline #2748 passed with stage
in 1 minute 30 seconds
...@@ -347,6 +347,7 @@ def manage_regular_shifts(request): ...@@ -347,6 +347,7 @@ def manage_regular_shifts(request):
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") committees_shift_name = getattr(settings, 'COMMITTEES_SHIFT_NAME', "service des Comités")
exemptions_shift_id = CagetteServices.get_exemptions_shift_id()
context = { context = {
'title': 'BDM - Créneaux', 'title': 'BDM - Créneaux',
'module': 'Membres', 'module': 'Membres',
...@@ -359,7 +360,8 @@ def manage_regular_shifts(request): ...@@ -359,7 +360,8 @@ def manage_regular_shifts(request):
'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, 'committees_shift_name': committees_shift_name,
'ASSOCIATE_MEMBER_SHIFT' : getattr(settings, 'ASSOCIATE_MEMBER_SHIFT', '') 'ASSOCIATE_MEMBER_SHIFT' : getattr(settings, 'ASSOCIATE_MEMBER_SHIFT', ''),
'exemptions_shift_id': exemptions_shift_id,
} }
return HttpResponse(template.render(context, request)) return HttpResponse(template.render(context, request))
...@@ -579,7 +581,7 @@ def shift_subscription(request): ...@@ -579,7 +581,7 @@ def shift_subscription(request):
if shift_type == 1: if shift_type == 1:
# 1 = standard # 1 = standard
shift_template_id = int(data["shift_template_id"]) shift_template_id = int(data["shift_template_id"])
else: elif shift_type == 2:
# 2 = ftop # 2 = ftop
# First try to get committees shift # First try to get committees shift
...@@ -587,6 +589,10 @@ def shift_subscription(request): ...@@ -587,6 +589,10 @@ def shift_subscription(request):
# 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()
else:
# 3 = exempté
# Get exemptions shift
shift_template_id = CagetteServices.get_exemptions_shift_id()
m = CagetteMember(partner_id) m = CagetteMember(partner_id)
......
...@@ -64,7 +64,7 @@ function remove_from_shift_template() { ...@@ -64,7 +64,7 @@ function remove_from_shift_template() {
* Send the request to register a member to a shift template. * Send the request to register a member to a shift template.
* Ask to unsuscribe first if the member was subscribed. * Ask to unsuscribe first if the member was subscribed.
* *
* @param {int} shift_type 1 === standard ; 2 === ftop * @param {int} shift_type 1 === standard ; 2 === ftop ; 3 === exempté
* @param {int} shift_template_id null for ftop shift type * @param {int} shift_template_id null for ftop shift type
* @param {String} shift_template_name selected shift template name * @param {String} shift_template_name selected shift template name
*/ */
...@@ -216,6 +216,22 @@ function set_subscription_area() { ...@@ -216,6 +216,22 @@ function set_subscription_area() {
false false
); );
}); });
$(document).off("click", "#shifts_calendar_area button[data-select='Exemption']");
$(document).on("click", "#shifts_calendar_area button[data-select='Exemption']", function() {
// Subscribe to comitee/ftop shift
msg = `Inscrire ${selected_member.name} en Éxempté ?`;
openModal(
msg,
() => {
shift_subscrition(3);
},
"Confirmer",
false
);
});
$(document).off("click", ".shift"); $(document).off("click", ".shift");
$(document).on("click", ".shift", function() { $(document).on("click", ".shift", function() {
// Subscribe to shift template // Subscribe to shift template
......
...@@ -49,6 +49,12 @@ def index(request): ...@@ -49,6 +49,12 @@ def index(request):
else: else:
context['committees_shift_id'] = committees_shift_id context['committees_shift_id'] = committees_shift_id
exemptions_shift_id = CagetteServices.get_exemptions_shift_id()
if exemptions_shift_id is None:
return HttpResponse("Le créneau des exemptions n'est pas configuré dans Odoo !")
else:
context['exemptions_shift_id'] = exemptions_shift_id
if 'no_picture_member_advice' in msettings: if 'no_picture_member_advice' in msettings:
if len(msettings['no_picture_member_advice']['value']) > 0: if len(msettings['no_picture_member_advice']['value']) > 0:
context['no_picture_member_advice'] = msettings['no_picture_member_advice']['value'] context['no_picture_member_advice'] = msettings['no_picture_member_advice']['value']
...@@ -88,6 +94,7 @@ def inscriptions(request, type=1): ...@@ -88,6 +94,7 @@ def inscriptions(request, type=1):
template = loader.get_template('members/inscriptions.html') template = loader.get_template('members/inscriptions.html')
committees_shift_id = CagetteServices.get_committees_shift_id() committees_shift_id = CagetteServices.get_committees_shift_id()
exemptions_shift_id = CagetteServices.get_exemptions_shift_id()
context = { context = {
'type': type, 'title': 'Inscriptions', 'type': type, 'title': 'Inscriptions',
'couchdb_server': settings.COUCHDB['url'], 'couchdb_server': settings.COUCHDB['url'],
...@@ -108,6 +115,7 @@ def inscriptions(request, type=1): ...@@ -108,6 +115,7 @@ def inscriptions(request, type=1):
'can_create_binome': getattr(settings, 'CAN_CREATE_BINOME', True), 'can_create_binome': getattr(settings, 'CAN_CREATE_BINOME', True),
'prepa_odoo_url' : getattr(settings, 'PREPA_ODOO_URL', '/members/prepa-odoo'), 'prepa_odoo_url' : getattr(settings, 'PREPA_ODOO_URL', '/members/prepa-odoo'),
'committees_shift_id': committees_shift_id, 'committees_shift_id': committees_shift_id,
'exemptions_shift_id': exemptions_shift_id,
} }
response = HttpResponse(template.render(context, request)) response = HttpResponse(template.render(context, request))
...@@ -125,6 +133,7 @@ def prepa_odoo(request): ...@@ -125,6 +133,7 @@ def prepa_odoo(request):
"""Generate coop subscription form, to be fill by BDM.""" """Generate coop subscription form, to be fill by BDM."""
template = loader.get_template('members/prepa_odoo.html') template = loader.get_template('members/prepa_odoo.html')
committees_shift_id = CagetteServices.get_committees_shift_id() committees_shift_id = CagetteServices.get_committees_shift_id()
exemptions_shift_id = CagetteServices.get_exemptions_shift_id()
context = {'title': 'Préparation Odoo Inscriptions', context = {'title': 'Préparation Odoo Inscriptions',
'warning_placeholder': 'Par exemple, il manque un chèque', 'warning_placeholder': 'Par exemple, il manque un chèque',
...@@ -141,6 +150,7 @@ def prepa_odoo(request): ...@@ -141,6 +150,7 @@ def prepa_odoo(request):
'show_ftop_button': getattr(settings, 'SHOW_FTOP_BUTTON', True), 'show_ftop_button': getattr(settings, 'SHOW_FTOP_BUTTON', True),
'db': settings.COUCHDB['dbs']['member'], 'db': settings.COUCHDB['dbs']['member'],
'committees_shift_id': committees_shift_id, 'committees_shift_id': committees_shift_id,
'exemptions_shift_id': exemptions_shift_id,
} }
# with_addr_complement # with_addr_complement
......
...@@ -447,13 +447,15 @@ function shift_loc_selection() { ...@@ -447,13 +447,15 @@ function shift_loc_selection() {
st_loc_buttons.removeClass('highlighted'); st_loc_buttons.removeClass('highlighted');
clicked.addClass('highlighted'); clicked.addClass('highlighted');
if (clicked.data('select') != 'Volant') { if (clicked.data('select') !== 'Volant' && clicked.data('select') !== 'Exemption') {
retrieve_and_draw_shift_tempates(); retrieve_and_draw_shift_tempates();
} else { } else if (clicked.data('select') === 'Volant') {
//shift_templates[volant] is not always set (when call from bdm interface) //shift_templates[volant] is not always set (when call from bdm interface)
if (typeof volant !== "undefined" && typeof shift_templates[volant] !== "undefined") { if (typeof volant !== "undefined" && typeof shift_templates[volant] !== "undefined") {
subscribe_shift(volant); subscribe_shift(volant);
} }
} else if (clicked.data('select') === 'Exemption') {
subscribe_shift(exemptions_shift_id);
} }
} }
......
...@@ -828,6 +828,23 @@ class CagetteServices(models.Model): ...@@ -828,6 +828,23 @@ class CagetteServices(models.Model):
return shift_id return shift_id
@staticmethod @staticmethod
def get_exemptions_shift_id():
shift_id = None
try:
api = OdooAPI()
res = api.search_read('ir.config_parameter',
[['key','=', 'lacagette_exemptions.exemptions_shift_id']],
['value'])
if len(res) > 0:
try:
shift_id = int(res[0]['value'])
except:
pass
except:
pass
return shift_id
@staticmethod
def get_first_ftop_shift_id(): def get_first_ftop_shift_id():
shift_id = None shift_id = None
try: try:
......
...@@ -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}}';
var exemptions_shift_id = '{{exemptions_shift_id}}';
const committees_shift_name = '{{committees_shift_name}}'; const committees_shift_name = '{{committees_shift_name}}';
var ASSOCIATE_MEMBER_SHIFT = '{{ASSOCIATE_MEMBER_SHIFT}}'; var ASSOCIATE_MEMBER_SHIFT = '{{ASSOCIATE_MEMBER_SHIFT}}';
</script> </script>
......
...@@ -197,6 +197,7 @@ ...@@ -197,6 +197,7 @@
var max_begin_hour = '{{max_begin_hour}}'; var max_begin_hour = '{{max_begin_hour}}';
var email_domain = '{{email_domain}}'; var email_domain = '{{email_domain}}';
var committees_shift_id = '{{committees_shift_id}}'; var committees_shift_id = '{{committees_shift_id}}';
var exemptions_shift_id = '{{exemptions_shift_id}}';
</script> </script>
<script src="{% static "js/all_common.js" %}?v=1651853225"></script> <script src="{% static "js/all_common.js" %}?v=1651853225"></script>
......
...@@ -107,6 +107,7 @@ ...@@ -107,6 +107,7 @@
var office_place_string = '{{office_place_string}}' var office_place_string = '{{office_place_string}}'
var max_begin_hour = '{{max_begin_hour}}' var max_begin_hour = '{{max_begin_hour}}'
var committees_shift_id = '{{committees_shift_id}}'; var committees_shift_id = '{{committees_shift_id}}';
var exemptions_shift_id = '{{exemptions_shift_id}}';
</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>
......
...@@ -7,6 +7,9 @@ ...@@ -7,6 +7,9 @@
ou ... ou ...
<br /> <br />
<button class="flex-container--column" data-select="Volant">Volant</button> <button class="flex-container--column" data-select="Volant">Volant</button>
ou ...
<br />
<button class="flex-container--column" data-select="Exemption">Exempté</button>
<div class="info"></div> <div class="info"></div>
</div> </div>
<div class="col-5 main_content"> <div class="col-5 main_content">
......
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
<br /> <br />
<button class="flex-container--column" data-select="Volant">Volant</button> <button class="flex-container--column" data-select="Volant">Volant</button>
{% endif %} {% endif %}
ou ...
<br />
<button class="flex-container--column" data-select="Exemption">Exempté</button>
<div class="info"></div> <div class="info"></div>
</div> </div>
<div class="col-5 main_content"> <div class="col-5 main_content">
......
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