Make api functions writing to db atomic

pull/8/head
JamesRamm 2017-02-03 20:34:35 +00:00
rodzic 645710c9f0
commit 1cead7642b
2 zmienionych plików z 5 dodań i 2 usunięć

Wyświetl plik

@ -1,5 +1,5 @@
from django.apps import apps
from django.conf import settings
from django.db import transaction
from rest_framework.decorators import api_view, permission_classes
from rest_framework import permissions, status
from rest_framework.response import Response
@ -33,6 +33,7 @@ def get_item_count(request):
count = 0
return Response(data={"quantity": count}, status=status.HTTP_200_OK)
@transaction.atomic
@api_view(["POST"])
@permission_classes([permissions.AllowAny])
def add_to_basket(request):
@ -59,6 +60,7 @@ def add_to_basket(request):
return Response(data=serializer.data,
status=status.HTTP_201_CREATED)
@transaction.atomic
@api_view(["POST"])
@permission_classes([permissions.AllowAny])
def remove_from_basket(request):

Wyświetl plik

@ -2,6 +2,7 @@
Shipping logic and payment capture API
'''
from django.utils.module_loading import import_string
from django.db import transaction
from rest_framework.decorators import api_view, permission_classes
from rest_framework import permissions, status
from rest_framework.response import Response
@ -23,7 +24,7 @@ def create_token(request):
token = gateway.get_token(request)
return Response({'token': token}, status=status.HTTP_200_OK)
@transaction.atomic
@api_view(['POST'])
@permission_classes([permissions.AllowAny])
def capture_payment(request):