Commit 8d67c83d by Damien Moulard

prepare blocking extension if member can't have it

parent ad4867a3
...@@ -39,15 +39,24 @@ function request_delay() { ...@@ -39,15 +39,24 @@ function request_delay() {
resolve(); resolve();
}, },
error: function(data) { error: function(data) {
err = {msg: "erreur serveur lors de la création du délai", ctx: 'request_delay'}; if (data.status == 403
if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') { && typeof data.responseJSON != 'undefined'
err.msg += ' : ' + data.responseJSON.error; && data.responseJSON.message === "delays limit reached") {
closeModal();
alert("Vous avez mis plus de 6 mois pour rattraper un service, " +
"vous ne pouvez plus sélectionner de rattrapage depuis l'espace membre. " +
"Merci de contacter le BDM.");
} else {
err = {msg: "erreur serveur lors de la création du délai", ctx: 'request_delay'};
if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') {
err.msg += ' : ' + data.responseJSON.error;
}
report_JS_error(err, 'members_space.home');
closeModal();
alert('Erreur lors de la création du délai.');
} }
report_JS_error(err, 'members_space.home');
closeModal();
// TODO Notify
alert('Erreur lors de la création du délai.');
} }
}); });
}); });
......
...@@ -313,4 +313,8 @@ class CagetteShift(models.Model): ...@@ -313,4 +313,8 @@ class CagetteShift(models.Model):
return self.o_api.update('res.partner', partner_id, f) return self.o_api.update('res.partner', partner_id, f)
else: else:
return "makeups already at 0" return "makeups already at 0"
\ No newline at end of file
def member_can_have_delay(self, partner_id):
""" Can a member have a delay? """
return self.o_api.execute('res.partner', 'can_have_extension', [partner_id])
\ No newline at end of file
...@@ -265,8 +265,16 @@ def add_shift(request): ...@@ -265,8 +265,16 @@ def add_shift(request):
def request_delay(request): def request_delay(request):
if 'verif_token' in request.POST: if 'verif_token' in request.POST:
if Verification.verif_token(request.POST.get('verif_token'), int(request.POST.get('idPartner'))) is True: if Verification.verif_token(request.POST.get('verif_token'), int(request.POST.get('idPartner'))) is True:
cs = CagetteShift() cs = CagetteShift()
# TODO do we need this?
# use_new_members_space = getattr(settings, 'USE_NEW_MEMBERS_SPACE', False)
# if use_new_members_space is True:
# member_can_have_delay = cs.member_can_have_delay(int(request.POST.get('idPartner')))
# if member_can_have_delay is False:
# res = { 'message' : 'delays limit reached'}
# return JsonResponse(res, status=403)
data = { data = {
"idPartner": int(request.POST['idPartner']), "idPartner": int(request.POST['idPartner']),
"start_date" : request.POST['start_date'] "start_date" : request.POST['start_date']
......
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