def collection_post(self): """Post a complaint """ tender = self.request.validated['tender'] complaint = self.request.validated['complaint'] complaint.relatedLot = self.context.lotID complaint.date = get_now() complaint.bid_id = get_bid_id(self.request) if complaint.status == 'claim': complaint.dateSubmitted = get_now() elif complaint.status == 'pending': complaint.type = 'complaint' complaint.dateSubmitted = get_now() else: complaint.status = 'draft' if self.context.status == 'unsuccessful' and complaint.status == 'claim' and self.context.bidID != complaint.bid_id: raise_operation_error(self.request, 'Can add claim only on unsuccessful qualification of your bid') complaint.complaintID = '{}.{}{}'.format(tender.tenderID, self.server_id, self.complaints_len(tender) + 1) set_ownership(complaint, self.request) self.context.complaints.append(complaint) if save_tender(self.request): self.LOGGER.info('Created tender qualification complaint {}'.format(complaint.id), extra=context_unpack(self.request, {'MESSAGE_ID': 'tender_qualification_complaint_create'}, {'complaint_id': complaint.id})) self.request.response.status = 201 self.request.response.headers['Location'] = self.request.route_url('{}:Tender Qualification Complaints'.format(tender.procurementMethodType), tender_id=tender.id, qualification_id=self.request.validated['qualification_id'], complaint_id=complaint['id']) return { 'data': complaint.serialize("view"), 'access': { 'token': complaint.owner_token } }
def collection_post(self): """Post a complaint """ tender = self.request.validated['tender'] if tender.status not in ['active.pre-qualification.stand-still']: self.request.errors.add('body', 'data', 'Can\'t add complaint in current ({}) tender status'.format(tender.status)) self.request.errors.status = 403 return if any([i.status != 'active' for i in tender.lots if i.id == self.context.lotID]): self.request.errors.add('body', 'data', 'Can add complaint only in active lot status') self.request.errors.status = 403 return if tender.qualificationPeriod and \ (tender.qualificationPeriod.startDate and tender.qualificationPeriod.startDate > get_now() or tender.qualificationPeriod.endDate and tender.qualificationPeriod.endDate < get_now()): self.request.errors.add('body', 'data', 'Can add complaint only in qualificationPeriod') self.request.errors.status = 403 return complaint = self.request.validated['complaint'] complaint.relatedLot = self.context.lotID complaint.date = get_now() complaint.bid_id = get_bid_id(self.request) if complaint.status == 'claim': complaint.dateSubmitted = get_now() elif complaint.status == 'pending': complaint.type = 'complaint' complaint.dateSubmitted = get_now() else: complaint.status = 'draft' if self.context.status == 'unsuccessful' and complaint.status == 'claim' and self.context.bidID != complaint.bid_id: self.request.errors.add('body', 'data', 'Can add claim only on unsuccessful qualification of your bid') self.request.errors.status = 403 return complaint.complaintID = '{}.{}{}'.format(tender.tenderID, self.server_id, self.complaints_len(tender) + 1) set_ownership(complaint, self.request) self.context.complaints.append(complaint) if save_tender(self.request): self.LOGGER.info('Created tender qualification complaint {}'.format(complaint.id), extra=context_unpack(self.request, {'MESSAGE_ID': 'tender_qualification_complaint_create'}, {'complaint_id': complaint.id})) self.request.response.status = 201 self.request.response.headers['Location'] = self.request.route_url('Tender EU Qualification Complaints', tender_id=tender.id, qualification_id=self.request.validated['qualification_id'], complaint_id=complaint['id']) return { 'data': complaint.serialize("view"), 'access': { 'token': complaint.owner_token } }
def collection_post(self): """Post a complaint """ tender = self.request.validated["tender"] complaint = self.request.validated["complaint"] complaint.relatedLot = self.context.lotID complaint.date = get_now() complaint.bid_id = get_bid_id(self.request) if complaint.status == "claim": complaint.dateSubmitted = get_now() elif complaint.status == "pending": complaint.type = "complaint" complaint.dateSubmitted = get_now() else: complaint.status = "draft" if (self.context.status == "unsuccessful" and complaint.status == "claim" and self.context.bidID != complaint.bid_id): raise_operation_error( self.request, "Can add claim only on unsuccessful qualification of your bid") complaint.complaintID = "{}.{}{}".format( tender.tenderID, self.server_id, self.complaints_len(tender) + 1) access = set_ownership(complaint, self.request) self.context.complaints.append(complaint) if save_tender(self.request): self.LOGGER.info( "Created tender qualification complaint {}".format( complaint.id), extra=context_unpack( self.request, {"MESSAGE_ID": "tender_qualification_complaint_create"}, {"complaint_id": complaint.id}, ), ) self.request.response.status = 201 self.request.response.headers["Location"] = self.request.route_url( "{}:Tender Qualification Complaints".format( tender.procurementMethodType), tender_id=tender.id, qualification_id=self.request.validated["qualification_id"], complaint_id=complaint["id"], ) return {"data": complaint.serialize("view"), "access": access}
def collection_post(self): """Post a complaint for award """ tender = self.request.validated["tender"] complaint = self.request.validated["complaint"] complaint.date = get_now() complaint.relatedLot = self.context.lotID complaint.bid_id = get_bid_id(self.request) if complaint.status == "claim": self.validate_posting_claim() complaint.dateSubmitted = get_now() elif complaint.status == "pending": complaint.type = "complaint" complaint.dateSubmitted = get_now() else: complaint.status = "draft" complaint.complaintID = "{}.{}{}".format(tender.tenderID, self.server_id, self.complaints_len(tender) + 1) access = set_ownership(complaint, self.request) self.context.complaints.append(complaint) if save_tender(self.request): self.LOGGER.info( "Created tender award complaint {}".format(complaint.id), extra=context_unpack( self.request, {"MESSAGE_ID": "tender_award_complaint_create"}, {"complaint_id": complaint.id} ), ) self.request.response.status = 201 self.request.response.headers["Location"] = self.request.route_url( "{}:Tender Award Complaints".format(tender.procurementMethodType), tender_id=tender.id, award_id=self.request.validated["award_id"], complaint_id=complaint["id"], ) return {"data": complaint.serialize("view"), "access": access}