Commit 93a4afdf authored by John Red Medrano's avatar John Red Medrano

Merge pull request #87 in RMS/api-main-service from red-develop to RMSv2

* commit '09558182':
  add department name and company name at user list
parents e3868ae8 09558182
from rest_framework import serializers
from app.entities.models import User
from app.entities.models import User, Department
import ast
from django.contrib.auth.hashers import make_password, check_password
import re
......@@ -7,6 +7,22 @@ from django.contrib.auth import authenticate
class UserSerializer(serializers.ModelSerializer):
def to_representation(self, instance):
# department = Department.objects.filter(
# id=instance.company.id
# ).values().first()
# company_name = Department.objects.filter(
# id=instance.company.id
# ).values().first()
ret = super().to_representation(instance)
ret['department_name'] = instance.department.name
ret['company_name'] = instance.department.company.name
return ret
class Meta:
model = User
fields = (
......@@ -16,8 +32,7 @@ class UserSerializer(serializers.ModelSerializer):
'department',
'email', 'default_app',
'user_type', 'is_active',
'doa',
# 'password',
'doa'
)
......
......@@ -53,7 +53,6 @@ class UserManagementRetreiveSerializer(serializers.ModelSerializer):
'email', 'default_app',
'user_type', 'is_active',
'doa',
)
# exclude = ['password', 'application', 'groups', 'user_permissions']
......@@ -97,6 +96,7 @@ class UserManagementRetreiveSerializer(serializers.ModelSerializer):
if user.user_type == 'SU':
mod = data.modules.all().values()
remove = []
elif user.user_type == 'OUA':
remove.remove("Department Management")
remove.remove("User Management")
......
......@@ -63,4 +63,4 @@ VENDOR_ACCEPTANCE_MESSAGE = has ACCEPTED the change request;RMS-CRACCEPTED
VENDOR_REJECT_MESSAGE = has REJECTED the change request;RMS-CRREJECTED-VENDOR
[ADMIN]
CATCH_EMAIL = 'red@tirsolutions.com'
CATCH_EMAIL = red@tirsolutions.com
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