Commit b870cb38 authored by John Red Medrano's avatar John Red Medrano

edit hml user

parent ca09dd48
......@@ -14,6 +14,9 @@ class UserSerializer(serializers.ModelSerializer):
ret = super().to_representation(instance)
ret['department'] = model_to_dict(instance.department)
ret['company'] = model_to_dict(instance.department.company)
# print(instance.application.all())
application = [data['id'] for data in instance.application.values('id')]
ret['application'] = application
return ret
class Meta:
......
......@@ -84,6 +84,7 @@ class UserViewSet(viewsets.ModelViewSet):
status=status.HTTP_201_CREATED
)
@decorators.rms.user_list
def list(self, request, *args, **kwargs):
queryset = self.filter_queryset(self.get_queryset())
......
......@@ -174,3 +174,32 @@ class rms:
return function(self, request, *args, **kwargs)
return wrapper
@staticmethod
def user_list(function):
@wraps(function)
def wrapper(self, request, *args, **kwargs):
if rms.user_type(self) == rms.enums_department:
id = rms.user(self).department.id
self.queryset = self.queryset.filter(
department=id
)
elif rms.user_type(self) == rms.enums_company:
id = rms.user(self).department.company.id
self.queryset = self.queryset.filter(
department__company=id
)
print(self.queryset.query)
elif rms.user_type(self) == rms.enums_super:
pass
else:
raise ParseError(
rms.access_error
)
return function(self, request, *args, **kwargs)
return wrapper
......@@ -16,7 +16,7 @@
<p>You have been created as a new user of RMS. Please see your default login details below.</p><br>
<b>Username</b><br>{username}<br><br>
<b>Password</b><br>password123<br><br>
<b>Password</b><br>{password}<br><br>
<p>You may change your password through the <u><a href="http://staging.rms.oneberrysystem.com/cms/profile/" style="text-decoration:underline;color:#007bff;" target="_blank">my profile</a></u> section of RMS any time.</p><br>
......
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