add acceptor & terminal device to assignment - add phone to organization - set password for device when assignment
This commit is contained in:
@@ -94,6 +94,7 @@ class OrganizationType(BaseModel):
|
|||||||
class Organization(BaseModel):
|
class Organization(BaseModel):
|
||||||
name = models.CharField(max_length=250, null=True)
|
name = models.CharField(max_length=250, null=True)
|
||||||
en_name = models.CharField(max_length=150, null=True)
|
en_name = models.CharField(max_length=150, null=True)
|
||||||
|
phone = models.CharField(max_length=25, null=True)
|
||||||
type = models.ForeignKey(
|
type = models.ForeignKey(
|
||||||
'OrganizationType',
|
'OrganizationType',
|
||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ class POSDeviceViewSet(viewsets.ModelViewSet, POSDeviceMixin):
|
|||||||
if not session:
|
if not session:
|
||||||
session = pos_models.Sessions.objects.create(
|
session = pos_models.Sessions.objects.create(
|
||||||
device=device,
|
device=device,
|
||||||
name = headers_data['device-name'],
|
name=headers_data['device-name'],
|
||||||
version=headers_data['device-version'],
|
version=headers_data['device-version'],
|
||||||
mac=headers_data['device-mac'],
|
mac=headers_data['device-mac'],
|
||||||
ip=get_client_ip(request),
|
ip=get_client_ip(request),
|
||||||
@@ -100,23 +100,23 @@ class POSDeviceViewSet(viewsets.ModelViewSet, POSDeviceMixin):
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Response({
|
return Response({
|
||||||
"message": "خوش آمدید",
|
"message": "خوش آمدید", # noqa
|
||||||
"device_identity": device.device_identity,
|
"device_identity": device.device_identity,
|
||||||
"serial": device.serial,
|
"serial": device.serial,
|
||||||
"password": device.password,
|
"password": device.password,
|
||||||
"provider": organization.name,
|
"provider": organization.name,
|
||||||
"provider_tell": '0214021',
|
"provider_tell": organization.phone,
|
||||||
"device_owner": org_data,
|
"device_owner": org_data,
|
||||||
"device_owner_users": get_users_of_organization(device_owner_org)
|
"device_owner_users": get_users_of_organization(device_owner_org)
|
||||||
}, status=status.HTTP_200_OK)
|
}, status=status.HTTP_200_OK)
|
||||||
|
|
||||||
return Response({
|
return Response({
|
||||||
"message": "دستگاه در سیستم ثبت در انتظار فعال سازی توسط پذیرنده می باشد",
|
"message": "دستگاه در سیستم ثبت در انتظار فعال سازی توسط پذیرنده می باشد", # noqa
|
||||||
"device_identity": device.device_identity,
|
"device_identity": device.device_identity,
|
||||||
"password": "****",
|
"password": "****",
|
||||||
"serial": device.serial,
|
"serial": device.serial,
|
||||||
"provider": organization.name,
|
"provider": organization.name,
|
||||||
"provider_tell": '0214021',
|
"provider_tell": organization.phone,
|
||||||
}, status=status.HTTP_401_UNAUTHORIZED)
|
}, status=status.HTTP_401_UNAUTHORIZED)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@@ -129,11 +129,11 @@ class POSDeviceViewSet(viewsets.ModelViewSet, POSDeviceMixin):
|
|||||||
)
|
)
|
||||||
|
|
||||||
return Response({
|
return Response({
|
||||||
"message": "دستگاه در سیستم ثبت در انتظار فعال سازی توسط پذیرنده می باشد",
|
"message": "دستگاه در سیستم ثبت در انتظار فعال سازی توسط پذیرنده می باشد", # noqa
|
||||||
"device_identity": pre_device.device_identity,
|
"device_identity": pre_device.device_identity,
|
||||||
"password": "****",
|
"password": "****",
|
||||||
"provider": organization.name,
|
"provider": organization.name,
|
||||||
"provider_tell": '0214021',
|
"provider_tell": organization.phone,
|
||||||
}, status=status.HTTP_412_PRECONDITION_FAILED)
|
}, status=status.HTTP_412_PRECONDITION_FAILED)
|
||||||
|
|
||||||
@action(
|
@action(
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import random
|
||||||
|
import string
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
from apps.pos_device.web.api.v1.serilaizers import device as device_serializer
|
from apps.pos_device.web.api.v1.serilaizers import device as device_serializer
|
||||||
@@ -207,6 +209,10 @@ class DeviceAssignmentViewSet(viewsets.ModelViewSet, SoftDeleteMixin):
|
|||||||
|
|
||||||
# set device status to assigned
|
# set device status to assigned
|
||||||
assignment.device.assigned_state = True
|
assignment.device.assigned_state = True
|
||||||
|
assignment.device.acceptor = request.data['device_acceptor']
|
||||||
|
assignment.device.terminal = request.data['device_terminal']
|
||||||
|
if not assignment.device.password:
|
||||||
|
assignment.device.password = ''.join(random.choices(string.digits, k=6))
|
||||||
assignment.device.save()
|
assignment.device.save()
|
||||||
|
|
||||||
# set organization having pos status
|
# set organization having pos status
|
||||||
|
|||||||
Reference in New Issue
Block a user