wagtail-longclaw/longclaw/longclaworders/api.py

24 wiersze
750 B
Python
Czysty Zwykły widok Historia

2017-02-10 09:06:35 +00:00
from django.apps import apps
from django.db import transaction
from rest_framework.decorators import api_view, permission_classes
from rest_framework import permissions, status, viewsets
from rest_framework.response import Response
2017-02-17 09:03:21 +00:00
from longclaw.longclaworders.models import Order
from longclaw.longclaworders.serializers import OrderSerializer
2017-02-10 09:06:35 +00:00
@api_view(["POST"])
def fulfill_order(request, pk):
''' Get all basket items
'''
order = Order.objects.get(id=pk)
order.status = Order.FULFILLED
order.save()
return Response(status=status.HTTP_204_NO_CONTENT)
class OrderViewSet(viewsets.ModelViewSet):
serializer_class = OrderSerializer
permission_classes = [permissions.IsAdminUser]
queryset = Order.objects.all()