Commit 53435a62 authored by Gladys Forte's avatar Gladys Forte

{dev bugfix} Do not allow to save Vendor same level to other delegation Template Post

parent 9bfe763a
......@@ -172,5 +172,20 @@ def validation_poc_vendor_only(poc, approvers):
return validate
# Check if level if Vendor delegation has same level with other delegation
def validation_vendor_unique_level(approvers):
validate = False
data_level = []
for approver in 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 approver['level'] in data_level:
if not approver['delegation'] == 'DELEGATION-20191119-0000002':
validate = True
return validate
\ No newline at end of file
......@@ -14,7 +14,8 @@ from app.businesslayer.changerequest.change_request_template import (
validation_approver_same_level,
validation_existing_vendor_requestor,
validation_existing_approver,
validation_poc_vendor_only
validation_poc_vendor_only,
validation_vendor_unique_level
)
from app.applicationlayer.utils import error_message
......@@ -307,7 +308,7 @@ def TemplateValidation(function):
'failed', status.HTTP_400_BAD_REQUEST)
# Check if prefix already exists
prefix = ChangeRequestTemplateHeader.objects.get(
prefix = ChangeRequestTemplateHeader.objects.filter(
requested_to_template_id=template_header['requested_to_template_id'])
if prefix:
......@@ -345,6 +346,12 @@ def TemplateValidation(function):
if validate is True:
return error_message('400', 'Point of contact can only be assign to Vendor/Implementor',
'failed', status.HTTP_400_BAD_REQUEST)
# Do not allow to save Vendor same level to other delegation
validate = validation_vendor_unique_level(tmp_approvers)
if validate is True:
return error_message('400', 'Vendor/Implementor cannot have same level with other delegation/s',
'failed', status.HTTP_400_BAD_REQUEST)
return function(self, request, *args, **kwargs)
return wrapper
......
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