Skip to content

Commit

Permalink
Merge branch 'a154043417500164_PeriodEndRequired_validation'
Browse files Browse the repository at this point in the history
  • Loading branch information
kroman0 committed Jul 12, 2016
2 parents 2ad051f + b2403c8 commit 98aaa2c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions openprocurement/tender/openua/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
embedded_lot_role, default_lot_role, calc_auction_end_time, get_tender,
ComplaintModelType, validate_cpv_group, validate_items_uniq, Model,
rounding_shouldStartAfter,
PeriodEndRequired as BasePeriodEndRequired,
)
from openprocurement.api.models import ITender
from openprocurement.tender.openua.utils import (
Expand All @@ -46,6 +47,7 @@
ENQUIRY_PERIOD_TIME = timedelta(days=10)
TENDERING_EXTRA_PERIOD = timedelta(days=7)
AUCTION_PERIOD_TIME = timedelta(days=2)
PERIOD_END_REQUIRED_FROM = datetime(2016, 7, 15, tzinfo=TZ)


def bids_validation_wrapper(validation_func):
Expand Down Expand Up @@ -158,10 +160,14 @@ def shouldStartAfter(self):
return rounding_shouldStartAfter(start_after, tender).isoformat()


class PeriodEndRequired(Model):
class PeriodEndRequired(BasePeriodEndRequired):

startDate = IsoDateTimeType() # The state date for the period.
endDate = IsoDateTimeType(required=True) # The end date for the period.
def validate_startDate(self, data, value):
tender = get_tender(data['__parent__'])
if (tender.revisions[0].date if tender.revisions else get_now()) < PERIOD_END_REQUIRED_FROM:
return
if value and data.get('endDate') and data.get('endDate') < value:
raise ValidationError(u"period should begin before its end")


class PeriodStartEndRequired(Period):
Expand Down Expand Up @@ -440,6 +446,7 @@ class Options:
auctionPeriod = ModelType(TenderAuctionPeriod, default={})
bids = SifterListType(ModelType(Bid), default=list(), filter_by='status', filter_in_values=['invalid', 'deleted']) # A list of all the companies who entered submissions for the tender.
awards = ListType(ModelType(Award), default=list())
contracts = ListType(ModelType(Contract), default=list())
complaints = ListType(ComplaintModelType(Complaint), default=list())
procurementMethodType = StringType(default="aboveThresholdUA")
lots = ListType(ModelType(Lot), default=list(), validators=[validate_lots_uniq])
Expand Down

0 comments on commit 98aaa2c

Please sign in to comment.