def validate_relatedLot(self, data, relatedLot):
     if isinstance(data['__parent__'], Model) and (
             data['__parent__'].status
             not in ('invalid', 'deleted', 'draft')) and relatedLot not in [
                 i.id for i in get_tender(data['__parent__']).lots
             ]:
         raise ValidationError(u"relatedLot should be one of lots")
예제 #2
0
 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")
 def serialize(self, role=None, context=None):
     if role == 'view' and self.type == 'claim' and get_tender(
             self).status in [
                 'active.tendering', 'active.pre-qualification',
                 'active.pre-qualification.stand-still', 'active.auction'
             ]:
         role = 'view_claim'
     return super(Complaint, self).serialize(role=role, context=context)
 def validate_value(self, data, value):
     if value and isinstance(data['__parent__'], Model) and (data['__parent__'].status not in ('invalid', 'deleted', 'draft')) and data['relatedLot']:
         lots = [i for i in get_tender(data['__parent__']).lots if i.id == data['relatedLot']]
         if not lots:
             return
         lot = lots[0]
         if lot.value.amount < value.amount:
             raise ValidationError(u"value of bid should be less than value of lot")
         if lot.get('value').currency != value.currency:
             raise ValidationError(u"currency of bid should be identical to currency of value of lot")
         if lot.get('value').valueAddedTaxIncluded != value.valueAddedTaxIncluded:
             raise ValidationError(u"valueAddedTaxIncluded of bid should be identical to valueAddedTaxIncluded of value of lot")
 def validate_value(self, data, value):
     if value and isinstance(data['__parent__'], Bid) and ( data['__parent__'].status not in ('invalid', 'deleted')) and data['relatedLot']:
         lots = [i for i in get_tender(data['__parent__']).lots if i.id == data['relatedLot']]
         if not lots:
             return
         lot = lots[0]
         if lot.value.amount < value.amount:
             raise ValidationError(u"value of bid should be less than value of lot")
         if lot.get('value').currency != value.currency:
             raise ValidationError(u"currency of bid should be identical to currency of value of lot")
         if lot.get('value').valueAddedTaxIncluded != value.valueAddedTaxIncluded:
             raise ValidationError(u"valueAddedTaxIncluded of bid should be identical to valueAddedTaxIncluded of value of lot")
 def shouldStartAfter(self):
     if self.endDate:
         return
     tender = get_tender(self)
     lot = self.__parent__
     if tender.status not in ['active.tendering', 'active.pre-qualification.stand-still', 'active.auction'] or lot.status != 'active':
         return
     if tender.status == 'active.tendering' and tender.tenderPeriod.endDate:
         return calculate_business_date(tender.tenderPeriod.endDate, TENDERING_AUCTION, tender).isoformat()
     elif self.startDate and get_now() > calc_auction_end_time(lot.numberOfBids, self.startDate):
         return calc_auction_end_time(lot.numberOfBids, self.startDate).isoformat()
     elif tender.qualificationPeriod and tender.qualificationPeriod.endDate:
         return tender.qualificationPeriod.endDate.isoformat()
 def shouldStartAfter(self):
     if self.endDate:
         return
     tender = get_tender(self)
     lot = self.__parent__
     if tender.status not in ['active.tendering', 'active.pre-qualification.stand-still', 'active.auction'] or lot.status != 'active':
         return
     start_after = None
     if tender.status == 'active.tendering' and tender.tenderPeriod.endDate:
         start_after = calculate_business_date(tender.tenderPeriod.endDate, TENDERING_AUCTION, tender)
     elif self.startDate and get_now() > calc_auction_end_time(lot.numberOfBids, self.startDate):
         start_after = calc_auction_end_time(lot.numberOfBids, self.startDate)
     elif tender.qualificationPeriod and tender.qualificationPeriod.endDate:
         start_after = tender.qualificationPeriod.endDate
     if start_after:
         return rounding_shouldStartAfter(start_after, tender).isoformat()
 def shouldStartAfter(self):
     if self.endDate:
         return
     tender = get_tender(self)
     lot = self.__parent__
     if tender.status not in ['active.tendering', 'active.auction'] or lot.status != 'active':
         return
     if self.startDate and get_now() > calc_auction_end_time(lot.numberOfBids, self.startDate):
         return calc_auction_end_time(lot.numberOfBids, self.startDate).isoformat()
     else:
         decision_dates = [
             datetime.combine(complaint.dateDecision.date() + timedelta(days=3), time(0, tzinfo=complaint.dateDecision.tzinfo))
             for complaint in tender.complaints
             if complaint.dateDecision
         ]
         decision_dates.append(tender.tenderPeriod.endDate)
         return max(decision_dates).isoformat()
 def shouldStartAfter(self):
     if self.endDate:
         return
     tender = get_tender(self)
     lot = self.__parent__
     if tender.status not in ['active.tendering', 'active.auction'
                              ] or lot.status != 'active':
         return
     if self.startDate and get_now() > calc_auction_end_time(
             lot.numberOfBids, self.startDate):
         return calc_auction_end_time(lot.numberOfBids,
                                      self.startDate).isoformat()
     else:
         decision_dates = [
             datetime.combine(
                 complaint.dateDecision.date() + timedelta(days=3),
                 time(0, tzinfo=complaint.dateDecision.tzinfo))
             for complaint in tender.complaints if complaint.dateDecision
         ]
         decision_dates.append(tender.tenderPeriod.endDate)
         return max(decision_dates).isoformat()
 def validate_relatedLot(self, data, relatedLot):
     if isinstance(data['__parent__'], Model) and (data['__parent__'].status not in ('invalid', 'deleted')) and relatedLot not in [i.id for i in get_tender(data['__parent__']).lots]:
         raise ValidationError(u"relatedLot should be one of lots")
 def serialize(self, role=None, context=None):
     if role == 'view' and self.type == 'claim' and get_tender(self).status in ['active.tendering', 'active.pre-qualification', 'active.pre-qualification.stand-still', 'active.auction']:
         role = 'view_claim'
     return super(Complaint, self).serialize(role=role, context=context)
예제 #12
0
 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")
 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")