From 325a94a3203c8014d097ca4390e8b7019ca35544 Mon Sep 17 00:00:00 2001 From: sasha Date: Thu, 22 Nov 2018 12:32:39 +0200 Subject: [PATCH 1/3] added classification.id validator --- src/openprocurement/api/validation.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/openprocurement/api/validation.py b/src/openprocurement/api/validation.py index 0ec424ebcd..ff116dbdd2 100644 --- a/src/openprocurement/api/validation.py +++ b/src/openprocurement/api/validation.py @@ -108,3 +108,20 @@ def validate_items_uniq(items, *args): def validate_cpv_group(items, *args): if items and len(set([i.classification.id[:3] for i in items])) != 1: raise ValidationError(u"CPV group of items be identical") + + +def validate_classification_id(items, *args): + allowed_schemes = ['INN', 'ATC'] + for item in items: + if item.classification.id.startswith('336'): + schemes = [x.scheme for x in item.additionalClassifications] + if not set(schemes).issubset(set(allowed_schemes)): + raise ValidationError(u'additionalClassification of items wich classification.id starts with 336 \ +have to be one of {}'.format(allowed_schemes)) + if item.classification.id == '33600000-6': + if schemes.count('INN') != 1: + raise ValidationError(u"Item with classification.id=33600000-6 have to contain exactly one \ +additionalClassifications with scheme=INN") + if schemes.count('INN') > 1: + raise ValidationError(u"Item wich classification.id starts with 336 and contains \ +additionalClassification objects have to contain exactly one additionalClassifications with scheme=INN") \ No newline at end of file From aa7d30f0cbbe15d907c6d3b14bc75640ac2b5593 Mon Sep 17 00:00:00 2001 From: smithumble Date: Fri, 25 Jan 2019 09:16:12 +0200 Subject: [PATCH 2/3] Adjust mnn 336 validation error message --- src/openprocurement/api/validation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openprocurement/api/validation.py b/src/openprocurement/api/validation.py index ff116dbdd2..ad9ead25a7 100644 --- a/src/openprocurement/api/validation.py +++ b/src/openprocurement/api/validation.py @@ -124,4 +124,4 @@ def validate_classification_id(items, *args): additionalClassifications with scheme=INN") if schemes.count('INN') > 1: raise ValidationError(u"Item wich classification.id starts with 336 and contains \ -additionalClassification objects have to contain exactly one additionalClassifications with scheme=INN") \ No newline at end of file +additionalClassification objects have to contain no more than one additionalClassifications with scheme=INN") From 3c1f0e03550d1612012ede0414de05aafc9c72d6 Mon Sep 17 00:00:00 2001 From: smithumble Date: Tue, 29 Jan 2019 07:44:26 +0200 Subject: [PATCH 3/3] Fix inn validation --- src/openprocurement/api/validation.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/openprocurement/api/validation.py b/src/openprocurement/api/validation.py index ad9ead25a7..a054bab95f 100644 --- a/src/openprocurement/api/validation.py +++ b/src/openprocurement/api/validation.py @@ -111,13 +111,9 @@ def validate_cpv_group(items, *args): def validate_classification_id(items, *args): - allowed_schemes = ['INN', 'ATC'] for item in items: if item.classification.id.startswith('336'): schemes = [x.scheme for x in item.additionalClassifications] - if not set(schemes).issubset(set(allowed_schemes)): - raise ValidationError(u'additionalClassification of items wich classification.id starts with 336 \ -have to be one of {}'.format(allowed_schemes)) if item.classification.id == '33600000-6': if schemes.count('INN') != 1: raise ValidationError(u"Item with classification.id=33600000-6 have to contain exactly one \