Add order termination logic
This commit is contained in:
parent
1b97fc8fc7
commit
89e853b490
2 changed files with 28 additions and 2 deletions
|
|
@ -313,3 +313,15 @@ class AdminOrderViewSet(mixins.ListModelMixin,
|
|||
|
||||
def get_queryset(self):
|
||||
return Order.objects.all()
|
||||
|
||||
@action(detail=True, methods=['post'])
|
||||
def terminate(self, request, pk):
|
||||
order = self.get_object()
|
||||
if order.is_terminated:
|
||||
return Response(
|
||||
{'error': 'Order is already terminated.'},
|
||||
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
|
||||
|
||||
else:
|
||||
order.terminate()
|
||||
return Response({}, status=status.HTTP_200_OK)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue