diff --git a/kfet/templates/kfet/kpsul.html b/kfet/templates/kfet/kpsul.html
index 2d7a1238..8b8a335a 100644
--- a/kfet/templates/kfet/kpsul.html
+++ b/kfet/templates/kfet/kpsul.html
@@ -378,6 +378,14 @@ $(document).ready(function() {
}
if ('negative' in data['errors'])
content += 'Autorisation de négatif requise';
+ if ('addcost' in data['errors']) {
+ content += '
';
+ if (data['errors']['addcost'].indexOf('__all__') != -1)
+ content += '- Compte invalide
';
+ if (data['errors']['addcost'].indexOf('amount') != -1)
+ content += '- Montant invalide
';
+ content += '
';
+ }
return content;
}
@@ -1082,16 +1090,16 @@ $(document).ready(function() {
});
break;
case 400:
- displayErrors(getErrorsHtml(data));
+ askAddcost(getErrorsHtml(data));
break;
}
});
}
- function askAddcost() {
+ function askAddcost(errors = '') {
$.confirm({
title: 'Majoration',
- content: '',
+ content: errors + '',
backgroundDismiss: true,
animation:'top',
closeAnimation:'bottom',
@@ -1108,7 +1116,7 @@ $(document).ready(function() {
that.$confirmButton.click();
});
},
- onClose: function() { this._lastFocused = articleSelect; }
+ onClose: function() { this._lastFocused = triInput; }
});
}
diff --git a/kfet/views.py b/kfet/views.py
index 4702f614..7e5f38d3 100644
--- a/kfet/views.py
+++ b/kfet/views.py
@@ -535,8 +535,8 @@ def kpsul_update_addcost(request):
addcost_form = AddcostForm(request.POST)
if not addcost_form.is_valid():
- print(addcost_form.errors)
- return JsonResponse({}, status=400)
+ data = { 'errors': { 'addcost': list(addcost_form.errors) } }
+ return JsonResponse(data, status=400)
required_perms = ['kfet.manage_addcosts']
if not request.user.has_perms(required_perms):
data = {