Skip to content

Commit

Permalink
Merge pull request #32 from gorserg/add_validation_for_shortlistedFirms
Browse files Browse the repository at this point in the history
minimal number of shortlistedFirm is 3.
if lot id in firm then it's must be id of tender lot
replace validation with min_size in args
  • Loading branch information
kroman0 committed Jul 22, 2016
2 parents 76038df + b2b364e commit 1dc56fa
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
10 changes: 7 additions & 3 deletions openprocurement/tender/competitivedialogue/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pyramid.security import Allow
from schematics.types.compound import ModelType
from schematics.types.serializable import serializable
from openprocurement.api.models import ITender, Identifier, Model, Value
from openprocurement.api.models import ITender, Identifier, Model, Value, get_tender
from openprocurement.api.utils import calculate_business_date, get_now
from openprocurement.tender.openua.models import (SifterListType, Item as BaseItem, Tender as BaseTenderUA,
TENDER_PERIOD as TENDERING_DURATION_UA)
Expand Down Expand Up @@ -211,6 +211,10 @@ def validate_features(self, data, features):
class LotId(Model):
id = StringType()

def validate_id(self, data, lot_id):
if lot_id and isinstance(data['__parent__'], Model) and lot_id not in [i.id for i in get_tender(data['__parent__']).lots]:
raise ValidationError(u"id should be one of lots")


class Firms(Model):
identifier = ModelType(Identifier, required=True)
Expand Down Expand Up @@ -334,7 +338,7 @@ class Tender(BaseTenderEU):
procurementMethodType = StringType(default=STAGE_2_EU_TYPE)
dialogue_token = StringType(required=True)
dialogueID = StringType()
shortlistedFirms = ListType(ModelType(Firms), required=True)
shortlistedFirms = ListType(ModelType(Firms), min_size=3, required=True)
tenderPeriod = ModelType(PeriodStartEndRequired, required=False,
default=init_PeriodStartEndRequired(TENDERING_DURATION_EU))
minimalStep = ModelType(Value, required=True, default=Value({'amount': 0}))
Expand Down Expand Up @@ -364,7 +368,7 @@ class Tender(BaseTenderUA):
procurementMethodType = StringType(default=STAGE_2_UA_TYPE)
dialogue_token = StringType(required=True)
dialogueID = StringType()
shortlistedFirms = ListType(ModelType(Firms), required=True)
shortlistedFirms = ListType(ModelType(Firms), min_size=3, required=True)
tenderPeriod = ModelType(PeriodStartEndRequired, required=False,
default=init_PeriodStartEndRequired(TENDERING_DURATION_UA))
minimalStep = ModelType(Value, required=True, default=Value({'amount': 0}))
Expand Down
23 changes: 18 additions & 5 deletions openprocurement/tender/competitivedialogue/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,25 @@
test_tender_stage2_data_ua["procurementMethod"] = "selective"
test_shortlistedFirms = [
{
"lots": [{"id": uuid4().hex}],
"identifier": test_organization["identifier"],
"name": test_organization["name"]
}
"identifier": {"scheme": test_organization["identifier"]['scheme'],
"id": u'00037257',
"uri": test_organization["identifier"]['uri']},
"name": "Test org name 1"
},
{
"identifier": {"scheme": test_organization["identifier"]['scheme'],
"id": u'00037257',
"uri": test_organization["identifier"]['uri']},
"name": "Test org name 2"
},
{
"identifier": {"scheme": test_organization["identifier"]['scheme'],
"id": u'00037257',
"uri": test_organization["identifier"]['uri']},
"name": "Test org name 3"
},
]
test_access_token_stage1 = uuid4().hex;
test_access_token_stage1 = uuid4().hex
test_tender_stage2_data_eu["shortlistedFirms"] = test_shortlistedFirms
test_tender_stage2_data_ua["shortlistedFirms"] = test_shortlistedFirms
test_tender_stage2_data_eu["dialogue_token"] = sha512(test_access_token_stage1).hexdigest()
Expand Down
Empty file.

0 comments on commit 1dc56fa

Please sign in to comment.