Remove unused Organization and User serializers; update POSDeviceViewSet to directly construct organization data for response
This commit is contained in:
@@ -5,4 +5,4 @@ from rest_framework import serializers
|
|||||||
class DeviceSerializer(serializers.ModelSerializer):
|
class DeviceSerializer(serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = pos_models.Device
|
model = pos_models.Device
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
from apps.pos_device import models as pos_models
|
|
||||||
from rest_framework import serializers
|
|
||||||
|
|
||||||
|
|
||||||
class OrganizationSerializer(serializers.ModelSerializer):
|
|
||||||
class Meta:
|
|
||||||
model = pos_models.Organization
|
|
||||||
fields = ['id', 'name', 'en_name']
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
from django.contrib.auth.models import User as pos_models
|
|
||||||
from rest_framework import serializers
|
|
||||||
|
|
||||||
|
|
||||||
class UserSerializer(serializers.ModelSerializer):
|
|
||||||
class Meta:
|
|
||||||
model = pos_models.User
|
|
||||||
fields = ['id', 'username', 'first_name', 'last_name', 'email', 'mobile', 'phone', 'national_code']
|
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
from apps.pos_device.pos.api.v1.serializers.device import DeviceSerializer
|
from apps.pos_device.pos.api.v1.serializers.device import DeviceSerializer , OrganizationSerializer
|
||||||
from apps.pos_device.pos.api.v1.serializers.organization import OrganizationSerializer
|
|
||||||
from apps.pos_device.pos.api.v1.serializers.user import UserSerializer
|
|
||||||
from apps.authentication.services.service import get_users_of_organization
|
from apps.authentication.services.service import get_users_of_organization
|
||||||
from apps.pos_device.mixins.pos_device_mixin import POSDeviceMixin
|
from apps.pos_device.mixins.pos_device_mixin import POSDeviceMixin
|
||||||
from apps.pos_device import models as pos_models
|
from apps.pos_device import models as pos_models
|
||||||
@@ -80,10 +78,12 @@ class POSDeviceViewSet(viewsets.ModelViewSet, POSDeviceMixin):
|
|||||||
latitude=headers_data['device-lot'],
|
latitude=headers_data['device-lot'],
|
||||||
longitude=headers_data['device-lng'],
|
longitude=headers_data['device-lng'],
|
||||||
)
|
)
|
||||||
|
|
||||||
org_serializer = OrganizationSerializer(device_owner_org)
|
org_data = {
|
||||||
users_data = get_users_of_organization(device_owner_org)
|
'id': device_owner_org.id,
|
||||||
users_serializer = UserSerializer(users_data, many=True)
|
'name': device_owner_org.name,
|
||||||
|
'en_name': device_owner_org.en_name
|
||||||
|
}
|
||||||
|
|
||||||
return Response({
|
return Response({
|
||||||
"message": "login success - session activated",
|
"message": "login success - session activated",
|
||||||
@@ -92,8 +92,8 @@ class POSDeviceViewSet(viewsets.ModelViewSet, POSDeviceMixin):
|
|||||||
"password": device.password,
|
"password": device.password,
|
||||||
"provider": organization.name,
|
"provider": organization.name,
|
||||||
"provider_tell": '0214021',
|
"provider_tell": '0214021',
|
||||||
"device_owner": org_serializer.data,
|
"device_owner": org_data,
|
||||||
"device_owner_users": users_serializer.data
|
"device_owner_users": get_users_of_organization(device_owner_org)
|
||||||
}, status=status.HTTP_200_OK)
|
}, status=status.HTTP_200_OK)
|
||||||
|
|
||||||
return Response({
|
return Response({
|
||||||
|
|||||||
Reference in New Issue
Block a user