def create_awards(request): """ Function create NUMBER_OF_BIDS_TO_BE_QUALIFIED awards objects First award always in pending.verification status others in pending.waiting status """ auction = request.validated['auction'] auction.status = 'active.qualification' now = get_now() auction.awardPeriod = type(auction).awardPeriod({'startDate': now}) awarding_type = request.content_configurator.awarding_type valid_bids = [bid for bid in auction.bids if bid['value'] is not None] bids = chef(valid_bids, auction.features or [], [], True) bids_to_qualify = get_bids_to_qualify(bids) for i in xrange(0, bids_to_qualify): status = 'pending.waiting' if i == 0: status = 'pending.verification' bid = bids[i].serialize() award = make_award(request, auction, bid, status, now, parent=True) if bid['status'] == 'invalid': set_award_status_unsuccessful(award, now) if award.status == 'pending.verification': award.signingPeriod = award.paymentPeriod = award.verificationPeriod = { 'startDate': now } add_award_route_url(request, auction, award, awarding_type) auction.awards.append(award)
def create_awards(request): """ Function create NUMBER_OF_BIDS_TO_BE_QUALIFIED awards objects First award always in pending.verification status others in pending.waiting status """ auction = request.validated['auction'] auction.status = 'active.qualification' now = get_now() auction.awardPeriod = type(auction).awardPeriod({'startDate': now}) awarding_type = request.content_configurator.awarding_type bids = chef(auction.bids, auction.features or [], [], True) # minNumberOfQualifiedBids == 1 bids_to_qualify = get_bids_to_qualify(bids) for bid, status in izip_longest(bids[:bids_to_qualify], ['pending.verification'], fillvalue='pending.waiting'): bid = bid.serialize() award = make_award(request, auction, bid, status, now, parent=True) if bid['status'] == 'invalid': set_award_status_unsuccessful(award, now) if award.status == 'pending.verification': award.verificationPeriod = award.paymentPeriod = award.signingPeriod = { 'startDate': now } add_award_route_url(request, auction, award, awarding_type) auction.awards.append(award)
def test_set_award_status_unsuccessful(self): need_end_date = get_now() end_data = munch.Munch({'endDate': None}) award = munch.Munch({ 'status': 'successfull', 'complaintPeriod': end_data }) set_award_status_unsuccessful(award, need_end_date) self.assertEqual(award.status, 'unsuccessful') self.assertEqual(need_end_date.isoformat(), end_data.endDate.isoformat())
def _start_awarding(self): """ Function create NUMBER_OF_BIDS_TO_BE_QUALIFIED awards objects First award always in pending.verification status others in pending.waiting status In case that only one bid was applied, award object in pending.admission status will be created for that bid """ auction = self.context auction.status = 'active.qualification' now = get_now() auction.awardPeriod = type(auction).awardPeriod({'startDate': now}) awarding_type = self.awarding_type valid_bids = [bid for bid in auction.bids if self.is_bid_valid(bid)] award_status = 'pending.admission' if len( valid_bids ) == 1 and self.pending_admission_for_one_bid else 'pending' bids = chef(valid_bids, auction.features or [], [], True) bids_to_qualify = self.get_bids_to_qualify(bids) for bid, status in izip_longest(bids[:bids_to_qualify], [award_status], fillvalue='pending.waiting'): bid = bid.serialize() award = make_award(self.request, auction, bid, status, now, parent=True) if bid['status'] == 'invalid': set_award_status_unsuccessful(award, now) if award.status == 'pending': award.verificationPeriod = self.verificationPeriod() award.signingPeriod = self.signingPeriod() add_award_route_url(self.request, auction, award, awarding_type) if award.status == 'pending.admission': award.admissionPeriod = { 'startDate': now, 'endDate': calculate_business_date(start=now, context=auction, **award.ADMISSION_PERIOD_PARAMS) } add_award_route_url(self.request, auction, award, awarding_type) auction.awards.append(award) return True
def create_awards(request): """ Function create NUMBER_OF_BIDS_TO_BE_QUALIFIED awards objects First award always in pending.verification status others in pending.waiting status In case that only one bid was applied, award object in pending.admission status will be created for that bid """ auction = request.validated['auction'] auction.status = 'active.qualification' now = get_now() auction.awardPeriod = type(auction).awardPeriod({'startDate': now}) awarding_type = request.content_configurator.awarding_type valid_bids = [bid for bid in auction.bids if bid['value'] is not None] if len(valid_bids) == 1: bid = valid_bids[0].serialize() award = make_award(request, auction, bid, 'pending.admission', now, parent=True) if bid['status'] == 'invalid': set_award_status_unsuccessful(award, now) if award.status == 'pending.admission': award.admissionPeriod = { 'startDate': now, 'endDate': calculate_business_date(now, VERIFY_ADMISSION_PROTOCOL_TIME, auction, True, AWARDING_PERIODS_END_DATE_HOUR) } add_award_route_url(request, auction, award, awarding_type) auction.awards.append(award) else: bids = chef(valid_bids, auction.features or [], [], True) bids_to_qualify = get_bids_to_qualify(bids) for bid, status in izip_longest(bids[:bids_to_qualify], ['pending'], fillvalue='pending.waiting'): bid = bid.serialize() award = make_award(request, auction, bid, status, now, parent=True) if bid['status'] == 'invalid': set_award_status_unsuccessful(award, now) if award.status == 'pending': award.signingPeriod = award.verificationPeriod = { 'startDate': now } add_award_route_url(request, auction, award, awarding_type) auction.awards.append(award)