Commit 1520f01b by Damien Moulard

fix pr comments

parent 2c65a595
Pipeline #2105 passed with stage
in 1 minute 31 seconds
......@@ -116,8 +116,6 @@ valider votre présence en cherchant<br/>
votre nom ou numéro ci-dessous
"""
HAS_COMMITTEE_SHIFT = True
# Members space / shifts
UNSUBSCRIBED_FORM_LINK = 'https://docs.google.com/forms/d/e/1FAIpQLScWcpls-ruYIp7HdrjRF1B1TyuzdqhvlUIcUWynbEujfj3dTg/viewform'
UNSUBSCRIBED_MSG = 'Vous êtes désincrit·e, merci de remplir <a href="https://docs.google.com/forms/d/e/1FAIpQLSfPiC2PkSem9x_B5M7LKpoFNLDIz0k0V5I2W3Mra9AnqnQunw/viewform">ce formulaire</a> pour vous réinscrire sur un créneau.<br />Vous pouvez également contacter le Bureau des Membres en remplissant <a href="https://docs.google.com/forms/d/e/1FAIpQLSeZP0m5-EXPVJxEKJk6EjwSyZJtnbiGdYDuAeFI3ENsHAOikg/viewform">ce formulaire</a>'
......
......@@ -338,6 +338,7 @@ def manage_attached(request):
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()
context = {
'title': 'BDM - Créneaux',
'module': 'Membres',
......@@ -347,7 +348,7 @@ def manage_regular_shifts(request):
'mag_place_string': settings.MAG_NAME,
'open_on_sunday': getattr(settings, 'OPEN_ON_SUNDAY', False),
'show_ftop_button': getattr(settings, 'SHOW_FTOP_BUTTON', True),
'has_committe_shift': getattr(settings, 'HAS_COMMITTEE_SHIFT', True),
'has_committe_shift': committees_shift_id is not None,
'ASSOCIATE_MEMBER_SHIFT' : getattr(settings, 'ASSOCIATE_MEMBER_SHIFT', '')
}
return HttpResponse(template.render(context, request))
......@@ -496,8 +497,14 @@ def shift_subscription(request):
shift_template_id = data["shift_template_id"]
else:
# 2 = ftop
# 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()
m = CagetteMember(partner_id)
m.create_coop_shift_subscription(shift_template_id, shift_type)
......
......@@ -1538,6 +1538,29 @@ class CagetteServices(models.Model):
return shift_id
@staticmethod
def get_first_ftop_shift_id():
shift_id = None
try:
api = OdooAPI()
res = api.search_read('shift.template',
[['shift_type_id','=', 2]],
['id', 'registration_qty'])
# Get the ftop shift template with the max registrations: most likely the one in use
ftop_shift = {'id': None, 'registration_qty': 0}
for shift_reg in res:
if shift_reg["registration_qty"] > ftop_shift["registration_qty"]:
ftop_shift = shift_reg
try:
shift_id = int(ftop_shift['id'])
except:
pass
except:
pass
return shift_id
@staticmethod
def easy_validate_shift_presence(coop_id):
"""Add a presence point if the request is valid."""
res = {}
......
......@@ -26,7 +26,6 @@ function load_member_infos(divId, memberId) {
traditional: true,
contentType: "application/json; charset=utf-8",
success: function(data) {
console.log(data.member);
if (divId === 'parentInfo') {
parentId = data.member.id;
parentName = data.member.barcode_base + ' ' + data.member.name;
......@@ -197,10 +196,13 @@ function display_attached_members() {
function delete_pair(childId, gone_checked) {
var payload = {"child": {"id": childId}, "gone": []};
if (gone_checked.length > 0) {
$.each(gone_checked, function(i,e) {
const elts = $(e).attr('name').split("_")
payload['gone'].push(elts[0])
$.each(gone_checked, function(i, e) {
const elts = $(e).attr('name')
.split("_");
payload['gone'].push(elts[0]);
});
}
......@@ -237,6 +239,7 @@ function confirmDeletion(childId) {
openModal(modalContent, () => {
if (is_time_to('delete_pair')) {
const gone_checked = $('input.after_unattached_state:checked');
closeModal();
openModal();
delete_pair(childId, gone_checked);
......
......@@ -249,7 +249,7 @@ function update_members_makeups(member_ids, action) {
makeups_members[member_index].display_ftop_points += 1;
}
}
//console.log(makeups_members[member_index])
data.push({
member_id: mid,
target_makeups_nb: makeups_members[member_index].makeups_to_do,
......
......@@ -127,6 +127,7 @@ function display_member_info() {
$("#shifts_calendar_area").show();
// Wait for listeners to be set in common.js
// TODO use "signals" to avoid waiting an arbitrary time
setTimeout(() => {
// Cancel listeners from subscription page & set custom listeners
$("#shifts_calendar_area button[data-select='Volant']").off("click");
......
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