Commit 33703ce4 authored by Gladys Forte's avatar Gladys Forte

Merge branch 'product-dev' into 'product-sit'

Product dev

See merge request rms/Backend/api-main-service!852
parents fabb814c 6e2d5e7d
...@@ -12,6 +12,8 @@ from django.db.models import Q ...@@ -12,6 +12,8 @@ from django.db.models import Q
from rest_framework.response import Response from rest_framework.response import Response
from rest_framework.permissions import AllowAny from rest_framework.permissions import AllowAny
# from cms.applicationlayer.utilities import logged_user # from cms.applicationlayer.utilities import logged_user
from rest_framework.exceptions import ParseError
from rest_framework import status
class UserDownloadRequest(XLSXFileMixin, ReadOnlyModelViewSet): class UserDownloadRequest(XLSXFileMixin, ReadOnlyModelViewSet):
...@@ -23,11 +25,32 @@ class UserDownloadRequest(XLSXFileMixin, ReadOnlyModelViewSet): ...@@ -23,11 +25,32 @@ class UserDownloadRequest(XLSXFileMixin, ReadOnlyModelViewSet):
def list(self, request, *args, **kwargs): def list(self, request, *args, **kwargs):
# id_number = request.user.code # id_number = self.request.user
data = User.objects.all().exclude(id=1) data = User.objects.all().exclude(id=1)
user_type = data.values_list('user_type', flat=True)[0]
if user_type == 'CUA':
code = data.values_list('department__company', flat=True)[0]
data = User.objects.filter(
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':
data = User.objects.all().exclude(id=1)
elif user_type == 'OUA':
data = User.objects.all().exclude(id=1)
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 = headers(data=data, many=True)
serializer.is_valid(raise_exception=False) serializer.is_valid(raise_exception=False)
return Response(serializer.data) return Response(serializer.data)
column_header = { column_header = {
......
...@@ -184,8 +184,9 @@ CHANNEL_LAYERS = { ...@@ -184,8 +184,9 @@ CHANNEL_LAYERS = {
'default': { 'default': {
'BACKEND': 'channels_redis.core.RedisChannelLayer', 'BACKEND': 'channels_redis.core.RedisChannelLayer',
'CONFIG': { 'CONFIG': {
"hosts": [('172.17.0.1', 6379)], # "hosts": [('172.17.0.1', 6379)],
# "hosts": [('127.0.0.1', 6379)], # "hosts": [(os.environ.get('REDIS_HOST', 'localhost'),6379)],
"hosts": [('127.0.0.1', 6379)],
}, },
}, },
} }
......
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