Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
R
red-ci-cd
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
red-group-test
red-ci-cd
Commits
47fddd2e
Commit
47fddd2e
authored
Sep 09, 2019
by
John Red Medrano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add company and department object at current user
parent
2980e76d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
6 deletions
+22
-6
app/applicationlayer/management/user/serializers.py
app/applicationlayer/management/user/serializers.py
+22
-6
No files found.
app/applicationlayer/management/user/serializers.py
View file @
47fddd2e
...
...
@@ -39,8 +39,10 @@ class UserManagementRoleSerializer(serializers.ModelSerializer):
class
UserManagementRetreiveSerializer
(
serializers
.
ModelSerializer
):
image
=
serializers
.
SerializerMethodField
()
applications
=
serializers
.
SerializerMethodField
()
department_name
=
serializers
.
ReadOnlyField
(
source
=
'department.name'
)
department_id
=
serializers
.
ReadOnlyField
(
source
=
'department.id'
)
# department_name = serializers.ReadOnlyField(source='department.name')
# department_id = serializers.ReadOnlyField(source='department.id')
department
=
serializers
.
SerializerMethodField
()
company
=
serializers
.
SerializerMethodField
()
# role = UserManagementRoleSerializer()
# special_permissions = serializers.SlugRelatedField(many=True,
# read_only=True,
...
...
@@ -49,19 +51,33 @@ class UserManagementRetreiveSerializer(serializers.ModelSerializer):
class
Meta
:
model
=
models
.
User
fields
=
(
'id'
,
'image'
,
'applications'
,
'id'
,
'image'
,
'
company'
,
'department'
,
'
applications'
,
'last_login'
,
'is_superuser'
,
'first_name'
,
'last_name'
,
'is_staff'
,
'is_active'
,
'date_joined'
,
'user_type'
,
'code'
,
'name'
,
'username'
,
'contact_no'
,
'email'
,
'department_name'
,
'doa'
,
'department_id'
,
'email'
,
'doa'
,
'default_app'
,
)
# exclude = ['password', 'application', 'groups', 'user_permissions']
def
get_department
(
self
,
user
):
data
=
{
"id"
:
user
.
department
.
id
,
"name"
:
user
.
department
.
name
}
return
data
def
get_company
(
self
,
user
):
data
=
{
"id"
:
user
.
department
.
company
.
id
,
"name"
:
user
.
department
.
company
.
name
}
return
data
def
get_image
(
self
,
user
):
request
=
self
.
context
.
get
(
'request'
)
...
...
@@ -102,7 +118,7 @@ class UserManagementRetreiveSerializer(serializers.ModelSerializer):
# list_mod.append(body)
app_body
=
{}
app_body
[
'app_code'
]
=
data
.
app_code
app_body
[
'app_code'
]
=
data
.
app_code
.
lower
()
app_body
[
'name'
]
=
data
.
name
app_body
[
'modules'
]
=
mod
list_app
.
append
(
app_body
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment