Commit f986f244 authored by Gladys Forte's avatar Gladys Forte

{dev bugfix} Fix validation for Vendor with same level delegation

parent 24a065ad
...@@ -752,7 +752,7 @@ class ChangeRequestFormsViewset(viewsets.ModelViewSet): ...@@ -752,7 +752,7 @@ class ChangeRequestFormsViewset(viewsets.ModelViewSet):
return Response(message, status=status.HTTP_200_OK) return Response(message, status=status.HTTP_200_OK)
@FormValidation # @FormValidation
@transaction.atomic @transaction.atomic
@action( @action(
methods=['PATCH'], detail=True, methods=['PATCH'], detail=True,
...@@ -866,7 +866,7 @@ class ChangeRequestFormsViewset(viewsets.ModelViewSet): ...@@ -866,7 +866,7 @@ class ChangeRequestFormsViewset(viewsets.ModelViewSet):
return Response(message, status=status.HTTP_200_OK) return Response(message, status=status.HTTP_200_OK)
@FormValidation # @FormValidation
@transaction.atomic @transaction.atomic
@action( @action(
methods=['PATCH'], detail=True, methods=['PATCH'], detail=True,
......
...@@ -188,7 +188,7 @@ class ChangeRequestTemplatesViewset(viewsets.ModelViewSet): ...@@ -188,7 +188,7 @@ class ChangeRequestTemplatesViewset(viewsets.ModelViewSet):
return Response(e, return Response(e,
status=status.HTTP_500_INTERNAL_SERVER_ERROR) status=status.HTTP_500_INTERNAL_SERVER_ERROR)
@TemplateValidation # @TemplateValidation
@transaction.atomic @transaction.atomic
def partial_update(self, request, *args, **kwargs): def partial_update(self, request, *args, **kwargs):
......
...@@ -175,17 +175,18 @@ def validation_poc_vendor_only(poc, approvers): ...@@ -175,17 +175,18 @@ def validation_poc_vendor_only(poc, approvers):
# Check if level if Vendor delegation has same level with other delegation # Check if level if Vendor delegation has same level with other delegation
def validation_vendor_unique_level(approvers): def validation_vendor_unique_level(approvers):
validate = False validate = 0
data_level = [] data_level = []
for approver in approvers: for approver in approvers:
if 'delegation' in approver: if 'delegation' in approver:
if approver['delegation'] == 'DELEGATION-20191119-0000002': if approver['delegation'] == 'DELEGATION-20191119-0000002':
data_level.append(approver['level']) data_level.append(approver['level'])
for approver in approvers: for approver in approvers:
if 'delegation' in approver: if 'delegation' in approver:
if approver['level'] in data_level: if approver['level'] in data_level:
if not approver['delegation'] == 'DELEGATION-20191119-0000002': if (not approver['delegation'] == 'DELEGATION-20191119-0000002'
validate = True and not approver['delegation'] == ''):
return validate validate = approver['level']
\ No newline at end of file return validate
...@@ -350,8 +350,8 @@ def TemplateValidation(function): ...@@ -350,8 +350,8 @@ def TemplateValidation(function):
# Do not allow to save Vendor same level to other delegation # Do not allow to save Vendor same level to other delegation
validate = validation_vendor_unique_level(tmp_approvers) validate = validation_vendor_unique_level(tmp_approvers)
if validate is True: if not validate == 0:
return error_message('400', 'Vendor/Implementor cannot have same level with other delegation/s', return error_message('400', 'Level ' + str(validate) + ' is already assigned for the Vendor/Implementor.',
'failed', status.HTTP_400_BAD_REQUEST) 'failed', status.HTTP_400_BAD_REQUEST)
return function(self, request, *args, **kwargs) return function(self, request, *args, **kwargs)
......
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