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
985df577
Commit
985df577
authored
Feb 07, 2020
by
Gladys Forte
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
{dev bugfix} added condition for id=null add_edit_delete functions on header childs
parent
1667c2f5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
169 additions
and
97 deletions
+169
-97
app/applicationlayer/cms/form/header/views.py
app/applicationlayer/cms/form/header/views.py
+7
-4
app/businesslayer/changerequest/change_request.py
app/businesslayer/changerequest/change_request.py
+108
-62
app/businesslayer/changerequest/change_request_template.py
app/businesslayer/changerequest/change_request_template.py
+54
-25
app/helper/decorators.py
app/helper/decorators.py
+0
-6
No files found.
app/applicationlayer/cms/form/header/views.py
View file @
985df577
...
...
@@ -1192,6 +1192,13 @@ class ChangeRequestFormPost(APIView):
form_header
=
request
.
data
try
:
# Restrict a requestor to submit a CR without atleast 1 approver
counter
=
validation_existing_approver
(
form_header
[
'frm_approvers'
])
if
form_header
[
'status'
]
.
lower
()
==
'pending'
and
counter
==
0
:
return
error_message
(
'400'
,
'Please select at least 1 approver before submitting this request.'
,
'failed'
,
status
.
HTTP_400_BAD_REQUEST
)
data_list_approver
=
[]
data_list_stake
=
[]
data_list_attach
=
[]
...
...
@@ -1213,10 +1220,6 @@ class ChangeRequestFormPost(APIView):
'template_no'
:
form_header
[
'template_no'
]
}
# 'company_desc': None,
# 'department_desc': None,
# 'requested_desc': None,
sp1
=
transaction
.
savepoint
()
# nothing will save to db
serializer
=
ChangeRequestFormHeaderSerializer
(
...
...
app/businesslayer/changerequest/change_request.py
View file @
985df577
...
...
@@ -293,34 +293,56 @@ def form_add_edit_delete(form_request_body,
# update or create
for
i
in
form_request_body
:
if
"id"
in
i
:
frm_instance
=
queryset
.
objects
.
get
(
pk
=
i
[
'id'
]
)
if
not
i
[
'id'
]
is
None
:
frm_instance
=
queryset
.
objects
.
get
(
pk
=
i
[
'id'
]
)
frm_code
=
{
"form_code"
:
form_code
}
data
=
{
**
i
,
**
frm_code
}
frm_code
=
{
"form_code"
:
form_code
}
data
=
{
**
i
,
**
frm_code
}
serializer
=
serializer_data
(
frm_instance
,
data
=
data
,
partial
=
partial
,
context
=
{
"request"
:
self
.
request
})
serializer
=
serializer_data
(
frm_instance
,
data
=
data
,
partial
=
partial
,
context
=
{
"request"
:
self
.
request
})
serializer
.
is_valid
(
raise_exception
=
True
)
old_instance
=
model_to_dict
(
frm_instance
)
self
.
perform_update
(
serializer
)
new_instance
=
serializer
.
data
# comment
crhistory_save
(
batch_no
,
main_action
,
enums
.
CREnum
.
UPDATE
.
value
,
entity
,
form_code
,
old_instance
,
new_instance
)
serializer
.
is_valid
(
raise_exception
=
True
)
old_instance
=
model_to_dict
(
frm_instance
)
self
.
perform_update
(
serializer
)
new_instance
=
serializer
.
data
crhistory_save
(
batch_no
,
main_action
,
enums
.
CREnum
.
UPDATE
.
value
,
entity
,
form_code
,
old_instance
,
new_instance
)
else
:
frm_code
=
{
"form_code"
:
form_code
}
data
=
{
**
i
,
**
frm_code
}
serializer
=
serializer_data
(
data
=
data
,
context
=
{
"request"
:
self
.
request
})
serializer
.
is_valid
(
raise_exception
=
True
)
self
.
perform_create
(
serializer
)
new_instance
=
serializer
.
data
crhistory_save
(
batch_no
,
main_action
,
enums
.
CREnum
.
ADD
.
value
,
entity
,
form_code
,
None
,
new_instance
)
else
:
frm_code
=
{
...
...
@@ -328,7 +350,7 @@ def form_add_edit_delete(form_request_body,
}
data
=
{
**
i
,
**
frm_code
}
serializer
=
serializer_data
(
data
=
data
,
context
=
{
"request"
:
self
.
request
})
context
=
{
"request"
:
self
.
request
})
serializer
.
is_valid
(
raise_exception
=
True
)
self
.
perform_create
(
serializer
)
...
...
@@ -379,54 +401,78 @@ def attachment_add_edit_delete(form_request_body,
# update or create
for
i
in
form_request_body
:
if
"id"
in
i
:
frm_instance
=
queryset
.
objects
.
get
(
pk
=
i
[
'id'
]
)
if
not
i
[
'id'
]
is
None
:
frm_instance
=
queryset
.
objects
.
get
(
pk
=
i
[
'id'
]
)
data_old
=
{
'id'
:
frm_instance
.
id
,
'attachment_type'
:
frm_instance
.
attachment_type
,
'attachment_name'
:
frm_instance
.
attachment_name
,
'file_name'
:
frm_instance
.
file_name
,
'description'
:
frm_instance
.
description
,
'file_upload'
:
frm_instance
.
file_upload
.
id
}
data_old
=
{
'id'
:
frm_instance
.
id
,
'attachment_type'
:
frm_instance
.
attachment_type
,
'attachment_name'
:
frm_instance
.
attachment_name
,
'file_name'
:
frm_instance
.
file_name
,
'description'
:
frm_instance
.
description
,
'file_upload'
:
frm_instance
.
file_upload
.
id
}
data_new
=
{
'id'
:
i
[
'id'
],
'attachment_type'
:
i
[
'attachment_type'
],
'attachment_name'
:
i
[
'attachment_name'
],
'file_name'
:
i
[
'file_name'
],
'description'
:
i
[
'description'
],
'file_upload'
:
i
[
'file_upload'
]
}
frm_code
=
{
"form_code"
:
form_code
,
"uploaded_by"
:
id_number
}
data
=
{
**
i
,
**
frm_code
}
old_instance
=
model_to_dict
(
frm_instance
)
if
not
data_old
==
data_new
:
serializer
=
serializer_data
(
frm_instance
,
data
=
data
,
partial
=
partial
,
context
=
{
"request"
:
self
.
request
})
data_new
=
{
'id'
:
i
[
'id'
],
'attachment_type'
:
i
[
'attachment_type'
],
'attachment_name'
:
i
[
'attachment_name'
],
'file_name'
:
i
[
'file_name'
],
'description'
:
i
[
'description'
],
'file_upload'
:
i
[
'file_upload'
]
}
frm_code
=
{
"form_code"
:
form_code
,
"uploaded_by"
:
id_number
}
data
=
{
**
i
,
**
frm_code
}
old_instance
=
model_to_dict
(
frm_instance
)
if
not
data_old
==
data_new
:
serializer
=
serializer_data
(
frm_instance
,
data
=
data
,
partial
=
partial
,
context
=
{
"request"
:
self
.
request
})
serializer
.
is_valid
(
raise_exception
=
True
)
self
.
perform_update
(
serializer
)
new_instance
=
serializer
.
data
crhistory_save
(
batch_no
,
main_action
,
enums
.
CREnum
.
UPDATE
.
value
,
entity
,
form_code
,
old_instance
,
new_instance
)
else
:
frm_code
=
{
"form_code"
:
form_code
,
"uploaded_by"
:
id_number
}
data
=
{
**
i
,
**
frm_code
}
serializer
=
serializer_data
(
data
=
data
,
context
=
{
"request"
:
self
.
request
})
serializer
.
is_valid
(
raise_exception
=
True
)
self
.
perform_
upd
ate
(
serializer
)
self
.
perform_
cre
ate
(
serializer
)
new_instance
=
serializer
.
data
crhistory_save
(
batch_no
,
main_action
,
enums
.
CREnum
.
UPDATE
.
value
,
enums
.
CREnum
.
ADD
.
value
,
entity
,
form_code
,
old_instanc
e
,
Non
e
,
new_instance
)
...
...
app/businesslayer/changerequest/change_request_template.py
View file @
985df577
...
...
@@ -51,31 +51,60 @@ def tmp_add_edit_delete(tmp_request_body,
# update or create
for
i
in
tmp_request_body
:
if
"id"
in
i
:
tmp_instance
=
queryset
.
objects
.
get
(
pk
=
i
[
'id'
]
)
tmp_code
=
{
"template_no"
:
template_no
}
data
=
{
**
i
,
**
tmp_code
}
serializer
=
serializer_data
(
tmp_instance
,
data
=
data
,
partial
=
partial
)
if
not
i
[
'id'
]
is
None
:
tmp_instance
=
queryset
.
objects
.
get
(
pk
=
i
[
'id'
]
)
tmp_code
=
{
"template_no"
:
template_no
}
data
=
{
**
i
,
**
tmp_code
}
serializer
=
serializer_data
(
tmp_instance
,
data
=
data
,
partial
=
partial
)
serializer
.
is_valid
(
raise_exception
=
True
)
old_instance
=
model_to_dict
(
tmp_instance
)
self
.
perform_update
(
serializer
)
new_instance
=
serializer
.
data
log_save
(
enums
.
LogEnum
.
UPDATE
.
value
,
enum_type
,
i
[
'id'
],
old_instance
,
new_instance
)
else
:
tmp_code
=
{
"template_no"
:
template_no
}
data
=
{
**
i
,
**
tmp_code
}
serializer
=
serializer_data
(
data
=
data
)
serializer
.
is_valid
(
raise_exception
=
True
)
self
.
perform_create
(
serializer
)
new_instance
=
serializer
.
data
try
:
log_save
(
enums
.
LogEnum
.
ADD
.
value
,
enum_type
,
old_instance
[
'id'
],
''
,
new_instance
)
except
Exception
as
e
:
log_save
(
enums
.
LogEnum
.
ADD
.
value
,
enum_type
,
new_instance
[
'id'
],
''
,
new_instance
)
serializer
.
is_valid
(
raise_exception
=
True
)
old_instance
=
model_to_dict
(
tmp_instance
)
self
.
perform_update
(
serializer
)
new_instance
=
serializer
.
data
log_save
(
enums
.
LogEnum
.
UPDATE
.
value
,
enum_type
,
i
[
'id'
],
old_instance
,
new_instance
)
else
:
tmp_code
=
{
"template_no"
:
template_no
...
...
@@ -183,7 +212,7 @@ def validation_vendor_unique_level(approvers):
if
'delegation'
in
approver
:
if
approver
[
'delegation'
]
==
'DELEGATION-20191119-0000002'
:
data_level
.
append
(
approver
[
'level'
])
for
approver
in
approvers
:
if
'delegation'
in
approver
:
if
not
approver
[
'delegation'
]
is
None
:
...
...
app/helper/decorators.py
View file @
985df577
...
...
@@ -399,12 +399,6 @@ def FormValidation(function):
return
error_message
(
'400'
,
validation_result
+
' is already exist for the same level of approval.'
,
'failed'
,
status
.
HTTP_400_BAD_REQUEST
)
# Restrict a requestor to submit a CR without atleast 1 approver
counter
=
validation_existing_approver
(
frm_approvers
)
if
form_header
[
'status'
]
.
lower
()
==
'pending'
and
counter
==
0
:
return
error_message
(
'400'
,
'Please select at least 1 approver before submitting this request.'
,
'failed'
,
status
.
HTTP_400_BAD_REQUEST
)
# Do not allow saving user as Vendor and other delegation
validate
=
validation_poc_vendor_only
(
form_header
[
'requested_to_user'
],
frm_approvers
)
...
...
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