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

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

* commit '977678cb':
  edit hml user
parents 319ca52a 977678cb
......@@ -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
<!DOCTYPE html>
<html>
<head>
<title>RMS: New User Created</title>
</head>
<body style="font-family: arial;">
<h3>Resource Management System &#40;RMS&#41;</h3>
<h3 style="color:#888888;">New User Created</h3><br>
<p>Dear {name},</p><br>
<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>
<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>
<p>Sincerely,</p>
<p>RMS Team</p><br><br>
<p>Powered by</p>
<img src="https://s18.directupload.net/images/190807/jaewp4nx.png" width="120px"/>
</body>
<<<<<<< HEAD
<!DOCTYPE html>
<html>
<head>
<title>RMS: New User Created</title>
</head>
<body style="font-family: arial;">
<div style="max-width:100px!important;">
<img src="https://s18.directupload.net/images/190807/wjwrxx5i.jpg"/>
</div>
<h3>Resource Management System &#40;RMS&#41;</h3>
<h3 style="color:#888888;">New User Created</h3><br>
<p>Dear {name},</p><br>
<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>{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>
<p>Sincerely,</p>
<p>RMS Team</p><br><br>
<p>Powered by</p>
<img src="https://s18.directupload.net/images/190807/jaewp4nx.png" width="120px"/>
</body>
=======
<!DOCTYPE html>
<html>
<head>
<title>RMS: New User Created</title>
</head>
<body style="font-family: arial;">
<h3>Resource Management System &#40;RMS&#41;</h3>
<h3 style="color:#888888;">New User Created</h3><br>
<p>Dear {name},</p><br>
<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>
<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>
<p>Sincerely,</p>
<p>RMS Team</p><br><br>
<p>Powered by</p>
<img src="https://s18.directupload.net/images/190807/jaewp4nx.png" width="120px"/>
</body>
>>>>>>> 319ca52a542ff76918cbe79ef0d144f8156c3abb
</html>
\ No newline at end of file
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