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 """ auction = self.context if auction.status not in ['active.enquiries', 'active.tendering']: self.request.errors.add('body', 'data', 'Can\'t add complaint in current ({}) auction status'.format(auction.status)) self.request.errors.status = 403 return complaint = self.request.validated['complaint'] complaint.date = get_now() if complaint.status == 'claim': complaint.dateSubmitted = get_now() else: complaint.status = 'draft' complaint.complaintID = '{}.{}{}'.format(auction.auctionID, self.server_id, sum([len(i.complaints) for i in auction.awards], len(auction.complaints)) + 1) set_ownership(complaint, self.request) auction.complaints.append(complaint) if save_auction(self.request): self.LOGGER.info('Created auction complaint {}'.format(complaint.id), extra=context_unpack(self.request, {'MESSAGE_ID': 'auction_complaint_create'}, {'complaint_id': complaint.id})) self.request.response.status = 201 route = self.request.matched_route.name.replace("collection_", "") self.request.response.headers['Location'] = self.request.current_route_url(_route_name=route, complaint_id=complaint.id, _query={}) return { 'data': complaint.serialize(auction.status), 'access': { 'token': complaint.owner_token } }
def collection_post(self): """Post a complaint """ tender = self.context complaint = self.request.validated['complaint'] if complaint.status == 'claim': validate_submit_claim_time(self.request) elif complaint.status == 'pending': validate_submit_complaint_time(self.request) complaint.dateSubmitted = get_now() complaint.type = 'complaint' else: complaint.status = 'draft' complaint.complaintID = '{}.{}{}'.format(tender.tenderID, self.server_id, self.complaints_len(tender) + 1) set_ownership(complaint, self.request) tender.complaints.append(complaint) if save_tender(self.request): self.LOGGER.info('Created tender complaint {}'.format(complaint.id), extra=context_unpack(self.request, {'MESSAGE_ID': 'tender_complaint_create'}, {'complaint_id': complaint.id})) self.request.response.status = 201 self.request.response.headers['Location'] = self.request.route_url('{}:Tender Complaints'.format(tender.procurementMethodType), tender_id=tender.id, complaint_id=complaint.id) return { 'data': complaint.serialize(tender.status), 'access': { 'token': complaint.owner_token } }
def collection_post(self): """Post a complaint """ tender = self.context if tender.status not in ['active.enquiries', 'active.tendering']: self.request.errors.add('body', 'data', 'Can\'t add complaint in current ({}) tender status'.format(tender.status)) self.request.errors.status = 403 return complaint = self.request.validated['complaint'] if complaint.status == 'claim': complaint.dateSubmitted = get_now() else: complaint.status = 'draft' complaint.complaintID = '{}.{}{}'.format(tender.tenderID, self.server_id, sum([len(i.complaints) for i in tender.awards], len(tender.complaints)) + 1) set_ownership(complaint, self.request) tender.complaints.append(complaint) if save_tender(self.request): self.LOGGER.info('Created tender complaint {}'.format(complaint.id), extra=context_unpack(self.request, {'MESSAGE_ID': 'tender_complaint_create'}, {'complaint_id': complaint.id})) self.request.response.status = 201 self.request.response.headers['Location'] = self.request.route_url('Tender Complaints', tender_id=tender.id, complaint_id=complaint.id) return { 'data': complaint.serialize(tender.status), 'access': { 'token': complaint.owner_token } }
def collection_post(self): """Post a complaint for award """ tender = self.request.validated['tender'] if tender.status not in ['active.qualification', 'active.awarded']: 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 self.context.complaintPeriod and \ (self.context.complaintPeriod.startDate and self.context.complaintPeriod.startDate > get_now() or self.context.complaintPeriod.endDate and self.context.complaintPeriod.endDate < get_now()): self.request.errors.add( 'body', 'data', 'Can add complaint only in complaintPeriod') self.request.errors.status = 403 return complaint = self.request.validated['complaint'] complaint.date = get_now() complaint.relatedLot = self.context.lotID if complaint.status == '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) 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', tender_id=tender.id, award_id=self.request.validated['award_id'], complaint_id=complaint['id']) return { 'data': complaint.serialize("view"), 'access': { 'token': complaint.owner_token } }
def collection_post(self): """Post a complaint """ tender = self.context if tender.status not in ['active.enquiries', 'active.tendering']: self.request.errors.add( 'body', 'data', 'Can\'t add complaint in current ({}) tender status'.format( tender.status)) self.request.errors.status = 403 return complaint = self.request.validated['complaint'] if complaint.status == 'claim': complaint.dateSubmitted = get_now() else: complaint.status = 'draft' set_ownership(complaint, self.request) tender.complaints.append(complaint) if save_tender(self.request): LOGGER.info( 'Created tender complaint {}'.format(complaint.id), extra=context_unpack(self.request, {'MESSAGE_ID': 'tender_complaint_create'}, {'complaint_id': complaint.id})) self.request.response.status = 201 self.request.response.headers['Location'] = self.request.route_url( 'Tender Complaints', tender_id=tender.id, complaint_id=complaint.id) return { 'data': complaint.serialize("view"), 'access': { 'token': complaint.owner_token } }
def collection_post(self): """Post a complaint for award """ tender = self.request.validated['tender'] if tender.status != 'active': self.request.errors.add('body', 'data', 'Can\'t add complaint in current ({}) tender status'.format(tender.status)) self.request.errors.status = 403 return if self.context.complaintPeriod and \ (self.context.complaintPeriod.startDate and self.context.complaintPeriod.startDate > get_now() or self.context.complaintPeriod.endDate and self.context.complaintPeriod.endDate < get_now()): self.request.errors.add('body', 'data', 'Can add complaint only in complaintPeriod') self.request.errors.status = 403 return complaint = self.request.validated['complaint'] complaint.type = 'complaint' if complaint.status == 'pending': complaint.dateSubmitted = get_now() else: complaint.status = 'draft' complaint.complaintID = '{}.{}{}'.format(tender.tenderID, self.server_id, sum([len(i.complaints) for i in tender.awards], 1)) 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 negotiation Award Complaints', tender_id=tender.id, award_id=self.request.validated['award_id'], complaint_id=complaint['id']) return { 'data': complaint.serialize("view"), 'access': { 'token': complaint.owner_token } }
def collection_post(self): """Post a complaint """ tender = self.context complaint = self.request.validated['complaint'] if complaint.status == 'claim': validate_submit_claim_time(self.request) elif complaint.status == 'pending': validate_submit_complaint_time(self.request) complaint.dateSubmitted = get_now() complaint.type = 'complaint' else: complaint.status = 'draft' complaint.complaintID = '{}.{}{}'.format( tender.tenderID, self.server_id, self.complaints_len(tender) + 1) set_ownership(complaint, self.request) tender.complaints.append(complaint) if save_tender(self.request): self.LOGGER.info( 'Created tender complaint {}'.format(complaint.id), extra=context_unpack(self.request, {'MESSAGE_ID': 'tender_complaint_create'}, {'complaint_id': complaint.id})) self.request.response.status = 201 self.request.response.headers['Location'] = self.request.route_url( '{}:Tender Complaints'.format(tender.procurementMethodType), tender_id=tender.id, complaint_id=complaint.id) return { 'data': complaint.serialize(tender.status), 'access': { 'token': complaint.owner_token } }
def collection_post(self): """Post a complaint for award """ auction = self.request.validated['auction'] complaint = self.request.validated['complaint'] complaint.date = get_now() complaint.relatedLot = self.context.lotID if complaint.status == 'claim': complaint.dateSubmitted = get_now() else: complaint.status = 'draft' complaint.complaintID = '{}.{}{}'.format( auction.auctionID, self.server_id, sum([len(i.complaints) for i in auction.awards], len(auction.complaints)) + 1) set_ownership(complaint, self.request) self.context.complaints.append(complaint) if save_auction(self.request): self.LOGGER.info( 'Created auction award complaint {}'.format(complaint.id), extra=context_unpack( self.request, {'MESSAGE_ID': 'auction_award_complaint_create'}, {'complaint_id': complaint.id})) self.request.response.status = 201 route = self.request.matched_route.name.replace("collection_", "") self.request.response.headers[ 'Location'] = self.request.current_route_url( _route_name=route, complaint_id=complaint.id, _query={}) return { 'data': complaint.serialize("view"), 'access': { 'token': complaint.owner_token } }
def collection_post(self): """Post a complaint """ tender = self.context if tender.status != 'active.tendering': self.request.errors.add( 'body', 'data', 'Can\'t add complaint in current ({}) tender status'.format( tender.status)) self.request.errors.status = 403 return complaint = self.request.validated['complaint'] if complaint.status == 'claim': if get_now() > calculate_business_date(tender.tenderPeriod.endDate, -CLAIM_SUBMIT_TIME, tender): self.request.errors.add( 'body', 'data', 'Can submit claim not later than {0.days} days before tenderPeriod end' .format(CLAIM_SUBMIT_TIME)) self.request.errors.status = 403 return complaint.dateSubmitted = get_now() elif complaint.status == 'pending': if get_now() > calculate_business_date(tender.tenderPeriod.endDate, -COMPLAINT_SUBMIT_TIME, tender): self.request.errors.add( 'body', 'data', 'Can submit complaint not later than {0.days} days before tenderPeriod end' .format(COMPLAINT_SUBMIT_TIME)) self.request.errors.status = 403 return complaint.dateSubmitted = get_now() complaint.type = 'complaint' else: complaint.status = 'draft' complaint.complaintID = '{}.{}{}'.format( tender.tenderID, self.server_id, self.complaints_len(tender) + 1) set_ownership(complaint, self.request) tender.complaints.append(complaint) if save_tender(self.request): self.LOGGER.info( 'Created tender complaint {}'.format(complaint.id), extra=context_unpack(self.request, {'MESSAGE_ID': 'tender_complaint_create'}, {'complaint_id': complaint.id})) self.request.response.status = 201 self.request.response.headers['Location'] = self.request.route_url( 'Tender Complaints', tender_id=tender.id, complaint_id=complaint.id) return { 'data': complaint.serialize(tender.status), 'access': { 'token': complaint.owner_token } }
def collection_post(self): """Post a complaint for award """ auction = self.request.validated['auction'] if auction.status not in ['active.qualification', 'active.awarded']: self.request.errors.add( 'body', 'data', 'Can\'t add complaint in current ({}) auction status'.format( auction.status)) self.request.errors.status = 403 return if any([ i.status != 'active' for i in auction.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 self.context.complaintPeriod and \ (self.context.complaintPeriod.startDate and self.context.complaintPeriod.startDate > get_now() or self.context.complaintPeriod.endDate and self.context.complaintPeriod.endDate < get_now()): self.request.errors.add( 'body', 'data', 'Can add complaint only in complaintPeriod') self.request.errors.status = 403 return complaint = self.request.validated['complaint'] complaint.date = get_now() complaint.relatedLot = self.context.lotID if complaint.status == 'claim': complaint.dateSubmitted = get_now() else: complaint.status = 'draft' complaint.complaintID = '{}.{}{}'.format( auction.auctionID, self.server_id, sum([len(i.complaints) for i in auction.awards], len(auction.complaints)) + 1) set_ownership(complaint, self.request) self.context.complaints.append(complaint) if save_auction(self.request): self.LOGGER.info( 'Created auction award complaint {}'.format(complaint.id), extra=context_unpack( self.request, {'MESSAGE_ID': 'auction_award_complaint_create'}, {'complaint_id': complaint.id})) self.request.response.status = 201 route = self.request.matched_route.name.replace("collection_", "") self.request.response.headers[ 'Location'] = self.request.current_route_url( _route_name=route, complaint_id=complaint.id, _query={}) 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() if complaint.status == "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) 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 post(self): """This API request is targeted to creating new Asset.""" self.request.registry.getAdapter(self.request.validated['asset'], IAssetManager).create_asset( self.request) asset_id = generate_id() asset = self.request.validated['asset'] asset.id = asset_id if not asset.get('assetID'): asset.assetID = generate_asset_id(get_now(), self.db, self.server_id) self.request.registry.notify(AssetInitializeEvent(asset)) if self.request.json_body['data'].get('status') == 'draft': asset.status = 'draft' acc = set_ownership(asset, self.request) self.request.validated['asset'] = asset self.request.validated['asset_src'] = {} if save_asset(self.request): self.LOGGER.info( 'Created asset {} ({})'.format(asset_id, asset.assetID), extra=context_unpack(self.request, {'MESSAGE_ID': 'asset_create'}, { 'asset_id': asset_id, 'assetID': asset.assetID })) self.request.response.status = 201 self.request.response.headers['Location'] = self.request.route_url( 'Asset', asset_id=asset_id) return {'data': asset.serialize(asset.status), 'access': acc}
def collection_post(self): """Post a complaint for award """ tender = self.request.validated['tender'] complaint = self.request.validated['complaint'] complaint.date = get_now() complaint.type = 'complaint' if complaint.status == 'pending': complaint.dateSubmitted = get_now() else: complaint.status = 'draft' complaint.complaintID = '{}.{}{}'.format( tender.tenderID, self.server_id, sum([len(i.complaints) for i in tender.awards], 1)) acc = 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': acc}
def post(self): """This API request is targeted to creating new Lot.""" lot_id = generate_id() lot = self.request.validated['lot'] lot.id = lot_id if not lot.get('lotID'): lot.lotID = generate_lot_id(get_now(), self.db, self.server_id) self.request.registry.notify(LotInitializeEvent(lot)) default_status = type(lot).fields['status'].default status = self.request.json_body['data'].get('status', default_status) if status == 'draft': lot.status = status else: self.request.errors.add('body', 'status', 'You can create only in draft status') self.request.errors.status = 403 return acc = set_ownership(lot, self.request) self.request.validated['lot'] = lot self.request.validated['lot_src'] = {} if save_lot(self.request): self.LOGGER.info('Created lot {} ({})'.format(lot_id, lot.lotID), extra=context_unpack(self.request, {'MESSAGE_ID': 'lot_create'}, { 'lot_id': lot_id, 'lotID': lot.lotID })) self.request.response.status = 201 self.request.response.headers['Location'] = self.request.route_url( '{}:Lot'.format(lot.lotType), lot_id=lot_id) return {'data': lot.serialize(lot.status), 'access': acc}
def collection_post(self): """Post a complaint for cancellation """ tender = self.request.validated["tender"] complaint = self.request.validated["complaint"] complaint.date = get_now() complaint.complaintID = "{}.{}{}".format( tender.tenderID, self.server_id, calculate_total_complaints(tender) + 1) access = set_ownership(complaint, self.request) self.context.complaints.append(complaint) if save_tender(self.request): self.LOGGER.info( "Created tender cancellation complaint {}".format( complaint.id), extra=context_unpack( self.request, {"MESSAGE_ID": "tender_cancellation_complaint_create"}, {"complaint_id": complaint.id}), ) self.request.response.status = 201 self.request.response.headers["Location"] = self.request.route_url( "{}:Tender Cancellation Complaints".format( tender.procurementMethodType), tender_id=tender.id, cancellation_id=self.request.validated["cancellation_id"], complaint_id=complaint["id"], ) return {"data": complaint.serialize("view"), "access": access}
def post(self): """ Creating new submission """ submission_id = generate_id() submission = self.request.validated["submission"] submission.id = submission_id framework = self.request.validated["framework"] submission.submissionType = framework["frameworkType"] submission.mode = framework.get("mode") if self.request.json["data"].get("status") == "draft": submission.status = "draft" access = set_ownership(submission, self.request) self.request.validated["submission"] = submission self.request.validated["submission_src"] = {} if save_submission(self.request): self.LOGGER.info( "Created submission {}".format(submission_id), extra=context_unpack( self.request, {"MESSAGE_ID": "submission_create"}, { "submission_id": submission_id, "submission_mode": submission.mode }, ), ) self.request.response.status = 201 self.request.response.headers["Location"] = self.request.route_url( "{}:Submission".format(submission.submissionType), submission_id=submission_id) return {"data": submission.serialize("view"), "access": access}
def collection_post(self): plan = self.request.validated["plan"] milestone = self.request.validated["milestone"] access = set_ownership(milestone, self.request) plan.milestones.append(milestone) plan.dateModified = milestone.dateModified plan.modified = False if save_plan(self.request): self.LOGGER.info( "Created plan milestone {}".format(milestone.id), extra=context_unpack(self.request, {"MESSAGE_ID": "tender_milestone_post"}, { "milestone_id": milestone.id, "plan_id": plan.id }), ) self.request.response.status = 201 milestone_route = self.request.matched_route.name.replace( "collection_", "") self.request.response.headers[ "Location"] = self.request.current_route_url( _route_name=milestone_route, milestone_id=milestone.id, _query={}) return {"data": milestone.serialize("view"), "access": access}
def collection_post(self): """Post a complaint """ tender = self.context complaint = self.request.validated["complaint"] complaint.date = get_now() if complaint.status == "claim": complaint.dateSubmitted = get_now() else: complaint.status = "draft" complaint.complaintID = "{}.{}{}".format( tender.tenderID, self.server_id, sum([len(i.complaints) for i in tender.awards], len(tender.complaints)) + 1) access = set_ownership(complaint, self.request) tender.complaints.append(complaint) if save_tender(self.request): self.LOGGER.info( "Created tender complaint {}".format(complaint.id), extra=context_unpack(self.request, {"MESSAGE_ID": "tender_complaint_create"}, {"complaint_id": complaint.id}), ) self.request.response.status = 201 self.request.response.headers["Location"] = self.request.route_url( "{}:Tender Complaints".format(tender.procurementMethodType), tender_id=tender.id, complaint_id=complaint.id, ) return { "data": complaint.serialize(tender.status), "access": access }
def collection_post(self): """Post a complaint for award """ tender = self.request.validated['tender'] if tender.status not in ['active.qualification', 'active.awarded']: 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 self.context.complaintPeriod and \ (self.context.complaintPeriod.startDate and self.context.complaintPeriod.startDate > get_now() or self.context.complaintPeriod.endDate and self.context.complaintPeriod.endDate < get_now()): self.request.errors.add('body', 'data', 'Can add complaint only in complaintPeriod') self.request.errors.status = 403 return complaint = self.request.validated['complaint'] complaint.date = get_now() complaint.relatedLot = self.context.lotID if complaint.status == 'claim': complaint.dateSubmitted = get_now() elif complaint.status == 'pending': if not any([i.status == 'active' for i in tender.awards if i.lotID == self.request.validated['award'].lotID]): self.request.errors.add('body', 'data', 'Complaint submission is allowed only after award activation.') self.request.errors.status = 403 return complaint.type = 'complaint' complaint.dateSubmitted = get_now() else: complaint.status = 'draft' 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 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', tender_id=tender.id, award_id=self.request.validated['award_id'], complaint_id=complaint['id']) return { 'data': complaint.serialize("view"), 'access': { 'token': complaint.owner_token } }
def patch(self): agreement = self.request.validated["agreement"] access = set_ownership(agreement, self.request) if save_agreement(self.request): self.LOGGER.info( "Generate Agreement credentials {}".format(agreement.id), extra=context_unpack(self.request, {"MESSAGE_ID": "agreement_patch"}), ) return {"data": agreement.serialize("view"), "access": access}
def post(self): monitor = self.request.validated['monitor'] monitor.id = generate_id() set_ownership(monitor, self.request) self.request.validated['monitor'] = monitor self.request.validated['monitor_src'] = {} if save_monitor(self.request): LOGGER.info('Created monitor {}'.format(monitor.id), extra=context_unpack(self.request, {'MESSAGE_ID': 'monitor_create'}, {'monitor_id': monitor.id})) self.request.response.status = 201 self.request.response.headers['Location'] = self.request.route_url( 'Monitor', monitor_id=monitor.id) return { 'data': monitor.serialize("view"), 'access': { 'token': monitor.owner_token } }
def collection_post(self): """Post a complaint for award """ auction = self.request.validated['auction'] if auction.status not in ['active.qualification', 'active.awarded']: self.request.errors.add('body', 'data', 'Can\'t add complaint in current ({}) auction status'.format(auction.status)) self.request.errors.status = 403 return if any([i.status != 'active' for i in auction.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 self.context.complaintPeriod and \ (self.context.complaintPeriod.startDate and self.context.complaintPeriod.startDate > get_now() or self.context.complaintPeriod.endDate and self.context.complaintPeriod.endDate < get_now()): self.request.errors.add('body', 'data', 'Can add complaint only in complaintPeriod') self.request.errors.status = 403 return complaint = self.request.validated['complaint'] complaint.date = get_now() complaint.relatedLot = self.context.lotID if complaint.status == 'claim': complaint.dateSubmitted = get_now() else: complaint.status = 'draft' complaint.complaintID = '{}.{}{}'.format(auction.auctionID, self.server_id, sum([len(i.complaints) for i in auction.awards], len(auction.complaints)) + 1) set_ownership(complaint, self.request) self.context.complaints.append(complaint) if save_auction(self.request): self.LOGGER.info('Created auction award complaint {}'.format(complaint.id), extra=context_unpack(self.request, {'MESSAGE_ID': 'auction_award_complaint_create'}, {'complaint_id': complaint.id})) self.request.response.status = 201 route = self.request.matched_route.name.replace("collection_", "") self.request.response.headers['Location'] = self.request.current_route_url(_route_name=route, complaint_id=complaint.id, _query={}) return { 'data': complaint.serialize("view"), 'access': { 'token': complaint.owner_token } }
def collection_post(self): """Post a complaint """ tender = self.context if tender.status != 'active.tendering': self.request.errors.add('body', 'data', 'Can\'t add complaint in current ({}) tender status'.format(tender.status)) self.request.errors.status = 403 return complaint = self.request.validated['complaint'] complaint.date = get_now() if complaint.status == 'claim': if get_now() > calculate_business_date(tender.tenderPeriod.endDate, -CLAIM_SUBMIT_TIME, tender): self.request.errors.add('body', 'data', 'Can submit claim not later than {0.days} days before tenderPeriod end'.format(CLAIM_SUBMIT_TIME)) self.request.errors.status = 403 return complaint.dateSubmitted = get_now() elif complaint.status == 'pending': if get_now() > tender.complaintPeriod.endDate: self.request.errors.add('body', 'data', 'Can submit complaint not later than {0.days} days before tenderPeriod end'.format(COMPLAINT_SUBMIT_TIME)) self.request.errors.status = 403 return complaint.dateSubmitted = get_now() complaint.type = 'complaint' else: complaint.status = 'draft' complaint.complaintID = '{}.{}{}'.format(tender.tenderID, self.server_id, self.complaints_len(tender) + 1) set_ownership(complaint, self.request) tender.complaints.append(complaint) if save_tender(self.request): self.LOGGER.info('Created tender complaint {}'.format(complaint.id), extra=context_unpack(self.request, {'MESSAGE_ID': 'tender_complaint_create'}, {'complaint_id': complaint.id})) self.request.response.status = 201 self.request.response.headers['Location'] = self.request.route_url('Tender Complaints', tender_id=tender.id, complaint_id=complaint.id) return { 'data': complaint.serialize(tender.status), 'access': { 'token': complaint.owner_token } }
def collection_post(self): """Post a complaint """ tender = self.request.validated["tender"] old_rules = get_first_revision_date(tender) < RELEASE_2020_04_19 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" and complaint.type == "claim": complaint.dateSubmitted = get_now() elif old_rules and 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, calculate_total_complaints(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 post(self): """This API request is targeted to creating new Auctions by procuring organizations. """ auction = self.request.validated['auction'] if auction['_internal_type'] == 'geb': manager = self.request.registry.queryMultiAdapter( (self.request, auction), IManager) applicant = self.request.validated['auction'] auction = manager.create(applicant) if not auction: return else: self.request.registry.getAdapter( auction, IAuctionManager).create_auction(self.request) auction_id = generate_id() auction.id = auction_id auction.auctionID = generate_auction_id(get_now(), self.db, self.server_id) if hasattr(auction, "initialize"): auction.initialize() status = self.request.json_body['data'].get('status') if status and status in ['draft', 'pending.verification']: auction.status = status acc = set_ownership(auction, self.request) self.request.validated['auction'] = auction self.request.validated['auction_src'] = {} if save_auction(self.request): self.LOGGER.info( 'Created auction {} ({})'.format(auction['id'], auction.auctionID), extra=context_unpack(self.request, {'MESSAGE_ID': 'auction_create'}, { 'auction_id': auction['id'], 'auctionID': auction.auctionID })) self.request.response.status = 201 auction_route_name = get_auction_route_name(self.request, auction) self.request.response.headers['Location'] = self.request.route_url( route_name=auction_route_name, auction_id=auction['id']) return {'data': auction.serialize(auction.status), 'access': acc}
def post(self): agreement = self.request.validated["agreement"] if not agreement.id: agreement_id = generate_id() agreement.id = agreement_id if not agreement.get("agreementID"): agreement.prettyID = generate_agreementID(get_now(), self.db, self.server_id) # Unify when cfa moved from tenders to frameworks framework = self.request.validated.get("framework") if framework: agreement.submissionType = framework["frameworkType"] agreement.mode = framework.get("mode") upload_objects_documents( self.request, agreement, route_kwargs={"agreement_id": agreement.id}, route_prefix=framework["frameworkType"]) access = set_ownership(agreement, self.request) self.request.validated["agreement"] = agreement self.request.validated["agreement_src"] = {} if save_agreement(self.request): self.LOGGER.info( "Created agreement {} ({})".format(agreement.id, agreement.agreementID), extra=context_unpack( self.request, {"MESSAGE_ID": "agreement_create"}, { "agreement_id": agreement.id, "agreementID": agreement.agreementID }, ), ) self.request.response.status = 201 self.request.response.headers["Location"] = self.request.route_url( "{}.Agreement".format(agreement.agreementType), agreement_id=agreement.id) return {"data": agreement.serialize("view"), "access": access}
def post(self): agreement = self.request.validated["agreement"] access = set_ownership(agreement, self.request) self.request.validated["agreement"] = agreement self.request.validated["agreement_src"] = {} if save_agreement(self.request): self.LOGGER.info( "Created agreement {} ({})".format(agreement.id, agreement.agreementID), extra=context_unpack( self.request, {"MESSAGE_ID": "agreement_create"}, { "agreement_id": agreement.id, "agreementID": agreement.agreementID }, ), ) self.request.response.status = 201 self.request.response.headers["Location"] = self.request.route_url( "{}.Agreement".format(agreement.agreementType), agreement_id=agreement.id) return {"data": agreement.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": # claim self.validate_posting_claim() complaint.dateSubmitted = get_now() elif complaint.status == "pending": # complaint self.validate_posting_complaint() complaint.type = "complaint" complaint.dateSubmitted = get_now() else: # draft is neither claim nor complaint yet 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}
def post(self): """This API request is targeted to creating new Frameworks by procuring organizations. Creating new Framework ------------------- Example request to create framework: .. sourcecode:: http POST /frameworks HTTP/1.1 Host: example.com Accept: application/json { "data": { "description": "Назва предмета закупівлі", "classification": { "scheme": "ДК021", "description": "Mustard seeds", "id": "03111600-8" }, "title": "Узагальнена назва закупівлі", "qualificationPeriod": { "endDate": "2021-02-07T14:33:22.129267+02:00" }, "additionalClassifications": [ { "scheme": "ДК003", "id": "17.21.1", "description": "папір і картон гофровані, паперова й картонна тара" } ], "procuringEntity": { "contactPoint": { "telephone": "0440000000", "email": "*****@*****.**", "name": "Назва організації(ЦЗО)" }, "identifier": { "scheme": "UA-EDR", "id": "40996564", "legalName": "Назва організації(ЦЗО)" }, "kind": "central", "name": "Повна назва юридичної організації.", "address": { "countryName": "Україна", "postalCode": "01220", "region": "м. Київ", "streetAddress": "вул. Банкова, 11, корпус 1", "locality": "м. Київ" } } } } This is what one should expect in response: .. sourcecode:: http HTTP/1.1 201 Created Location: http://localhost/api/0.1/frameworks/40b48e4878534db1bf228d5928f8f1d9 Content-Type: application/json { "data": { "status": "draft", "description": "Назва предмета закупівлі", "classification": { "scheme": "ДК021", "description": "Mustard seeds", "id": "03111600-8" }, "prettyID": "UA-F-2020-09-08-000001", "qualificationPeriod": { "endDate": "2021-02-07T14:33:22.129267+02:00" }, "frameworkType": "electronicCatalogue", "dateModified": "2020-09-08T01:00:00+03:00", "date": "2020-09-08T01:00:00+03:00", "additionalClassifications": [ { "scheme": "ДК003", "id": "17.21.1", "description": "папір і картон гофровані, паперова й картонна тара" } ], "procuringEntity": { "contactPoint": { "email": "*****@*****.**", "telephone": "0440000000", "name": "Назва організації(ЦЗО)" }, "identifier": { "scheme": "UA-EDR", "id": "40996564", "legalName": "Назва організації(ЦЗО)" }, "name": "Повна назва юридичної організації.", "kind": "central", "address": { "countryName": "Україна", "postalCode": "01220", "streetAddress": "вул. Банкова, 11, корпус 1", "region": "м. Київ", "locality": "м. Київ" } }, "owner": "broker", "title": "Узагальнена назва закупівлі", "id": "40b48e4878534db1bf228d5928f8f1d9" } } """ framework_id = generate_id() framework = self.request.validated["framework"] framework.id = framework_id if not framework.get("prettyID"): framework.prettyID = generate_framework_pretty_id( get_now(), self.db, self.server_id) access = set_ownership(framework, self.request) self.request.validated["framework"] = framework self.request.validated["framework_src"] = {} if save_framework(self.request): self.LOGGER.info( "Created framework {} ({})".format(framework_id, framework.prettyID), extra=context_unpack( self.request, {"MESSAGE_ID": "framework_create"}, { "framework_id": framework_id, "prettyID": framework.prettyID, "framework_mode": framework.mode }, ), ) self.request.response.status = 201 self.request.response.headers["Location"] = self.request.route_url( "{}:Framework".format(framework.frameworkType), framework_id=framework_id) return { "data": framework.serialize(framework.status), "access": access }
def collection_post(self): """This API request is targeted to creating new Plan by procuring organizations. Creating new Plan ------------------- Example request to create plan: .. sourcecode:: http POST /plans HTTP/1.1 Host: example.com Accept: application/json { "data": { "tender": { "procurementMethod": "допорогові закупівлі", "tenderPeriod": { "startDate": "2015-05-09T23:11:39.720908+03:00" } }, "items": [ { "deliveryDate": { "endDate": "2015-05-11T23:11:39.721063+03:00" }, "additionalClassifications": [ { "scheme": "ДКПП", "id": "28.29.39-10.00", "description": "Прилади контролювання маси та прилади контрольні автоматичні з максимальною масою зважування не більше ніж 5000 кг" } ], "unit": { "code": "KGM", "name": "кг" }, "classification": { "scheme": "CPV", "description": "Роботи з будування пневматичних будівель", "id": "45217000-1" }, "quantity": 760 } ], "procuringEntity": { "identifier": { "scheme": "UA-EDR", "id": "111983", "legalName": "ДП Державне Уравління Справами" }, "name": "ДУС" }, "budget": { "project": { "name": "proj_name", "id": "proj_id" }, "amount": 10000, "amountNet": 12222, "id": "budget_id", "description": "budget_description" } } } This is what one should expect in response: .. sourcecode:: http HTTP/1.1 201 Created Location: http://localhost/api/0.10/plans/84582807b5654bee9e216adb05e57d39 Content-Type: application/json { "access": { "token": "174fd98e4e7347eb863f125c9e561b27" }, "data": { "tender": { "procurementMethod": "допорогові закупівлі", "tenderPeriod": { "startDate": "2015-05-09T23:11:39.720908+03:00" } }, "items": [ { "classification": { "scheme": "CPV", "description": "Роботи з будування пневматичних будівель", "id": "45217000-1" }, "additionalClassifications": [ { "scheme": "ДКПП", "id": "28.29.39-10.00", "description": "Прилади контролювання маси та прилади контрольні автоматичні з максимальною масою зважування не більше ніж 5000 кг" } ], "deliveryDate": { "endDate": "2015-05-11T23:11:39.721063+03:00" }, "id": "84582807b5654bee9e216adb05e57d39", "unit": { "code": "KGM", "name": "кг" }, "quantity": 760 } ], "procuringEntity": { "identifier": { "scheme": "UA-EDR", "id": "111983", "legalName": "ДП Державне Уравління Справами" }, "name": "ДУС" }, "budget": { "project": { "id": "proj_id", "name": "proj_name" }, "amount": 10000, "amountNet": 12222, "id": "budget_id", "description": "budget_description" } } } """ plan_data = self.request.validated['data'] plan_id = generate_id() plan = Plan(plan_data) plan.__parent__ = self.request.context plan.id = plan_id plan.planID = generate_plan_id(get_now(), self.db_plan, self.server_id) set_ownership(plan, self.request) self.request.validated['plan'] = plan self.request.validated['plan_src'] = {} if save_plan(self.request): LOGGER.info('Created plan {} ({})'.format(plan_id, plan.planID), extra=context_unpack(self.request, {'MESSAGE_ID': 'plan_create'}, { 'plan_id': plan_id, 'planID': plan.planID })) self.request.response.status = 201 self.request.response.headers['Location'] = self.request.route_url( 'Plan', plan_id=plan_id) return { 'data': plan.serialize('create'), 'access': { 'token': plan.owner_token } }
def collection_post(self): """Registration of new bid proposal Creating new Bid proposal ------------------------- Example request to create bid proposal: .. sourcecode:: http POST /auctions/4879d3f8ee2443169b5fbbc9f89fa607/bids HTTP/1.1 Host: example.com Accept: application/json { "data": { "tenderers": [ { "id": { "name": "Державне управління справами", "scheme": "https://ns.openprocurement.org/ua/edrpou", "uid": "00037256", "uri": "http://www.dus.gov.ua/" }, "address": { "countryName": "Україна", "postalCode": "01220", "region": "м. Київ", "locality": "м. Київ", "streetAddress": "вул. Банкова, 11, корпус 1" } } ], "value": { "amount": 489, "currency": "UAH", "valueAddedTaxIncluded": true } } } This is what one should expect in response: .. sourcecode:: http HTTP/1.1 201 Created Content-Type: application/json { "data": { "id": "4879d3f8ee2443169b5fbbc9f89fa607", "status": "registration", "date": "2014-10-28T11:44:17.947Z", "tenderers": [ { "id": { "name": "Державне управління справами", "scheme": "https://ns.openprocurement.org/ua/edrpou", "uid": "00037256", "uri": "http://www.dus.gov.ua/" }, "address": { "countryName": "Україна", "postalCode": "01220", "region": "м. Київ", "locality": "м. Київ", "streetAddress": "вул. Банкова, 11, корпус 1" } } ], "value": { "amount": 489, "currency": "UAH", "valueAddedTaxIncluded": true } } } """ # See https://github.com/open-contracting/standard/issues/78#issuecomment-59830415 # for more info upon schema auction = self.request.validated['auction'] if self.request.validated[ 'auction_status'] not in TENDER_PERIOD_STATUSES: self.request.errors.add( 'body', 'data', 'Can\'t add bid in current ({}) auction status'.format( self.request.validated['auction_status'])) self.request.errors.status = 403 return if auction.tenderPeriod.startDate and get_now( ) < auction.tenderPeriod.startDate or get_now( ) > auction.tenderPeriod.endDate: self.request.errors.add( 'body', 'data', 'Bid can be added only during the tendering period: from ({}) to ({}).' .format( auction.tenderPeriod.startDate and auction.tenderPeriod.startDate.isoformat(), auction.tenderPeriod.endDate.isoformat())) self.request.errors.status = 403 return bid = self.request.validated['bid'] set_ownership(bid, self.request) auction.bids.append(bid) auction.modified = False if save_auction(self.request): self.LOGGER.info( 'Created auction bid {}'.format(bid.id), extra=context_unpack(self.request, {'MESSAGE_ID': 'auction_bid_create'}, {'bid_id': bid.id})) self.request.response.status = 201 route = self.request.matched_route.name.replace("collection_", "") self.request.response.headers[ 'Location'] = self.request.current_route_url(_route_name=route, bid_id=bid.id, _query={}) return { 'data': bid.serialize('view'), 'access': { 'token': bid.owner_token } }
def collection_post(self): """This API request is targeted to creating new Tenders by procuring organizations. Creating new Tender ------------------- Example request to create tender: .. sourcecode:: http POST /tenders HTTP/1.1 Host: example.com Accept: application/json { "data": { "procuringEntity": { "id": { "name": "Державне управління справами", "scheme": "https://ns.openprocurement.org/ua/edrpou", "uid": "00037256", "uri": "http://www.dus.gov.ua/" }, "address": { "countryName": "Україна", "postalCode": "01220", "region": "м. Київ", "locality": "м. Київ", "streetAddress": "вул. Банкова, 11, корпус 1" } }, "value": { "amount": 500, "currency": "UAH", "valueAddedTaxIncluded": true }, "itemsToBeProcured": [ { "description": "футляри до державних нагород", "primaryClassification": { "scheme": "CPV", "id": "44617100-9", "description": "Cartons" }, "additionalClassification": [ { "scheme": "ДКПП", "id": "17.21.1", "description": "папір і картон гофровані, паперова й картонна тара" } ], "unitOfMeasure": "item", "quantity": 5 } ], "enquiryPeriod": { "endDate": "2014-10-31T00:00:00" }, "tenderPeriod": { "startDate": "2014-11-03T00:00:00", "endDate": "2014-11-06T10:00:00" }, "awardPeriod": { "endDate": "2014-11-13T00:00:00" }, "deliveryDate": { "endDate": "2014-11-20T00:00:00" }, "minimalStep": { "amount": 35, "currency": "UAH" } } } This is what one should expect in response: .. sourcecode:: http HTTP/1.1 201 Created Location: http://localhost/api/0.1/tenders/64e93250be76435397e8c992ed4214d1 Content-Type: application/json { "data": { "id": "64e93250be76435397e8c992ed4214d1", "tenderID": "UA-64e93250be76435397e8c992ed4214d1", "dateModified": "2014-10-27T08:06:58.158Z", "procuringEntity": { "id": { "name": "Державне управління справами", "scheme": "https://ns.openprocurement.org/ua/edrpou", "uid": "00037256", "uri": "http://www.dus.gov.ua/" }, "address": { "countryName": "Україна", "postalCode": "01220", "region": "м. Київ", "locality": "м. Київ", "streetAddress": "вул. Банкова, 11, корпус 1" } }, "value": { "amount": 500, "currency": "UAH", "valueAddedTaxIncluded": true }, "itemsToBeProcured": [ { "description": "футляри до державних нагород", "primaryClassification": { "scheme": "CPV", "id": "44617100-9", "description": "Cartons" }, "additionalClassification": [ { "scheme": "ДКПП", "id": "17.21.1", "description": "папір і картон гофровані, паперова й картонна тара" } ], "unitOfMeasure": "item", "quantity": 5 } ], "enquiryPeriod": { "endDate": "2014-10-31T00:00:00" }, "tenderPeriod": { "startDate": "2014-11-03T00:00:00", "endDate": "2014-11-06T10:00:00" }, "awardPeriod": { "endDate": "2014-11-13T00:00:00" }, "deliveryDate": { "endDate": "2014-11-20T00:00:00" }, "minimalStep": { "amount": 35, "currency": "UAH" } } } """ tender_data = self.request.validated['data'] tender_id = generate_id() tender = Tender(tender_data) tender.id = tender_id tender.enquiryPeriod.startDate = get_now() tender.tenderID = generate_tender_id(tender.enquiryPeriod.startDate, self.db) if not tender.tenderPeriod.startDate: tender.tenderPeriod.startDate = tender.enquiryPeriod.endDate set_ownership(tender, self.request) self.request.validated['tender'] = tender self.request.validated['tender_src'] = {} save_tender(self.request) self.request.response.status = 201 self.request.response.headers[ 'Location'] = self.request.route_url('Tender', tender_id=tender_id) return { 'data': tender.serialize(tender.status), 'access': { 'token': tender.owner_token } }
def collection_post(self): """Registration of new bid proposal Creating new Bid proposal ------------------------- Example request to create bid proposal: .. sourcecode:: http POST /tenders/4879d3f8ee2443169b5fbbc9f89fa607/bids HTTP/1.1 Host: example.com Accept: application/json { "data": { "tenderers": [ { "id": { "name": "Державне управління справами", "scheme": "https://ns.openprocurement.org/ua/edrpou", "uid": "00037256", "uri": "http://www.dus.gov.ua/" }, "address": { "countryName": "Україна", "postalCode": "01220", "region": "м. Київ", "locality": "м. Київ", "streetAddress": "вул. Банкова, 11, корпус 1" } } ], "value": { "amount": 489, "currency": "UAH", "valueAddedTaxIncluded": true } } } This is what one should expect in response: .. sourcecode:: http HTTP/1.1 201 Created Content-Type: application/json { "data": { "id": "4879d3f8ee2443169b5fbbc9f89fa607", "status": "registration", "date": "2014-10-28T11:44:17.947Z", "tenderers": [ { "id": { "name": "Державне управління справами", "scheme": "https://ns.openprocurement.org/ua/edrpou", "uid": "00037256", "uri": "http://www.dus.gov.ua/" }, "address": { "countryName": "Україна", "postalCode": "01220", "region": "м. Київ", "locality": "м. Київ", "streetAddress": "вул. Банкова, 11, корпус 1" } } ], "value": { "amount": 489, "currency": "UAH", "valueAddedTaxIncluded": true } } } """ # See https://github.com/open-contracting/standard/issues/78#issuecomment-59830415 # for more info upon schema tender = self.request.validated["tender"] bid = self.request.validated["bid"] access = set_ownership(bid, self.request) tender.bids.append(bid) tender.modified = False if save_tender(self.request): self.LOGGER.info( "Created tender bid {}".format(bid.id), extra=context_unpack(self.request, {"MESSAGE_ID": "tender_bid_create"}, {"bid_id": bid.id}), ) self.request.response.status = 201 self.request.response.headers["Location"] = self.request.route_url( "{}:Tender Bids".format(tender.procurementMethodType), tender_id=tender.id, bid_id=bid["id"]) return {"data": bid.serialize("view"), "access": access}
def collection_post(self): """This API request is targeted to creating new Plan by procuring organizations. Creating new Plan ------------------- Example request to create plan: .. sourcecode:: http POST /plans HTTP/1.1 Host: example.com Accept: application/json { "data": { "tender": { "procurementMethod": "допорогові закупівлі", "tenderPeriod": { "startDate": "2015-05-09T23:11:39.720908+03:00" } }, "items": [ { "deliveryDate": { "endDate": "2015-05-11T23:11:39.721063+03:00" }, "additionalClassifications": [ { "scheme": "ДКПП", "id": "28.29.39-10.00", "description": "Прилади контролювання маси та прилади контрольні автоматичні з максимальною масою зважування не більше ніж 5000 кг" } ], "unit": { "code": "KGM", "name": "кг" }, "classification": { "scheme": "CPV", "description": "Роботи з будування пневматичних будівель", "id": "45217000-1" }, "quantity": 760 } ], "procuringEntity": { "identifier": { "scheme": "UA-EDR", "id": "111983", "legalName": "ДП Державне Уравління Справами" }, "name": "ДУС" }, "budget": { "project": { "name": "proj_name", "id": "proj_id" }, "amount": 10000, "amountNet": 12222, "id": "budget_id", "description": "budget_description" } } } This is what one should expect in response: .. sourcecode:: http HTTP/1.1 201 Created Location: http://localhost/api/0.10/plans/84582807b5654bee9e216adb05e57d39 Content-Type: application/json { "access": { "token": "174fd98e4e7347eb863f125c9e561b27" }, "data": { "tender": { "procurementMethod": "допорогові закупівлі", "tenderPeriod": { "startDate": "2015-05-09T23:11:39.720908+03:00" } }, "items": [ { "classification": { "scheme": "CPV", "description": "Роботи з будування пневматичних будівель", "id": "45217000-1" }, "additionalClassifications": [ { "scheme": "ДКПП", "id": "28.29.39-10.00", "description": "Прилади контролювання маси та прилади контрольні автоматичні з максимальною масою зважування не більше ніж 5000 кг" } ], "deliveryDate": { "endDate": "2015-05-11T23:11:39.721063+03:00" }, "id": "84582807b5654bee9e216adb05e57d39", "unit": { "code": "KGM", "name": "кг" }, "quantity": 760 } ], "procuringEntity": { "identifier": { "scheme": "UA-EDR", "id": "111983", "legalName": "ДП Державне Уравління Справами" }, "name": "ДУС" }, "budget": { "project": { "id": "proj_id", "name": "proj_name" }, "amount": 10000, "amountNet": 12222, "id": "budget_id", "description": "budget_description" } } } """ plan_data = self.request.validated['data'] plan_id = generate_id() plan = Plan(plan_data) plan.__parent__ = self.request.context plan.id = plan_id plan.planID = generate_plan_id(get_now(), self.db_plan, self.server_id) set_ownership(plan, self.request) self.request.validated['plan'] = plan self.request.validated['plan_src'] = {} if save_plan(self.request): LOGGER.info('Created plan {} ({})'.format(plan_id, plan.planID), extra=context_unpack(self.request, {'MESSAGE_ID': 'plan_create'}, {'plan_id': plan_id, 'planID': plan.planID})) self.request.response.status = 201 self.request.response.headers[ 'Location'] = self.request.route_url('Plan', plan_id=plan_id) return { 'data': plan.serialize('create'), 'access': { 'token': plan.owner_token } }
def collection_post(self): """Registration of new bid proposal Creating new Bid proposal ------------------------- Example request to create bid proposal: .. sourcecode:: http POST /auctions/4879d3f8ee2443169b5fbbc9f89fa607/bids HTTP/1.1 Host: example.com Accept: application/json { "data": { "tenderers": [ { "id": { "name": "Державне управління справами", "scheme": "https://ns.openprocurement.org/ua/edrpou", "uid": "00037256", "uri": "http://www.dus.gov.ua/" }, "address": { "countryName": "Україна", "postalCode": "01220", "region": "м. Київ", "locality": "м. Київ", "streetAddress": "вул. Банкова, 11, корпус 1" } } ], "value": { "amount": 489, "currency": "UAH", "valueAddedTaxIncluded": true } } } This is what one should expect in response: .. sourcecode:: http HTTP/1.1 201 Created Content-Type: application/json { "data": { "id": "4879d3f8ee2443169b5fbbc9f89fa607", "status": "registration", "date": "2014-10-28T11:44:17.947Z", "tenderers": [ { "id": { "name": "Державне управління справами", "scheme": "https://ns.openprocurement.org/ua/edrpou", "uid": "00037256", "uri": "http://www.dus.gov.ua/" }, "address": { "countryName": "Україна", "postalCode": "01220", "region": "м. Київ", "locality": "м. Київ", "streetAddress": "вул. Банкова, 11, корпус 1" } } ], "value": { "amount": 489, "currency": "UAH", "valueAddedTaxIncluded": true } } } """ # See https://github.com/open-contracting/standard/issues/78#issuecomment-59830415 # for more info upon schema auction = self.request.validated['auction'] if self.request.validated['auction_status'] != 'active.tendering': self.request.errors.add('body', 'data', 'Can\'t add bid in current ({}) auction status'.format(self.request.validated['auction_status'])) self.request.errors.status = 403 return if auction.tenderPeriod.startDate and get_now() < auction.tenderPeriod.startDate or get_now() > auction.tenderPeriod.endDate: self.request.errors.add('body', 'data', 'Bid can be added only during the tendering period: from ({}) to ({}).'.format(auction.tenderPeriod.startDate and auction.tenderPeriod.startDate.isoformat(), auction.tenderPeriod.endDate.isoformat())) self.request.errors.status = 403 return bid = self.request.validated['bid'] set_ownership(bid, self.request) auction.bids.append(bid) auction.modified = False if save_auction(self.request): self.LOGGER.info('Created auction bid {}'.format(bid.id), extra=context_unpack(self.request, {'MESSAGE_ID': 'auction_bid_create'}, {'bid_id': bid.id})) self.request.response.status = 201 self.request.response.headers['Location'] = self.request.route_url('Auction Bids', auction_id=auction.id, bid_id=bid['id']) return { 'data': bid.serialize('view'), 'access': { 'token': bid.owner_token } }
def collection_post(self): """Registration of new bid proposal Creating new Bid proposal ------------------------- Example request to create bid proposal: .. sourcecode:: http POST /tenders/4879d3f8ee2443169b5fbbc9f89fa607/bids HTTP/1.1 Host: example.com Accept: application/json { "data": { "tenderers": [ { "id": { "name": "Державне управління справами", "scheme": "https://ns.openprocurement.org/ua/edrpou", "uid": "00037256", "uri": "http://www.dus.gov.ua/" }, "address": { "countryName": "Україна", "postalCode": "01220", "region": "м. Київ", "locality": "м. Київ", "streetAddress": "вул. Банкова, 11, корпус 1" } } ], "value": { "amount": 489, "currency": "UAH", "valueAddedTaxIncluded": true } } } This is what one should expect in response: .. sourcecode:: http HTTP/1.1 201 Created Content-Type: application/json { "data": { "id": "4879d3f8ee2443169b5fbbc9f89fa607", "status": "registration", "date": "2014-10-28T11:44:17.947Z", "tenderers": [ { "id": { "name": "Державне управління справами", "scheme": "https://ns.openprocurement.org/ua/edrpou", "uid": "00037256", "uri": "http://www.dus.gov.ua/" }, "address": { "countryName": "Україна", "postalCode": "01220", "region": "м. Київ", "locality": "м. Київ", "streetAddress": "вул. Банкова, 11, корпус 1" } }aaaabid ], "value": { "amount": 489, "currency": "UAH", "valueAddedTaxIncluded": true } } } """ # See https://github.com/open-contracting/standard/issues/78#issuecomment-59830415 # for more info upon schema tender = self.request.validated["tender"] if self.request.validated["tender_status"] != "active.tendering": self.request.errors.add( "body", "data", "Can't add bid in current ({}) tender status".format(self.request.validated["tender_status"]), ) self.request.errors.status = 403 return if ( tender.tenderPeriod.startDate and get_now() < tender.tenderPeriod.startDate or get_now() > tender.tenderPeriod.endDate ): self.request.errors.add( "body", "data", "Bid can be added only during the tendering period: from ({}) to ({}).".format( tender.tenderPeriod.startDate, tender.tenderPeriod.endDate ), ) self.request.errors.status = 403 return bid = self.request.validated["bid"] if bid.status not in self.allowed_bid_status_on_create: self.request.errors.add( "body", "data", "Bid can be added only with status: {}.".format(self.allowed_bid_status_on_create) ) self.request.errors.status = 403 return tender.modified = False set_ownership(bid, self.request) tender.bids.append(bid) if save_tender(self.request): self.LOGGER.info( "Created tender bid {}".format(bid.id), extra=context_unpack(self.request, {"MESSAGE_ID": "tender_bid_create"}, {"bid_id": bid.id}), ) self.request.response.status = 201 self.request.response.headers["Location"] = self.request.route_url( "Tender Bids", tender_id=tender.id, bid_id=bid["id"] ) return {"data": bid.serialize("view"), "access": {"token": bid.owner_token}}
def post(self): """This API request is targeted to creating new Tenders by procuring organizations. Creating new Tender ------------------- Example request to create tender: .. sourcecode:: http POST /tenders HTTP/1.1 Host: example.com Accept: application/json { "data": { "procuringEntity": { "id": { "name": "Державне управління справами", "scheme": "https://ns.openprocurement.org/ua/edrpou", "uid": "00037256", "uri": "http://www.dus.gov.ua/" }, "address": { "countryName": "Україна", "postalCode": "01220", "region": "м. Київ", "locality": "м. Київ", "streetAddress": "вул. Банкова, 11, корпус 1" } }, "value": { "amount": 500, "currency": "UAH", "valueAddedTaxIncluded": true }, "itemsToBeProcured": [ { "description": "футляри до державних нагород", "primaryClassification": { "scheme": "CPV", "id": "44617100-9", "description": "Cartons" }, "additionalClassification": [ { "scheme": "ДКПП", "id": "17.21.1", "description": "папір і картон гофровані, паперова й картонна тара" } ], "unitOfMeasure": "item", "quantity": 5 } ], "enquiryPeriod": { "endDate": "2014-10-31T00:00:00" }, "tenderPeriod": { "startDate": "2014-11-03T00:00:00", "endDate": "2014-11-06T10:00:00" }, "awardPeriod": { "endDate": "2014-11-13T00:00:00" }, "deliveryDate": { "endDate": "2014-11-20T00:00:00" }, "minimalStep": { "amount": 35, "currency": "UAH" } } } This is what one should expect in response: .. sourcecode:: http HTTP/1.1 201 Created Location: http://localhost/api/0.1/tenders/64e93250be76435397e8c992ed4214d1 Content-Type: application/json { "data": { "id": "64e93250be76435397e8c992ed4214d1", "tenderID": "UA-64e93250be76435397e8c992ed4214d1", "dateModified": "2014-10-27T08:06:58.158Z", "procuringEntity": { "id": { "name": "Державне управління справами", "scheme": "https://ns.openprocurement.org/ua/edrpou", "uid": "00037256", "uri": "http://www.dus.gov.ua/" }, "address": { "countryName": "Україна", "postalCode": "01220", "region": "м. Київ", "locality": "м. Київ", "streetAddress": "вул. Банкова, 11, корпус 1" } }, "value": { "amount": 500, "currency": "UAH", "valueAddedTaxIncluded": true }, "itemsToBeProcured": [ { "description": "футляри до державних нагород", "primaryClassification": { "scheme": "CPV", "id": "44617100-9", "description": "Cartons" }, "additionalClassification": [ { "scheme": "ДКПП", "id": "17.21.1", "description": "папір і картон гофровані, паперова й картонна тара" } ], "unitOfMeasure": "item", "quantity": 5 } ], "enquiryPeriod": { "endDate": "2014-10-31T00:00:00" }, "tenderPeriod": { "startDate": "2014-11-03T00:00:00", "endDate": "2014-11-06T10:00:00" }, "awardPeriod": { "endDate": "2014-11-13T00:00:00" }, "deliveryDate": { "endDate": "2014-11-20T00:00:00" }, "minimalStep": { "amount": 35, "currency": "UAH" } } } """ tender_id = generate_id() tender = self.request.validated['tender'] tender.id = tender_id tender.tenderID = generate_tender_id(get_now(), self.db, self.server_id) if hasattr(tender, "initialize"): tender.initialize() set_ownership(tender, self.request) self.request.validated['tender'] = tender self.request.validated['tender_src'] = {} if save_tender(self.request): self.LOGGER.info( 'Created tender {} ({})'.format(tender_id, tender.tenderID), extra=context_unpack(self.request, {'MESSAGE_ID': 'tender_create'}, { 'tender_id': tender_id, 'tenderID': tender.tenderID })) self.request.response.status = 201 self.request.response.headers['Location'] = self.request.route_url( 'Tender', tender_id=tender_id) return { 'data': tender.serialize(tender.status), 'access': { 'token': tender.owner_token } }
def post(self): """This API request is targeted to creating new Plan by procuring organizations. Creating new Plan ------------------- Example request to create plan: .. sourcecode:: http POST /plans HTTP/1.1 Host: example.com Accept: application/json { "data": { "tender": { "procurementMethod": "допорогові закупівлі", "tenderPeriod": { "startDate": "2015-05-09T23:11:39.720908+03:00" } }, "items": [ { "deliveryDate": { "endDate": "2015-05-11T23:11:39.721063+03:00" }, "additionalClassifications": [ { "scheme": "ДКПП", "id": "28.29.39-10.00", "description": "Прилади контролювання маси та прилади контрольні автоматичні з максимальною масою зважування не більше ніж 5000 кг" } ], "unit": { "code": "KGM", "name": "кг" }, "classification": { "scheme": "CPV", "description": "Роботи з будування пневматичних будівель", "id": "45217000-1" }, "quantity": 760 } ], "procuringEntity": { "identifier": { "scheme": "UA-EDR", "id": "111983", "legalName": "ДП Державне Уравління Справами" }, "name": "ДУС" }, "budget": { "project": { "name": "proj_name", "id": "proj_id" }, "amount": 10000, "amountNet": 12222, "id": "budget_id", "description": "budget_description" } } } This is what one should expect in response: .. sourcecode:: http HTTP/1.1 201 Created Location: http://localhost/api/0.10/plans/84582807b5654bee9e216adb05e57d39 Content-Type: application/json { "access": { "token": "e4c75de4320649a4bbbdfa180e7a9ef2" }, "data": { "items": [ { "classification": { "scheme": "CPV", "description": "Роботи з будування пневматичних будівель", "id": "45217000-1" }, "additionalClassifications": [ { "scheme": "ДКПП", "id": "28.29.39-10.00", "description": "Прилади контролювання маси та прилади контрольні" }, { "scheme": "КЕКВ", "id": "123", "description": "-" } ], "deliveryDate": { "endDate": "2015-05-11T23:11:39.721063+03:00" }, "id": "8cd4abfd0bbb489a83a81dec1393ab8d", "unit": { "code": "KGM", "name": "кг" }, "quantity": 760 } ], "planID": "UA-2015-11-26-000001", "budget": { "amountNet": 12222, "description": "budget_description", "project": { "id": "proj_id", "name": "proj_name" }, "currency": "UAH", "amount": 10000, "id": "budget_id" }, "procuringEntity": { "identifier": { "scheme": "UA-EDR", "id": "111983", "legalName": "ДП Державне Уравління Справами" }, "name": "ДУС" }, "tender": { "procurementMethod": "open", "tenderPeriod": { "startDate": "2015-05-09T23:11:39.720908+03:00" } }, "id": "ac658c4ff7ab47dea27e32d15a655ddb" } } """ plan_id = generate_id() plan = self.request.validated["plan"] plan.id = plan_id plan.planID = generate_plan_id(get_now(), self.db, self.server_id) access = set_ownership(plan, self.request) self.request.validated["plan"] = plan self.request.validated["plan_src"] = {} if save_plan(self.request): LOGGER.info( "Created plan {} ({})".format(plan_id, plan.planID), extra=context_unpack(self.request, {"MESSAGE_ID": "plan_create"}, { "plan_id": plan_id, "planID": plan.planID }), ) self.request.response.status = 201 self.request.response.headers["Location"] = self.request.route_url( "Plan", plan_id=plan_id) return {"data": plan.serialize("view"), "access": access}
def collection_post(self): """Registration of new bid proposal Creating new Bid proposal ------------------------- Example request to create bid proposal: .. sourcecode:: http POST /tenders/4879d3f8ee2443169b5fbbc9f89fa607/bids HTTP/1.1 Host: example.com Accept: application/json { "data": { "tenderers": [ { "id": { "name": "Державне управління справами", "scheme": "https://ns.openprocurement.org/ua/edrpou", "uid": "00037256", "uri": "http://www.dus.gov.ua/" }, "address": { "countryName": "Україна", "postalCode": "01220", "region": "м. Київ", "locality": "м. Київ", "streetAddress": "вул. Банкова, 11, корпус 1" } } ], "value": { "amount": 489, "currency": "UAH", "valueAddedTaxIncluded": true } } } This is what one should expect in response: .. sourcecode:: http HTTP/1.1 201 Created Content-Type: application/json { "data": { "id": "4879d3f8ee2443169b5fbbc9f89fa607", "status": "registration", "date": "2014-10-28T11:44:17.947Z", "tenderers": [ { "id": { "name": "Державне управління справами", "scheme": "https://ns.openprocurement.org/ua/edrpou", "uid": "00037256", "uri": "http://www.dus.gov.ua/" }, "address": { "countryName": "Україна", "postalCode": "01220", "region": "м. Київ", "locality": "м. Київ", "streetAddress": "вул. Банкова, 11, корпус 1" } } ], "value": { "amount": 489, "currency": "UAH", "valueAddedTaxIncluded": true } } } """ # See https://github.com/open-contracting/standard/issues/78#issuecomment-59830415 # for more info upon schema tender = self.request.validated['tender'] if self.request.validated[ 'tender_status'] != 'active.tendering' or tender.tenderPeriod.startDate and get_now( ) < tender.tenderPeriod.startDate or get_now( ) > tender.tenderPeriod.endDate: self.request.errors.add( 'body', 'data', 'Can\'t add bid in current ({}) tender status'.format( self.request.validated['tender_status'])) self.request.errors.status = 403 return bid = self.request.validated['bid'] set_ownership(bid, self.request) tender.bids.append(bid) if save_tender(self.request): LOGGER.info('Created tender bid {}'.format(bid.id), extra=context_unpack( self.request, {'MESSAGE_ID': 'tender_bid_create'}, {'bid_id': bid.id})) self.request.response.status = 201 self.request.response.headers['Location'] = self.request.route_url( 'Tender Bids', tender_id=tender.id, bid_id=bid['id']) return { 'data': bid.serialize('view'), 'access': { 'token': bid.owner_token } }
def collection_post(self): """Registration of new bid proposal Creating new Bid proposal ------------------------- Example request to create bid proposal: .. sourcecode:: http POST /tenders/4879d3f8ee2443169b5fbbc9f89fa607/bids HTTP/1.1 Host: example.com Accept: application/json { "data": { "tenderers": [ { "id": { "name": "Державне управління справами", "scheme": "https://ns.openprocurement.org/ua/edrpou", "uid": "00037256", "uri": "http://www.dus.gov.ua/" }, "address": { "countryName": "Україна", "postalCode": "01220", "region": "м. Київ", "locality": "м. Київ", "streetAddress": "вул. Банкова, 11, корпус 1" } } ], "value": { "amount": 489, "currency": "UAH", "valueAddedTaxIncluded": true } } } This is what one should expect in response: .. sourcecode:: http HTTP/1.1 201 Created Content-Type: application/json { "data": { "id": "4879d3f8ee2443169b5fbbc9f89fa607", "status": "registration", "date": "2014-10-28T11:44:17.947Z", "tenderers": [ { "id": { "name": "Державне управління справами", "scheme": "https://ns.openprocurement.org/ua/edrpou", "uid": "00037256", "uri": "http://www.dus.gov.ua/" }, "address": { "countryName": "Україна", "postalCode": "01220", "region": "м. Київ", "locality": "м. Київ", "streetAddress": "вул. Банкова, 11, корпус 1" } } ], "value": { "amount": 489, "currency": "UAH", "valueAddedTaxIncluded": true } } } """ # See https://github.com/open-contracting/standard/issues/78#issuecomment-59830415 # for more info upon schema tender = self.request.validated['tender'] if self.request.validated['tender_status'] != 'active.tendering': self.request.errors.add('body', 'data', 'Can\'t add bid in current ({}) tender status'.format(self.request.validated['tender_status'])) self.request.errors.status = 403 return bid_data = self.request.validated['data'] bid = Bid(bid_data) set_ownership(bid, self.request) tender.bids.append(bid) if save_tender(self.request): update_journal_handler_params({'bid_id': bid.id}) LOGGER.info('Created tender bid {}'.format(bid.id), extra={'MESSAGE_ID': 'tender_bid_create'}) self.request.response.status = 201 self.request.response.headers['Location'] = self.request.route_url('Tender Bids', tender_id=tender.id, bid_id=bid['id']) return { 'data': bid.serialize('view'), 'access': { 'token': bid.owner_token } }
def post(self): """This API request is targeted to creating new Plan by procuring organizations. Creating new Plan ------------------- Example request to create plan: .. sourcecode:: http POST /plans HTTP/1.1 Host: example.com Accept: application/json { "data": { "tender": { "procurementMethod": "допорогові закупівлі", "tenderPeriod": { "startDate": "2015-05-09T23:11:39.720908+03:00" } }, "items": [ { "deliveryDate": { "endDate": "2015-05-11T23:11:39.721063+03:00" }, "additionalClassifications": [ { "scheme": "ДКПП", "id": "28.29.39-10.00", "description": "Прилади контролювання маси та прилади контрольні автоматичні з максимальною масою зважування не більше ніж 5000 кг" } ], "unit": { "code": "KGM", "name": "кг" }, "classification": { "scheme": "CPV", "description": "Роботи з будування пневматичних будівель", "id": "45217000-1" }, "quantity": 760 } ], "procuringEntity": { "identifier": { "scheme": "UA-EDR", "id": "111983", "legalName": "ДП Державне Уравління Справами" }, "name": "ДУС" }, "budget": { "project": { "name": "proj_name", "id": "proj_id" }, "amount": 10000, "amountNet": 12222, "id": "budget_id", "description": "budget_description" } } } This is what one should expect in response: .. sourcecode:: http HTTP/1.1 201 Created Location: http://localhost/api/0.10/plans/84582807b5654bee9e216adb05e57d39 Content-Type: application/json { "access": { "token": "e4c75de4320649a4bbbdfa180e7a9ef2" }, "data": { "items": [ { "classification": { "scheme": "CPV", "description": "Роботи з будування пневматичних будівель", "id": "45217000-1" }, "additionalClassifications": [ { "scheme": "ДКПП", "id": "28.29.39-10.00", "description": "Прилади контролювання маси та прилади контрольні" }, { "scheme": "КЕКВ", "id": "123", "description": "-" } ], "deliveryDate": { "endDate": "2015-05-11T23:11:39.721063+03:00" }, "id": "8cd4abfd0bbb489a83a81dec1393ab8d", "unit": { "code": "KGM", "name": "кг" }, "quantity": 760 } ], "planID": "UA-2015-11-26-000001", "budget": { "amountNet": 12222, "description": "budget_description", "project": { "id": "proj_id", "name": "proj_name" }, "currency": "UAH", "amount": 10000, "id": "budget_id" }, "procuringEntity": { "identifier": { "scheme": "UA-EDR", "id": "111983", "legalName": "ДП Державне Уравління Справами" }, "name": "ДУС" }, "tender": { "procurementMethod": "open", "tenderPeriod": { "startDate": "2015-05-09T23:11:39.720908+03:00" } }, "id": "ac658c4ff7ab47dea27e32d15a655ddb" } } """ plan_id = generate_id() plan = self.request.validated["plan"] plan.id = plan_id plan.planID = generate_plan_id(get_now(), self.db, self.server_id) set_ownership(plan, self.request) self.request.validated["plan"] = plan self.request.validated["plan_src"] = {} if save_plan(self.request): LOGGER.info( "Created plan {} ({})".format(plan_id, plan.planID), extra=context_unpack( self.request, {"MESSAGE_ID": "plan_create"}, {"plan_id": plan_id, "planID": plan.planID} ), ) self.request.response.status = 201 self.request.response.headers["Location"] = self.request.route_url("Plan", plan_id=plan_id) return {"data": plan.serialize("create"), "access": {"token": plan.owner_token}}