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
31ad58a7
Commit
31ad58a7
authored
Sep 26, 2019
by
John Red Medrano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace company key to company object on change request template list
parent
617c68a3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
63 deletions
+26
-63
app/applicationlayer/cms/template/serializers.py
app/applicationlayer/cms/template/serializers.py
+23
-60
app/applicationlayer/cms/template/views.py
app/applicationlayer/cms/template/views.py
+1
-1
requirements/RMSv2 copy.postman_collection.json
requirements/RMSv2 copy.postman_collection.json
+2
-2
No files found.
app/applicationlayer/cms/template/serializers.py
View file @
31ad58a7
from
app.entities
import
models
from
app.entities
import
models
from
rest_framework
import
serializers
from
rest_framework
import
serializers
from
django.db.models
import
Q
from
django.db.models
import
Q
from
django.forms.models
import
model_to_dict
from
drf_writable_nested
import
WritableNestedModelSerializer
from
drf_writable_nested
import
WritableNestedModelSerializer
from
app.applicationlayer.cms.utils_cr
import
(
get_account_details
,
from
app.applicationlayer.cms.utils_cr
import
(
get_account_details
,
get_dept_details
,
get_dept_details
,
...
@@ -13,25 +14,12 @@ class ChangeRequestTemplateApproversSerializer(
...
@@ -13,25 +14,12 @@ class ChangeRequestTemplateApproversSerializer(
def
to_representation
(
self
,
instance
):
def
to_representation
(
self
,
instance
):
ret
=
super
()
.
to_representation
(
instance
)
ret
=
super
()
.
to_representation
(
instance
)
try
:
try
:
user
=
instance
.
user
ret
[
'company'
]
=
model_to_dict
(
instance
.
user
.
department
.
company
)
ret
[
'department'
]
=
model_to_dict
(
instance
.
user
.
department
)
user_details
=
get_account_details
(
user
.
code
)
ret
[
'name'
]
=
instance
.
user
.
name
name
=
user_details
.
values_list
(
'name'
,
flat
=
True
)[
0
]
ret
[
'email'
]
=
instance
.
user
.
email
email
=
user_details
.
values_list
(
'email'
,
flat
=
True
)[
0
]
ret
[
'contact_no'
]
=
instance
.
user
.
contact_no
contact_no
=
user_details
.
values_list
(
'contact_no'
,
flat
=
True
)[
0
]
dept_code
=
user_details
.
values_list
(
'department'
,
flat
=
True
)[
0
]
department_details
=
get_dept_details
(
dept_code
)
department
=
department_details
.
values_list
(
'name'
,
flat
=
True
)[
0
]
comp_code
=
department_details
.
values_list
(
'company'
,
flat
=
True
)[
0
]
company_details
=
get_companies_details
(
comp_code
)
company
=
company_details
.
values_list
(
'name'
,
flat
=
True
)[
0
]
ret
[
'company'
]
=
company
ret
[
'department'
]
=
department
ret
[
'name'
]
=
name
ret
[
'email'
]
=
email
ret
[
'contact_no'
]
=
contact_no
return
ret
return
ret
except
Exception
as
e
:
except
Exception
as
e
:
...
@@ -54,25 +42,13 @@ class ChangeRequestTemplateStakeHoldersSerializer(
...
@@ -54,25 +42,13 @@ class ChangeRequestTemplateStakeHoldersSerializer(
def
to_representation
(
self
,
instance
):
def
to_representation
(
self
,
instance
):
ret
=
super
()
.
to_representation
(
instance
)
ret
=
super
()
.
to_representation
(
instance
)
try
:
try
:
user
=
instance
.
user
ret
[
'company'
]
=
model_to_dict
(
instance
.
user
.
department
.
company
)
user_details
=
get_account_details
(
user
.
code
)
ret
[
'department'
]
=
model_to_dict
(
instance
.
user
.
department
)
name
=
user_details
.
values_list
(
'name'
,
flat
=
True
)[
0
]
ret
[
'name'
]
=
instance
.
user
.
name
email
=
user_details
.
values_list
(
'email'
,
flat
=
True
)[
0
]
ret
[
'email'
]
=
instance
.
user
.
email
contact_no
=
user_details
.
values_list
(
'contact_no'
,
flat
=
True
)[
0
]
dept_code
=
user_details
.
values_list
(
'department'
,
flat
=
True
)[
0
]
department_details
=
get_dept_details
(
dept_code
)
department
=
department_details
.
values_list
(
'name'
,
flat
=
True
)[
0
]
comp_code
=
department_details
.
values_list
(
'company'
,
flat
=
True
)[
0
]
company_details
=
get_companies_details
(
comp_code
)
company
=
company_details
.
values_list
(
'name'
,
flat
=
True
)[
0
]
ret
[
'company'
]
=
company
ret
[
'department'
]
=
department
ret
[
'name'
]
=
name
ret
[
'email'
]
=
email
ret
[
'contact_no'
]
=
contact_no
ret
[
'contact_no'
]
=
contact_no
return
ret
return
ret
except
Exception
as
e
:
except
Exception
as
e
:
...
@@ -122,34 +98,21 @@ class ChangeRequestTemplatesSerializer(
...
@@ -122,34 +98,21 @@ class ChangeRequestTemplatesSerializer(
def
to_representation
(
self
,
instance
):
def
to_representation
(
self
,
instance
):
ret
=
super
()
.
to_representation
(
instance
)
ret
=
super
()
.
to_representation
(
instance
)
try
:
try
:
company
=
instance
.
requested_to_company
.
code
department
=
instance
.
requested_to_department
.
code
ret
[
'company'
]
=
model_to_dict
(
instance
.
user
.
department
.
company
)
point_of_contact
=
instance
.
requested_to_user
.
code
ret
[
'department'
]
=
model_to_dict
(
instance
.
user
.
department
)
created_by
=
instance
.
created_by_user
.
code
ret
[
'point_of_contact'
]
=
model_to_dict
(
instance
.
requested_to_user
)
ret
[
'created_by'
]
=
instance
.
created_by_user
.
code
company
=
get_companies_details
(
company
)
company
=
company
.
values_list
(
'name'
,
flat
=
True
)[
0
]
department
=
get_dept_details
(
department
)
department
=
department
.
values_list
(
'name'
,
flat
=
True
)[
0
]
point_of_contact
=
get_account_details
(
point_of_contact
)
point_of_contact
=
point_of_contact
.
values_list
(
'name'
,
flat
=
True
)[
0
]
created_by
=
get_account_details
(
created_by
)
created_by
=
created_by
.
values_list
(
'name'
,
flat
=
True
)[
0
]
ret
[
'company'
]
=
company
ret
[
'department'
]
=
department
ret
[
'point_of_contact'
]
=
point_of_contact
ret
[
'created_by'
]
=
created_by
return
ret
return
ret
except
Exception
as
e
:
except
Exception
as
e
:
ret
[
'company'
]
=
"none"
ret
[
'company'
]
=
"none"
ret
[
'department'
]
=
"none"
ret
[
'department'
]
=
"none"
ret
[
'point_of_contact'
]
=
"none"
ret
[
'point_of_contact'
]
=
"none"
ret
[
'created_by'
]
=
"none"
ret
[
'created_by'
]
=
"none"
return
ret
return
ret
class
Meta
:
class
Meta
:
...
@@ -164,4 +127,4 @@ class ChangeRequestTemplatesSerializer(
...
@@ -164,4 +127,4 @@ class ChangeRequestTemplatesSerializer(
'tmp_approvers'
,
'tmp_stakes'
,
'tmp_attachments'
,
'tmp_approvers'
,
'tmp_stakes'
,
'tmp_attachments'
,
'tmp_details'
)
'tmp_details'
)
read_only_fields
=
[
'created'
,
'template_no'
]
read_only_fields
=
[
'created'
,
'template_no'
]
\ No newline at end of file
app/applicationlayer/cms/template/views.py
View file @
31ad58a7
...
@@ -364,7 +364,7 @@ class ChangeRequestTemplatePost(APIView):
...
@@ -364,7 +364,7 @@ class ChangeRequestTemplatePost(APIView):
if
serializerStake
.
is_valid
(
raise_exception
=
True
):
if
serializerStake
.
is_valid
(
raise_exception
=
True
):
serializerStake
.
save
()
serializerStake
.
save
()
# create template attachments
# create template attachments
if
template_header
[
'tmp_attachments'
]:
if
template_header
[
'tmp_attachments'
]:
tmp_attachments
=
template_header
[
'tmp_attachments'
]
tmp_attachments
=
template_header
[
'tmp_attachments'
]
...
...
requirements/RMSv2 copy.postman_collection.json
View file @
31ad58a7
...
@@ -1215,7 +1215,7 @@
...
@@ -1215,7 +1215,7 @@
],
],
"body"
:
{
"body"
:
{
"mode"
:
"raw"
,
"mode"
:
"raw"
,
"raw"
:
"{
\r\n\t\"
requested_to_template_name
\"
:
\"
Sample Template
\"
,
\r\n\t\"
requested_to_template_id
\"
:
\"
JTC21
\"
,
\r\n\t\"
requested_to_objective
\"
:
\"
Sample Objective
\"
,
\r\n\t\"
requested_to_target_date
\"
:
\"
10
\"
,
\r\n\t\"
requested_to_priority
\"
:
\"
High
\"
,
\r\n\t\"
description
\"
:
\"
sample description
\"
,
\r\n\t\"
created_by_department
\"
:
\"
admin
\"
,
\r\n\t\"
created_by_user
\"
:
\"
USER-20190913-0000006
\"
,
\r\n\t\"
requested_to_company
\"
:
\"
COMPANY-20190909-0000002
\"
,
\r\n\t\"
requested_to_department
\"
:
\"
DEPARTMENT-20190909-0000002
\"
,
\r\n\t\"
requested_to_user
\"
:
\"
USER-20190913-0000007
\"
,
\r\n\t\r\n\t\r\n\t\"
tmp_approvers
\"
: [{
\r\n\t\t\t\"
level
\"
:
\"
1
\"
,
\r\n\t\t\t\"
delegation
\"
:
\"
HOD
\"
,
\r\n\t\t\t\"
user
\"
:
\"\"\r\n\t\t
},
\r\n\t\t
{
\r\n\t\t\t\"
level
\"
:
\"
2
\"
,
\r\n\t\t\t\"
delegation
\"
:
\"
Approver
\"
,
\r\n\t\t\t\"
user
\"
:
\"
USER-20190913-0000009
\"\r\n\t\t
},
\r\n\t\t
{
\r\n\t\t\t\"
level
\"
:
\"
3
\"
,
\r\n\t\t\t\"
delegation
\"
:
\"
Approver
\"
,
\r\n\t\t\t\"
user
\"
:
\"
USER-20190913-0000008
\"\r\n\t\t
}
\r\n\t
],
\r\n\t\r\n\t\"
tmp_stakes
\"
: [{
\r\n\t\t\t\"
delegation
\"
:
\"
Mandatory Stakeholder
\"
,
\r\n\t\t\t\"
user
\"
:
\"
USER-20190913-0000009
\"\r\n\t\t
},
\r\n\t\t
{
\r\n\t\t\t\"
delegation
\"
:
\"
Stake Approver
\"
,
\r\n\t\t\t\"
user
\"
:
\"
USER-20190913-0000008
\"\r\n\t\t
}
\r\n\t
],
\r\n\t\r\n\t\"
tmp_attachments
\"
: [{
\r\n\t\t\t\"
attachment_type
\"
:
\"
Hello
\"
,
\r\n\t\t\t\"
attachment_name
\"
:
\"
heyu
\"
,
\r\n\t\t\t\"
file_name
\"
:
\"
Sample
\"
,
\r\n\t\t\t\"
description
\"
:
\"
Sameple Desc
\"
,
\r\n\t\t\t\"
uploaded_by
\"
:
\"
USER-20190913-0000006
\"\r\n\t\t
},
\r\n\t\t
{
\r\n\t\t\t\"
attachment_type
\"
:
\"
Hello
\"
,
\r\n\t\t\t\"
attachment_name
\"
:
\"
heyu
\"
,
\r\n\t\t\t\"
file_name
\"
:
\"
Sample
\"
,
\r\n\t\t\t\"
description
\"
:
\"
Sameple Desc
\"
,
\r\n\t\t\t\"
uploaded_by
\"
:
\"
USER-20190913-0000006
\"\r\n\t\t
}
\r\n\t
],
\r\n\t\r\n\t\"
tmp_details
\"
: [{
\r\n\t\t\t\"
field_idx
\"
:
\"
Hello
\"
,
\r\n\t\t\t\"
field_ref
\"
:
\"
heyu
\"
,
\r\n\t\t\t\"
field_val
\"
:
\"
Sample
\"
,
\r\n\t\t\t\"
field_props
\"
:
\"
Sameple Desc
\"\r\n\t\t
},
\r\n\t\t
{
\r\n\t\t\t\"
field_idx
\"
:
\"
Hello
\"
,
\r\n\t\t\t\"
field_ref
\"
:
\"
heyu
\"
,
\r\n\t\t\t\"
field_val
\"
:
\"
Sample
\"
,
\r\n\t\t\t\"
field_props
\"
:
\"
Sameple Desc
\"\r\n\t\t
}
\r\n\t
]
\r\n
}"
"raw"
:
"{
\r\n\t\"
requested_to_template_name
\"
:
\"
Sample Template
\"
,
\r\n\t\"
requested_to_template_id
\"
:
\"
JTC21
\"
,
\r\n\t\"
requested_to_objective
\"
:
\"
Sample Objective
\"
,
\r\n\t\"
requested_to_target_date
\"
:
\"
10
\"
,
\r\n\t\"
requested_to_priority
\"
:
\"
High
\"
,
\r\n\t\"
description
\"
:
\"
sample description
\"
,
\r\n\t\"
created_by_department
\"
:
\"
admin
\"
,
\r\n\t\"
created_by_user
\"
:
\"
USER-20190913-0000006
\"
,
\r\n\t\"
requested_to_company
\"
:
\"
COMPANY-20190909-0000002
\"
,
\r\n\t\"
requested_to_department
\"
:
\"
DEPARTMENT-20190909-0000002
\"
,
\r\n\t\"
requested_to_user
\"
:
\"
USER-20190913-0000007
\"
,
\r\n\t\r\n\t\r\n\t\"
tmp_approvers
\"
: [{
\r\n\t\t\t\"
level
\"
:
\"
1
\"
,
\r\n\t\t\t\"
delegation
\"
:
\"
HOD
\"
,
\r\n\t\t\t\"
user
\"
:
\"\"\r\n\t\t
},
\r\n\t\t
{
\r\n\t\t\t\"
level
\"
:
\"
2
\"
,
\r\n\t\t\t\"
delegation
\"
:
\"
Approver
\"
,
\r\n\t\t\t\"
user
\"
:
\"
USER-20190913-0000009
\"\r\n\t\t
},
\r\n\t\t
{
\r\n\t\t\t\"
level
\"
:
\"
3
\"
,
\r\n\t\t\t\"
delegation
\"
:
\"
Approver
\"
,
\r\n\t\t\t\"
user
\"
:
\"
USER-20190913-0000008
\"\r\n\t\t
}
\r\n\t
],
\r\n\t\r\n\t\"
tmp_stakes
\"
: [{
\r\n\t\t\t\"
delegation
\"
:
\"
Mandatory Stakeholder
\"
,
\r\n\t\t\t\"
user
\"
:
\"
USER-20190913-0000009
\"\r\n\t\t
},
\r\n\t\t
{
\r\n\t\t\t\"
delegation
\"
:
\"
Stake Approver
\"
,
\r\n\t\t\t\"
user
\"
:
\"
USER-20190913-0000008
\"\r\n\t\t
}
\r\n\t
],
\r\n\t\r\n\t\"
tmp_attachments
\"
: [{
\r\n\t\t\t\"
attachment_type
\"
:
\"
Hello
\"
,
\r\n\t\t\t\"
attachment_name
\"
:
\"
heyu
\"
,
\r\n\t\t\t\"
file_name
\"
:
\"
Sample
\"
,
\r\n\t\t\t\"
description
\"
:
\"
Sameple Desc
\"
,
\r\n\t\t\t\"
file_upload
\"
:
\"
1
\"
,
\r\n\t\t\t\"
uploaded_by
\"
:
\"
USER-20190913-0000006
\"\r\n\t\t
},
\r\n\t\t
{
\r\n\t\t\t\"
attachment_type
\"
:
\"
Hello
\"
,
\r\n\t\t\t\"
attachment_name
\"
:
\"
heyu
\"
,
\r\n\t\t\t\"
file_name
\"
:
\"
Sample
\"
,
\r\n\t\t\t\"
description
\"
:
\"
Sameple Desc
\"
,
\r\n\t\t\t\"
file_upload
\"
:
\"
2
\"
,
\r\n\t\t\t\"
uploaded_by
\"
:
\"
USER-20190913-0000006
\"\r\n\t\t
}
\r\n\t
],
\r\n\t\r\n\t\"
tmp_details
\"
: [{
\r\n\t\t\t\"
field_idx
\"
:
\"
Hello
\"
,
\r\n\t\t\t\"
field_ref
\"
:
\"
heyu
\"
,
\r\n\t\t\t\"
field_val
\"
:
\"
Sample
\"
,
\r\n\t\t\t\"
field_props
\"
:
\"
Sameple Desc
\"\r\n\t\t
},
\r\n\t\t
{
\r\n\t\t\t\"
field_idx
\"
:
\"
Hello
\"
,
\r\n\t\t\t\"
field_ref
\"
:
\"
heyu
\"
,
\r\n\t\t\t\"
field_val
\"
:
\"
Sample
\"
,
\r\n\t\t\t\"
field_props
\"
:
\"
Sameple Desc
\"\r\n\t\t
}
\r\n\t
]
\r\n
}"
},
},
"url"
:
{
"url"
:
{
"raw"
:
"{{baseurl}}/change-request/template-post/"
,
"raw"
:
"{{baseurl}}/change-request/template-post/"
,
...
@@ -2597,7 +2597,7 @@
...
@@ -2597,7 +2597,7 @@
"bearer"
:
[
"bearer"
:
[
{
{
"key"
:
"token"
,
"key"
:
"token"
,
"value"
:
"
84b7b325abedd50a537f78504ab2ff93dfe2d61b
"
,
"value"
:
"
ba9a275c67036d872f5cfd6862488fc115569fd3
"
,
"type"
:
"string"
"type"
:
"string"
}
}
]
]
...
...
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