some apis of pos
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from apps.pos_device.pos.api.v1.serializers.device import DeviceSerializer
|
||||
from apps.pos_device.mixins.pos_device_mixin import POSDeviceMixin
|
||||
from apps.pos_device import models as pos_models
|
||||
from rest_framework.permissions import AllowAny
|
||||
from rest_framework.decorators import action
|
||||
@@ -9,7 +10,7 @@ from django.db import transaction
|
||||
from rest_framework import status
|
||||
|
||||
|
||||
class POSDeviceViewSet(viewsets.ModelViewSet):
|
||||
class POSDeviceViewSet(viewsets.ModelViewSet, POSDeviceMixin):
|
||||
device_queryset = pos_models.Device.objects.all()
|
||||
session_queryset = pos_models.Sessions.objects.all()
|
||||
serializer_class = DeviceSerializer
|
||||
@@ -32,6 +33,9 @@ class POSDeviceViewSet(viewsets.ModelViewSet):
|
||||
def login(self, request):
|
||||
""" login of pos device """
|
||||
|
||||
# get device owner (organization)
|
||||
organization = self.get_device_organization()
|
||||
|
||||
# convert headers to dictionary
|
||||
headers_data = {key: request.headers.get(key) for key in self.HEADERS}
|
||||
|
||||
@@ -66,7 +70,8 @@ class POSDeviceViewSet(viewsets.ModelViewSet):
|
||||
return Response({
|
||||
"message": "login success - session activated",
|
||||
"device_identity": device.device_identity,
|
||||
"serial": device.serial
|
||||
"serial": device.serial,
|
||||
"device_owner": organization.name
|
||||
}, status=status.HTTP_200_OK)
|
||||
|
||||
return Response({
|
||||
|
||||
Reference in New Issue
Block a user