Commit 8db70778 by François C.

Merge branch '4713-exempt-coop' into 'dev_cooperatic'

retrieve exemptions shift id and create button to register to it

See merge request !227
parents ad509301 b820309d
Pipeline #2754 passed with stage
in 1 minute 29 seconds
......@@ -347,6 +347,7 @@ def manage_regular_shifts(request):
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")
exemptions_shift_id = CagetteServices.get_exemptions_shift_id()
context = {
'title': 'BDM - Créneaux',
'module': 'Membres',
......@@ -359,7 +360,8 @@ def manage_regular_shifts(request):
'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', '')
'ASSOCIATE_MEMBER_SHIFT' : getattr(settings, 'ASSOCIATE_MEMBER_SHIFT', ''),
'exemptions_shift_id': exemptions_shift_id,
}
return HttpResponse(template.render(context, request))
......@@ -580,7 +582,7 @@ def shift_subscription(request):
if shift_type == 1:
# 1 = standard
shift_template_id = int(data["shift_template_id"])
else:
elif shift_type == 2:
# 2 = ftop
# First try to get committees shift
......@@ -588,6 +590,10 @@ def shift_subscription(request):
# 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()
else:
# 3 = exempté
# Get exemptions shift
shift_template_id = CagetteServices.get_exemptions_shift_id()
m = CagetteMember(partner_id)
......
......@@ -64,7 +64,7 @@ function remove_from_shift_template() {
* Send the request to register a member to a shift template.
* 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 {String} shift_template_name selected shift template name
*/
......@@ -216,6 +216,22 @@ function set_subscription_area() {
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).on("click", ".shift", function() {
// Subscribe to shift template
......
......@@ -49,6 +49,12 @@ def index(request):
else:
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 len(msettings['no_picture_member_advice']['value']) > 0:
context['no_picture_member_advice'] = msettings['no_picture_member_advice']['value']
......@@ -88,6 +94,7 @@ def inscriptions(request, type=1):
template = loader.get_template('members/inscriptions.html')
committees_shift_id = CagetteServices.get_committees_shift_id()
exemptions_shift_id = CagetteServices.get_exemptions_shift_id()
context = {
'type': type, 'title': 'Inscriptions',
'couchdb_server': settings.COUCHDB['url'],
......@@ -108,6 +115,7 @@ def inscriptions(request, type=1):
'can_create_binome': getattr(settings, 'CAN_CREATE_BINOME', True),
'prepa_odoo_url' : getattr(settings, 'PREPA_ODOO_URL', '/members/prepa-odoo'),
'committees_shift_id': committees_shift_id,
'exemptions_shift_id': exemptions_shift_id,
}
response = HttpResponse(template.render(context, request))
......@@ -125,6 +133,7 @@ def prepa_odoo(request):
"""Generate coop subscription form, to be fill by BDM."""
template = loader.get_template('members/prepa_odoo.html')
committees_shift_id = CagetteServices.get_committees_shift_id()
exemptions_shift_id = CagetteServices.get_exemptions_shift_id()
context = {'title': 'Préparation Odoo Inscriptions',
'warning_placeholder': 'Par exemple, il manque un chèque',
......@@ -141,6 +150,7 @@ def prepa_odoo(request):
'show_ftop_button': getattr(settings, 'SHOW_FTOP_BUTTON', True),
'db': settings.COUCHDB['dbs']['member'],
'committees_shift_id': committees_shift_id,
'exemptions_shift_id': exemptions_shift_id,
}
# with_addr_complement
......
......@@ -447,13 +447,15 @@ function shift_loc_selection() {
st_loc_buttons.removeClass('highlighted');
clicked.addClass('highlighted');
if (clicked.data('select') != 'Volant') {
if (clicked.data('select') !== 'Volant' && clicked.data('select') !== 'Exemption') {
retrieve_and_draw_shift_tempates();
} else {
} else if (clicked.data('select') === '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);
}
} else if (clicked.data('select') === 'Exemption') {
subscribe_shift(exemptions_shift_id);
}
}
......
......@@ -829,6 +829,23 @@ class CagetteServices(models.Model):
return shift_id
@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():
shift_id = None
try:
......
......@@ -96,6 +96,7 @@
var couchdb_dbname = '{{db}}';
var couchdb_server = '{{couchdb_server}}' + couchdb_dbname;
var committees_shift_id = '{{committees_shift_id}}';
var exemptions_shift_id = '{{exemptions_shift_id}}';
const committees_shift_name = '{{committees_shift_name}}';
var ASSOCIATE_MEMBER_SHIFT = '{{ASSOCIATE_MEMBER_SHIFT}}';
</script>
......
......@@ -197,6 +197,7 @@
var max_begin_hour = '{{max_begin_hour}}';
var email_domain = '{{email_domain}}';
var committees_shift_id = '{{committees_shift_id}}';
var exemptions_shift_id = '{{exemptions_shift_id}}';
</script>
<script src="{% static "js/all_common.js" %}?v=1651853225"></script>
......
......@@ -107,6 +107,7 @@
var office_place_string = '{{office_place_string}}'
var max_begin_hour = '{{max_begin_hour}}'
var committees_shift_id = '{{committees_shift_id}}';
var exemptions_shift_id = '{{exemptions_shift_id}}';
</script>
<script src="{% static "js/all_common.js" %}"?v=1651853225></script>
<script src="{% static "js/common.js" %}"?v=1651853225></script>
......
......@@ -7,6 +7,9 @@
ou ...
<br />
<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>
<div class="col-5 main_content">
......
......@@ -9,6 +9,9 @@
<br />
<button class="flex-container--column" data-select="Volant">Volant</button>
{% endif %}
ou ...
<br />
<button class="flex-container--column" data-select="Exemption">Exempté</button>
<div class="info"></div>
</div>
<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