Commit c3979f0a authored by Gladys Forte's avatar Gladys Forte

RMS45 User Management Download List -...

RMS45 User Management Download List - http://54.169.104.100:27015/rms/Backend/api-main-service/issues/26 - added conditon for user download list
parent 9412f5d5
......@@ -12,6 +12,8 @@ from django.db.models import Q
from rest_framework.response import Response
from rest_framework.permissions import AllowAny
# from cms.applicationlayer.utilities import logged_user
from rest_framework.exceptions import ParseError
from rest_framework import status
class UserDownloadRequest(XLSXFileMixin, ReadOnlyModelViewSet):
......@@ -26,13 +28,26 @@ class UserDownloadRequest(XLSXFileMixin, ReadOnlyModelViewSet):
# id_number = self.request.user
data = User.objects.all().exclude(id=1)
user_type = data.values_list('user_type', flat=True)[0]
# user_type = data.values_list('user_type', flat=True)
code = data.values_list('department__company', flat=True)
if user_type == 'CUA':
code = data.values_list('department__company', flat=True)[0]
data = User.objects.filter(
department__company=str(code)).exclude(id=1)
department__company=code).exclude(id=1)
elif user_type == 'DUA':
code = data.values_list('department', flat=True)[0]
data = User.objects.filter(
department=code).exclude(id=1)
elif user_type == 'SU':
pass
elif user_type == 'OUA':
pass
else:
return Response(
{"message": "Logged user is unauthorize to access this section"},
status=status.HTTP_400_BAD_REQUEST
)
serializer = headers(data=data, many=True)
serializer.is_valid(raise_exception=False)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment