Vérification supplémentaire sur K-Psul
- Ajout d'une exception Checkout.IsProtected - Rend impossible d'utiliser une caisse (Checkout) protégée (is_protected) dans K-Psul Une caisse protégée est, par exemple, la caisse qui recevra les rechargements par CB en ligne.
This commit is contained in:
parent
ffc845aefa
commit
fdb105ab84
2 changed files with 6 additions and 1 deletions
|
@ -186,6 +186,9 @@ class Checkout(models.Model):
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['-valid_to']
|
ordering = ['-valid_to']
|
||||||
|
|
||||||
|
class IsProtected(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
|
|
@ -397,7 +397,9 @@ def kpsul_perform_operations(request):
|
||||||
try:
|
try:
|
||||||
checkout_pk = request.POST.get('checkout', 0)
|
checkout_pk = request.POST.get('checkout', 0)
|
||||||
checkout = Checkout.objects.get(pk=checkout_pk)
|
checkout = Checkout.objects.get(pk=checkout_pk)
|
||||||
except (Checkout.DoesNotExist, ValueError):
|
if checkout.is_protected:
|
||||||
|
raise Checkout.IsProtected
|
||||||
|
except (Checkout.DoesNotExist, ValueError, Checkout.IsProtected):
|
||||||
data['errors'].append('Caisse invalide')
|
data['errors'].append('Caisse invalide')
|
||||||
if 'errors' in data:
|
if 'errors' in data:
|
||||||
return JsonResponse(data, status=400)
|
return JsonResponse(data, status=400)
|
||||||
|
|
Loading…
Add table
Reference in a new issue