distribution organizations info - upload document inventory
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from datetime import timedelta
|
||||
|
||||
from apps.pos_device.web.api.v1.serilaizers import device as device_serializer
|
||||
from apps.authentication.api.v1.api import UserViewSet
|
||||
from apps.authorization.models import UserRelations
|
||||
@@ -6,6 +8,8 @@ from apps.pos_device import models as pos_models
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.decorators import action
|
||||
from common.tools import CustomOperations
|
||||
from common.helpers import generate_code
|
||||
from django.utils.timezone import now
|
||||
from rest_framework import viewsets
|
||||
from django.db import transaction
|
||||
from rest_framework import status
|
||||
@@ -82,6 +86,20 @@ class DeviceViewSet(viewsets.ModelViewSet):
|
||||
serializer = self.get_serializer(page, many=True)
|
||||
return self.get_paginated_response(serializer.data)
|
||||
|
||||
def activate_device(self, request):
|
||||
""" activations of pos by a temporary code """
|
||||
|
||||
device = self.queryset.filter(serial=request.data['serial']).first()
|
||||
if not device or not device.is_activated:
|
||||
code = generate_code()
|
||||
pos_models.DeviceActivationCode.objects.create(
|
||||
code=code,
|
||||
expires_at=now() + timedelta(hours=2)
|
||||
)
|
||||
return Response({'code': code, 'detail': 'enter code in panel'}, status=status.HTTP_202_ACCEPTED)
|
||||
elif device.is_activated:
|
||||
raise APIException('device is activated', code=403)
|
||||
|
||||
|
||||
class DeviceVersionViewSet(viewsets.ModelViewSet):
|
||||
queryset = pos_models.DeviceVersion.objects.all()
|
||||
|
||||
Reference in New Issue
Block a user