Пример #1
0
 def __local_roles__(self):
     auction = get_auction(self)
     for bid in auction.bids:
         if bid.id == self.bid_id:
             bid_owner = bid.owner
             bid_owner_token = bid.owner_token
     return dict([('{}_{}'.format(bid_owner, bid_owner_token), 'bid_owner')])
Пример #2
0
 def __acl__(self):
     auction = get_auction(self)
     for bid in auction.bids:
         if bid.id == self.bid_id:
             bid_owner = bid.owner
             bid_owner_token = bid.owner_token
     return [(Allow, '{}_{}'.format(bid_owner, bid_owner_token), 'edit_auction_award')]
 def validate_value(self, data, value):
     if isinstance(data['__parent__'], Model):
         auction = get_auction(data['__parent__'])
         codes = dict([(i.code, [x.value for x in i.enum])
                       for i in (auction.features or [])])
         if data['code'] in codes and value not in codes[data['code']]:
             raise ValidationError(u"value should be one of feature value.")
 def award_signingPeriod(self):
     period = self.signingPeriod
     if not period:
         return
     if not period.endDate:
         auction = get_auction(self)
         calculate_enddate(auction, period, CONTRACT_SIGNING_TIME)
     return period.to_primitive()
 def award_paymentPeriod(self):
     period = self.paymentPeriod
     if not period:
         return
     if not period.endDate:
         auction = get_auction(self)
         calculate_enddate(auction, period, AWARD_PAYMENT_TIME)
     return period.to_primitive()
 def award_verificationPeriod(self):
     period = self.verificationPeriod
     if not period:
         return
     if not period.endDate:
         auction = get_auction(self)
         calculate_enddate(auction, period, VERIFY_AUCTION_PROTOCOL_TIME)
     return period.to_primitive()
 def validate_relatedItem(self, data, relatedItem):
     if not relatedItem and data.get('questionOf') in ['item', 'lot']:
         raise ValidationError(u'This field is required.')
     if relatedItem and isinstance(data['__parent__'], Model):
         auction = get_auction(data['__parent__'])
         if data.get('questionOf') == 'lot' and relatedItem not in [i.id for i in auction.lots]:
             raise ValidationError(u"relatedItem should be one of lots")
         if data.get('questionOf') == 'item' and relatedItem not in [i.id for i in auction.items]:
             raise ValidationError(u"relatedItem should be one of items")
Пример #8
0
 def award_verificationPeriod(self):
     period = self.verificationPeriod
     if not period:
         return
     if not period.endDate:
         auction = get_auction(self)
         period.endDate = calculate_business_date(
             period.startDate, VERIFY_AUCTION_PROTOCOL_TIME, auction, True,
             AWARDING_PERIODS_END_DATE_HOUR)
     return period.to_primitive()
Пример #9
0
 def award_signingPeriod(self):
     period = self.signingPeriod
     if not period:
         return
     if not period.endDate:
         auction = get_auction(self)
         period.endDate = calculate_business_date(
             period.startDate, CONTRACT_SIGNING_TIME, auction, True,
             AWARDING_PERIODS_END_DATE_HOUR)
     return period.to_primitive()
    def validate_relatedItem(self, data, relatedItem):
        if not relatedItem and data.get('questionOf') in ['item']:
            raise ValidationError(u'This field is required.')

        if relatedItem:
            auction = get_auction(data['__parent__'])
            if data.get('questionOf') == 'item' and relatedItem not in [
                    item.id for item in auction.items
            ]:
                raise ValidationError(u"relatedItem should be one of items")
Пример #11
0
 def award_signingPeriod(self):
     period = self.signingPeriod
     if not period:
         return
     if not period.endDate:
         auction = get_auction(self)
         period.endDate = calculate_business_date(
             start=period.startDate,
             context=auction,
             **self.SIGNING_PERIOD_PARAMS)
     return period.to_primitive()
