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
85672b37
Commit
85672b37
authored
Jan 30, 2020
by
Gladys Forte
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validation Routing Table Form
parent
89d1097b
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
81 additions
and
32 deletions
+81
-32
app/applicationlayer/cms/form/header/views.py
app/applicationlayer/cms/form/header/views.py
+35
-1
app/businesslayer/changerequest/change_request.py
app/businesslayer/changerequest/change_request.py
+1
-20
app/businesslayer/changerequest/change_request_template.py
app/businesslayer/changerequest/change_request_template.py
+37
-2
config/settings/base.py
config/settings/base.py
+0
-1
config/settings/demo.py
config/settings/demo.py
+2
-2
config/settings/dev.py
config/settings/dev.py
+2
-2
config/settings/sit.py
config/settings/sit.py
+2
-2
config/settings/staging.py
config/settings/staging.py
+2
-2
No files found.
app/applicationlayer/cms/form/header/views.py
View file @
85672b37
...
@@ -1184,6 +1184,40 @@ class ChangeRequestFormPost(APIView):
...
@@ -1184,6 +1184,40 @@ class ChangeRequestFormPost(APIView):
try
:
try
:
frm_approvers
=
form_header
[
'frm_approvers'
]
frm_approvers
=
form_header
[
'frm_approvers'
]
# Routing Validations
result
=
change_request_template
.
validation_superuser_department
(
frm_approvers
)
if
result
is
True
:
message
=
{
'code'
:
400
,
'status'
:
'failed'
,
'message'
:
'Please remove Super User Department into routing table'
,
}
return
Response
(
message
,
status
=
status
.
HTTP_400_BAD_REQUEST
)
# Check if Vendor and Requestor are existing on routing table
if
len
(
frm_approvers
)
<
2
:
message
=
{
'code'
:
400
,
'status'
:
'failed'
,
'message'
:
'Please make sure to add an Approver, Vendor and Requestor into routing table'
,
}
return
Response
(
message
,
status
=
status
.
HTTP_400_BAD_REQUEST
)
else
:
result
=
change_request_template
.
validation_existing_vendor_requestor
(
frm_approvers
)
if
result
is
False
:
message
=
{
'code'
:
400
,
'status'
:
'failed'
,
'message'
:
'Please add Vendor/Implementor and Requestor into routing table'
,
}
return
Response
(
message
,
status
=
status
.
HTTP_400_BAD_REQUEST
)
# Do not allow adding an approver for the same level
# Do not allow adding an approver for the same level
validation_result
=
change_request_template
.
validation_approver_same_level
(
frm_approvers
)
validation_result
=
change_request_template
.
validation_approver_same_level
(
frm_approvers
)
if
validation_result
is
not
None
:
if
validation_result
is
not
None
:
...
@@ -1196,7 +1230,7 @@ class ChangeRequestFormPost(APIView):
...
@@ -1196,7 +1230,7 @@ class ChangeRequestFormPost(APIView):
status
=
status
.
HTTP_400_BAD_REQUEST
)
status
=
status
.
HTTP_400_BAD_REQUEST
)
# Restrict a requestor to submit a CR without atleast 1 approver
# Restrict a requestor to submit a CR without atleast 1 approver
counter
=
change_request
.
validation_existing_approver
(
frm_approvers
)
counter
=
change_request
_template
.
validation_existing_approver
(
frm_approvers
)
if
form_header
[
'status'
]
.
lower
()
==
'pending'
and
counter
==
0
:
if
form_header
[
'status'
]
.
lower
()
==
'pending'
and
counter
==
0
:
message
=
{
message
=
{
...
...
app/businesslayer/changerequest/change_request.py
View file @
85672b37
...
@@ -766,22 +766,3 @@ def cr_routing_actions(approver_instance, current_user, move_to_level):
...
@@ -766,22 +766,3 @@ def cr_routing_actions(approver_instance, current_user, move_to_level):
reset_autoemail_tables
(
form_code
)
reset_autoemail_tables
(
form_code
)
return
True
return
True
def
validation_existing_approver
(
approvers
):
counter
=
0
for
approver
in
approvers
:
# count all delegation not equal to Requestor and Vendor
if
approver
[
'delegation'
]
not
in
[
'DELEGATION-20191119-0000002'
,
'DELEGATION-20191119-0000001'
]:
counter
=
counter
+
1
return
counter
return
counter
app/businesslayer/changerequest/change_request_template.py
View file @
85672b37
...
@@ -106,6 +106,42 @@ def tmp_add_edit_delete(tmp_request_body,
...
@@ -106,6 +106,42 @@ def tmp_add_edit_delete(tmp_request_body,
return
True
return
True
# Check if superuser department included in routing table
def
validation_superuser_department
(
approvers
):
for
approver
in
approvers
:
if
approver
[
'delegation'
]
==
'DEPARTMENT-20190923-0000001'
:
return
True
else
:
return
False
# Check if routing table has Vendor and Requestor
def
validation_existing_vendor_requestor
(
approvers
):
approvers_data
=
sorted
(
approvers
,
key
=
itemgetter
(
'level'
))[
-
2
:]
if
(
approvers_data
[
0
][
'delegation'
]
==
'DELEGATION-20191119-0000002'
and
approvers_data
[
1
][
'delegation'
]
==
'DELEGATION-20191119-0000001'
):
return
True
else
:
return
False
# Check if routing table has atleast 1 approver
def
validation_existing_approver
(
approvers
):
counter
=
0
for
approver
in
approvers
:
# count all delegation not equal to Requestor and Vendor
if
approver
[
'delegation'
]
not
in
[
'DELEGATION-20191119-0000002'
,
'DELEGATION-20191119-0000001'
]:
counter
=
counter
+
1
return
counter
return
counter
# Check if a user has multiple same level in routing table
def
validation_approver_same_level
(
approvers
):
def
validation_approver_same_level
(
approvers
):
data_list_appr
=
[]
data_list_appr
=
[]
...
@@ -131,4 +167,3 @@ def validation_approver_same_level(approvers):
...
@@ -131,4 +167,3 @@ def validation_approver_same_level(approvers):
return
user_name
return
user_name
return
None
return
None
config/settings/base.py
View file @
85672b37
...
@@ -46,7 +46,6 @@ INSTALLED_APPS = [
...
@@ -46,7 +46,6 @@ INSTALLED_APPS = [
'app.accesslayer'
,
'app.accesslayer'
,
'app.entities'
,
'app.entities'
,
'channels'
,
'channels'
,
]
]
MIDDLEWARE
=
[
MIDDLEWARE
=
[
...
...
config/settings/demo.py
View file @
85672b37
...
@@ -14,8 +14,8 @@ CHANNEL_LAYERS = {
...
@@ -14,8 +14,8 @@ CHANNEL_LAYERS = {
'default'
:
{
'default'
:
{
'BACKEND'
:
'channels_redis.core.RedisChannelLayer'
,
'BACKEND'
:
'channels_redis.core.RedisChannelLayer'
,
'CONFIG'
:
{
'CONFIG'
:
{
#
"hosts": [('172.17.0.1', 6379)],
"hosts"
:
[(
'172.17.0.1'
,
6379
)],
"hosts"
:
[(
'127.0.0.1'
,
6379
)],
#
"hosts": [('127.0.0.1', 6379)],
},
},
},
},
}
}
...
...
config/settings/dev.py
View file @
85672b37
...
@@ -14,8 +14,8 @@ CHANNEL_LAYERS = {
...
@@ -14,8 +14,8 @@ CHANNEL_LAYERS = {
'default'
:
{
'default'
:
{
'BACKEND'
:
'channels_redis.core.RedisChannelLayer'
,
'BACKEND'
:
'channels_redis.core.RedisChannelLayer'
,
'CONFIG'
:
{
'CONFIG'
:
{
#
"hosts": [('172.17.0.1', 6379)],
"hosts"
:
[(
'172.17.0.1'
,
6379
)],
"hosts"
:
[(
'127.0.0.1'
,
6379
)],
#
"hosts": [('127.0.0.1', 6379)],
},
},
},
},
}
}
...
...
config/settings/sit.py
View file @
85672b37
...
@@ -13,8 +13,8 @@ CHANNEL_LAYERS = {
...
@@ -13,8 +13,8 @@ CHANNEL_LAYERS = {
'default'
:
{
'default'
:
{
'BACKEND'
:
'channels_redis.core.RedisChannelLayer'
,
'BACKEND'
:
'channels_redis.core.RedisChannelLayer'
,
'CONFIG'
:
{
'CONFIG'
:
{
#
"hosts": [('172.17.0.1', 6379)],
"hosts"
:
[(
'172.17.0.1'
,
6379
)],
"hosts"
:
[(
'127.0.0.1'
,
6379
)],
#
"hosts": [('127.0.0.1', 6379)],
},
},
},
},
}
}
...
...
config/settings/staging.py
View file @
85672b37
...
@@ -13,8 +13,8 @@ CHANNEL_LAYERS = {
...
@@ -13,8 +13,8 @@ CHANNEL_LAYERS = {
'default'
:
{
'default'
:
{
'BACKEND'
:
'channels_redis.core.RedisChannelLayer'
,
'BACKEND'
:
'channels_redis.core.RedisChannelLayer'
,
'CONFIG'
:
{
'CONFIG'
:
{
#
"hosts": [('172.17.0.1', 6379)],
"hosts"
:
[(
'172.17.0.1'
,
6379
)],
"hosts"
:
[(
'127.0.0.1'
,
6379
)],
#
"hosts": [('127.0.0.1', 6379)],
},
},
},
},
}
}
...
...
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