Пример #12
0
 def award_verificationPeriod(self):
     period = self.verificationPeriod
     if not period:
         return
     if not period.endDate:
         auction = get_auction(self)
         period.endDate = calculate_business_date(
             start=period.startDate,
             context=auction,
             **self.VERIFICATION_PERIOD_PARAMS)
     return period.to_primitive()
 def validate_value(self, data, value):
     if value and isinstance(data['__parent__'], Model) and data['relatedLot']:
         lots = [i for i in get_auction(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 greater 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_relatedItem(self, data, relatedItem):
     if not relatedItem and data.get('questionOf') in ['item', 'lot']:
         raise ValidationError(u'This field is required.')
     if relatedItem and isinstance(data['__parent__'], Model):
         auction = get_auction(data['__parent__'])
         if data.get('questionOf') == 'lot' and relatedItem not in [
                 i.id for i in auction.lots
         ]:
             raise ValidationError(u"relatedItem should be one of lots")
         if data.get('questionOf') == 'item' and relatedItem not in [
                 i.id for i in auction.items
         ]:
             raise ValidationError(u"relatedItem should be one of items")
 def shouldStartAfter(self):
     if self.endDate:
         return
     auction = get_auction(self)
     lot = self.__parent__
     if auction.status not in ['active.tendering', 'active.auction'] or lot.status != 'active':
         return
     if auction.status == 'active.auction' and lot.numberOfBids < 2:
         return
     if self.startDate and get_now() > calc_auction_end_time(lot.numberOfBids, self.startDate):
         start_after = calc_auction_end_time(auction.numberOfBids, self.startDate)
     else:
         start_after = auction.tenderPeriod.endDate
     return rounding_shouldStartAfter(start_after, auction).isoformat()
Пример #16
0
 def award_signingPeriod(self):
     period = self.signingPeriod
     if not period:
         return
     if not period.endDate:
         auction = get_auction(self)
         period.endDate = calculate_business_date(period.startDate,
                                                  CONTRACT_SIGNING_TIME,
                                                  auction, True)
         round_to_18_hour_delta = period.endDate.replace(
             hour=18, minute=0, second=0) - period.endDate
         period.endDate = calculate_business_date(period.endDate,
                                                  round_to_18_hour_delta,
                                                  auction, False)
     return period.to_primitive()
Пример #17
0
    def award_verificationPeriod(self):
        period = self.verificationPeriod
        if not period:
            return
        if not period.endDate:
            auction = get_auction(self)
            period.endDate = calculate_business_date(
                period.startDate, VERIFY_AUCTION_PROTOCOL_TIME, auction, True)
            round_to_18_hour_delta = period.endDate.replace(
                hour=18, minute=0, second=0) - period.endDate
            period.endDate = calculate_business_date(period.endDate,
                                                     round_to_18_hour_delta,
                                                     auction, False)

        return period.to_primitive()
Пример #18
0
 def award_paymentPeriod(self):
     period = self.paymentPeriod
     if not period:
         return
     if not period.endDate:
         auction = get_auction(self)
         period.endDate = calculate_business_date(period.startDate,
                                                  AWARD_PAYMENT_TIME,
                                                  auction, True)
         round_to_18_hour_delta = period.endDate.replace(
             hour=18, minute=0, second=0) - period.endDate
         period.endDate = calculate_business_date(period.endDate,
                                                  round_to_18_hour_delta,
                                                  auction, False)
     return period.to_primitive()
 def shouldStartAfter(self):
     if self.endDate:
         return
     auction = get_auction(self)
     lot = self.__parent__
     if auction.status not in ['active.tendering', 'active.auction'
                               ] or lot.status != 'active':
         return
     if auction.status == 'active.auction' and lot.numberOfBids < 2:
         return
     if self.startDate and get_now() > calc_auction_end_time(
             lot.numberOfBids, self.startDate):
         start_after = calc_auction_end_time(auction.numberOfBids,
                                             self.startDate)
     else:
         start_after = auction.tenderPeriod.endDate
     return rounding_shouldStartAfter(start_after, auction).isoformat()
Пример #20
0
    def apply(self):
        """Choose order of prolongation and apply right"""
        self._check_documents_are_present()
        auction = get_auction(self.prolongation)
        contract = self.prolongation.__parent__
        applied_prolongations_count = len(
            [p for p in contract.prolongations if p.status == 'applied'])

        if applied_prolongations_count >= 2:
            raise Exception("Contract can be prolongated for 2 times only.")

        self.prolongation.status = 'applied'
        prolongation_period = (PROLONGATION_LONG_PERIOD
                               if applied_prolongations_count else
                               PROLONGATION_SHORT_PERIOD)
        contract.signingPeriod.endDate = calculate_business_date(
            contract.signingPeriod.startDate,
            prolongation_period,
            auction,
            working_days=True,
            specific_hour=CONTRACT_SIGNING_PERIOD_END_DATE_HOUR)
 def validate_value(self, data, value):
     if value and isinstance(data['__parent__'],
                             Model) and data['relatedLot']:
         lots = [
             i for i in get_auction(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 greater 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_code(self, data, code):
     if isinstance(data['__parent__'], Model) and code not in [i.code for i in (get_auction(data['__parent__']).features or [])]:
         raise ValidationError(u"code should be one of feature code.")
 def validate_relatedLot(self, data, relatedLot):
     if relatedLot and isinstance(data['__parent__'], Model) and relatedLot not in [i.id for i in get_auction(data['__parent__']).lots]:
         raise ValidationError(u"relatedLot should be one of lots")
 def validate_value(self, data, value):
     if isinstance(data['__parent__'], Model):
         auction = get_auction(data['__parent__'])
         codes = dict([(i.code, [x.value for x in i.enum]) for i in (auction.features or [])])
         if data['code'] in codes and value not in codes[data['code']]:
             raise ValidationError(u"value should be one of feature value.")
 def participation_url(self):
     if not self.participationUrl and self.status == "active":
         request = get_auction(self).__parent__.request
         url = generate_auction_url(request, bid_id=str(self.id))
         return url
 def validate_relatedLot(self, data, relatedLot):
     if relatedLot and isinstance(
             data['__parent__'], Model) and relatedLot not in [
                 i.id for i in get_auction(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_auction(self).status in ['active.enquiries', 'active.tendering']:
         role = 'view_claim'
     return super(BaseComplaint, self).serialize(role=role, context=context)
 def validate_startDate(self, data, startDate):
     auction = get_auction(data['__parent__'])
     if not auction.revisions and not startDate:
         raise ValidationError(u'This field is required.')
 def validate_participationUrl(self, data, url):
     if url and isinstance(data['__parent__'], Model) and get_auction(
             data['__parent__']).lots:
         raise ValidationError(u"url should be posted for each lot of bid")
 def serialize(self, role=None, context=None):
     if role == 'view' and self.type == 'claim' and get_auction(
             self).status in ['active.enquiries', 'active.tendering']:
         role = 'view_claim'
     return super(BaseComplaint, self).serialize(role=role, context=context)
 def validate_participationUrl(self, data, url):
     if url and isinstance(data['__parent__'], Model) and get_auction(data['__parent__']).lots:
         raise ValidationError(u"url should be posted for each lot of bid")
 def validate_code(self, data, code):
     if isinstance(data['__parent__'], Model) and code not in [
             i.code
             for i in (get_auction(data['__parent__']).features or [])
     ]:
         raise ValidationError(u"code should be one of feature code.")
Пример #33
0
 def validate_value(self, data, value):
     auction = get_auction(data['__parent__'])
     if auction.get('value').currency != value.currency:
         raise ValidationError(u"currency of taxHolidays value should be identical to currency of value of auction")