Ejemplo n.º 1
0
 def collection_post(self):
     """Tender Bid Document Upload
     """
     tender = self.request.validated['tender']
     if tender.status not in [
             'active.tendering', 'active.auction', 'active.qualification'
     ]:
         self.request.errors.add(
             'body', 'data', 'Can\'t add document in current tender status')
         self.request.errors.status = 403
         return
     src = tender.serialize("plain")
     data = self.request.validated['file']
     document = Document()
     document.id = generate_id()
     document.title = data.filename
     document.format = data.type
     key = generate_id()
     document.url = self.request.route_url(
         'Tender Bid Documents',
         tender_id=tender.id,
         bid_id=self.request.validated['bid_id'],
         id=document.id,
         _query={'download': key})
     self.request.validated['bid'].documents.append(document)
     upload_file(tender, document, key, data.file, self.request)
     save_tender(tender, src, self.request)
     self.request.response.status = 201
     self.request.response.headers['Location'] = self.request.route_url(
         'Tender Bid Documents',
         tender_id=tender.id,
         bid_id=self.request.validated['bid_id'],
         id=document.id)
     return {'data': document.serialize("view")}
 def put(self):
     """Tender Complaint Document Update"""
     tender = self.request.validated['tender']
     if tender.status not in ['active.enquiries', 'active.tendering', 'active.auction', 'active.qualification', 'active.awarded']:
         self.request.errors.add('body', 'data', 'Can\'t update document in current tender status')
         self.request.errors.status = 403
         return
     first_document = self.request.validated['documents'][0]
     src = tender.serialize("plain")
     if self.request.content_type == 'multipart/form-data':
         data = self.request.validated['file']
         filename = data.filename
         content_type = data.type
         in_file = data.file
     else:
         filename = first_document.title
         content_type = self.request.content_type
         in_file = self.request.body_file
     document = Document()
     document.id = self.request.matchdict['id']
     document.title = filename
     document.format = content_type
     document.datePublished = first_document.datePublished
     key = generate_id()
     document.url = self.request.route_url('Tender Complaint Documents', tender_id=tender.id, complaint_id=self.request.validated['complaint_id'], id=document.id, _query={'download': key})
     self.request.validated['complaint'].documents.append(document)
     upload_file(tender, document, key, in_file, self.request)
     save_tender(tender, src, self.request)
     return {'data': document.serialize("view")}
 def put(self):
     """Tender Document Update"""
     tender = self.request.validated['tender']
     first_document = self.request.validated['documents'][0]
     if tender.status != 'active.enquiries':
         self.request.errors.add('body', 'data', 'Can\'t update document in current tender status')
         self.request.errors.status = 403
         return
     if self.request.content_type == 'multipart/form-data':
         data = self.request.validated['file']
         filename = data.filename
         content_type = data.type
         in_file = data.file
     else:
         filename = first_document.title
         content_type = self.request.content_type
         in_file = self.request.body_file
     document = Document()
     document.id = self.request.validated['id']
     document.title = filename
     document.format = content_type
     document.datePublished = first_document.datePublished
     key = generate_id()
     document.url = self.request.route_url('Tender Documents', tender_id=tender.id, id=document.id, _query={'download': key})
     src = tender.serialize("plain")
     tender.documents.append(document)
     upload_file(tender, document, key, in_file, self.request)
     save_tender(tender, src, self.request)
     return {'data': document.serialize("view")}
 def put(self):
     """Auction Award Complaint Document Update"""
     if self.request.authenticated_role != self.context.author:
         self.request.errors.add('url', 'role', 'Can update document only author')
         self.request.errors.status = 403
         return
     if self.request.validated['auction_status'] not in ['active.qualification', 'active.awarded']:
         self.request.errors.add('body', 'data', 'Can\'t update document in current ({}) auction status'.format(self.request.validated['auction_status']))
         self.request.errors.status = 403
         return
     if any([i.status != 'active' for i in self.request.validated['auction'].lots if i.id == self.request.validated['award'].lotID]):
         self.request.errors.add('body', 'data', 'Can update document only in active lot status')
         self.request.errors.status = 403
         return
     if self.request.validated['complaint'].status not in STATUS4ROLE.get(self.request.authenticated_role, []):
         self.request.errors.add('body', 'data', 'Can\'t update document in current ({}) complaint status'.format(self.request.validated['complaint'].status))
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     document.author = self.request.authenticated_role
     self.request.validated['complaint'].documents.append(document)
     if save_auction(self.request):
         self.LOGGER.info('Updated auction award complaint document {}'.format(self.request.context.id),
                     extra=context_unpack(self.request, {'MESSAGE_ID': 'auction_award_complaint_document_put'}))
         return {'data': document.serialize("view")}
 def put(self):
     """Tender Award Contract Document Update"""
     if self.request.validated['tender_status'] not in [
             'active.awarded', 'complete'
     ]:
         self.request.errors.add(
             'body', 'data',
             'Can\'t update document in current ({}) tender status'.format(
                 self.request.validated['tender_status']))
         self.request.errors.status = 403
         return
     contract = self.request.validated['contract']
     if contract.status not in ['pending', 'active']:
         self.request.errors.add(
             'body', 'data',
             'Can\'t update document in current contract status')
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     self.request.validated['contract'].documents.append(document)
     if save_tender(self.request):
         LOGGER.info(
             'Updated tender award contract document {}'.format(
                 self.request.context.id),
             extra={'MESSAGE_ID': 'tender_award_contract_document_put'})
         return {'data': document.serialize("view")}
 def collection_post(self):
     """Auction Award Complaint Document Upload
     """
     if self.request.validated['auction_status'] not in ['active.qualification', 'active.awarded']:
         self.request.errors.add('body', 'data', 'Can\'t add document in current ({}) auction status'.format(self.request.validated['auction_status']))
         self.request.errors.status = 403
         return
     if any([i.status != 'active' for i in self.request.validated['auction'].lots if i.id == self.request.validated['award'].lotID]):
         self.request.errors.add('body', 'data', 'Can add document only in active lot status')
         self.request.errors.status = 403
         return
     if self.context.status not in STATUS4ROLE.get(self.request.authenticated_role, []):
         self.request.errors.add('body', 'data', 'Can\'t add document in current ({}) complaint status'.format(self.context.status))
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     document.author = self.request.authenticated_role
     self.context.documents.append(document)
     if save_auction(self.request):
         self.LOGGER.info('Created auction award complaint document {}'.format(document.id),
                     extra=context_unpack(self.request, {'MESSAGE_ID': 'auction_award_complaint_document_create'}, {'document_id': document.id}))
         self.request.response.status = 201
         document_route = self.request.matched_route.name.replace("collection_", "")
         self.request.response.headers['Location'] = self.request.current_route_url(_route_name=document_route, document_id=document.id, _query={})
         return {'data': document.serialize("view")}
 def collection_post(self):
     """Tender Award Document Upload
     """
     if self.request.validated["tender_status"] != "active":
         self.request.errors.add(
             "body",
             "data",
             "Can't add document in current ({}) tender status".format(self.request.validated["tender_status"]),
         )
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     self.request.validated["award"].documents.append(document)
     if save_tender(self.request):
         LOGGER.info(
             "Created tender award document {}".format(document.id),
             extra=context_unpack(
                 self.request, {"MESSAGE_ID": "tender_award_document_create"}, {"document_id": document.id}
             ),
         )
         self.request.response.status = 201
         document_route = self.request.matched_route.name.replace("collection_", "")
         self.request.response.headers["Location"] = self.request.current_route_url(
             _route_name=document_route, document_id=document.id, _query={}
         )
         return {"data": document.serialize("view")}
 def put(self):
     """Tender Bid Document Update"""
     if self.request.validated['tender_status'] not in ['active.tendering', 'active.qualification']:
         self.request.errors.add('body', 'data', 'Can\'t update document in current ({}) tender status'.format(self.request.validated['tender_status']))
         self.request.errors.status = 403
         return
     tender = self.request.validated['tender']
     if self.request.validated['tender_status'] == 'active.tendering' and (tender.tenderPeriod.startDate and get_now() < tender.tenderPeriod.startDate or get_now() > tender.tenderPeriod.endDate):
         self.request.errors.add('body', 'data', 'Document can be updated only during the tendering period: from ({}) to ({}).'.format(tender.tenderPeriod.startDate and tender.tenderPeriod.startDate.isoformat(), tender.tenderPeriod.endDate.isoformat()))
         self.request.errors.status = 403
         return
     if self.request.validated['tender_status'] == 'active.qualification' and not [i for i in self.request.validated['tender'].awards if i.status == 'pending' and i.bid_id == self.request.validated['bid_id']]:
         self.request.errors.add('body', 'data', 'Can\'t update document because award of bid is not in pending state')
         self.request.errors.status = 403
         return
     bid = getattr(self.context, "__parent__")
     if bid and bid.status in ['invalid', 'unsuccessful', 'deleted']:
         self.request.errors.add('body', 'data', 'Can\'t update document in \'{}\' bid'.format(bid.status))
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     getattr(self.request.validated['bid'], self.container).append(document)
     if self.request.validated['tender_status'] == 'active.tendering':
         self.request.validated['tender'].modified = False
     if save_tender(self.request):
         self.LOGGER.info('Updated tender bid document {}'.format(self.request.context.id),
                     extra=context_unpack(self.request, {'MESSAGE_ID': 'tender_bid_document_put'}))
         return {'data': document.serialize("view")}
 def collection_post(self):
     """Auction Bid Document Upload
     """
     if self.request.validated['auction_status'] not in ['active.tendering', 'active.qualification']:
         self.request.errors.add('body', 'data', 'Can\'t add document in current ({}) auction status'.format(self.request.validated['auction_status']))
         self.request.errors.status = 403
         return
     auction = self.request.validated['auction']
     if self.request.validated['auction_status'] == 'active.tendering' and (auction.tenderPeriod.startDate and get_now() < auction.tenderPeriod.startDate or get_now() > auction.tenderPeriod.endDate):
         self.request.errors.add('body', 'data', 'Document can be added only during the tendering period: from ({}) to ({}).'.format(auction.auctionPeriod.startDate and auction.auctionPeriod.startDate.isoformat(), auction.auctionPeriod.endDate.isoformat()))
         self.request.errors.status = 403
         return
     if self.request.validated['auction_status'] == 'active.qualification' and not [i for i in self.request.validated['auction'].awards if i.status == 'pending' and i.bid_id == self.request.validated['bid_id']]:
         self.request.errors.add('body', 'data', 'Can\'t add document because award of bid is not in pending state')
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     self.context.documents.append(document)
     if self.request.validated['auction_status'] == 'active.tendering':
         self.request.validated['auction'].modified = False
     if save_auction(self.request):
         self.LOGGER.info('Created auction bid document {}'.format(document.id),
                     extra=context_unpack(self.request, {'MESSAGE_ID': 'auction_bid_document_create'}, {'document_id': document.id}))
         self.request.response.status = 201
         document_route = self.request.matched_route.name.replace("collection_", "")
         self.request.response.headers['Location'] = self.request.current_route_url(_route_name=document_route, document_id=document.id, _query={})
         return {'data': document.serialize("view")}
 def collection_post(self):
     """Auction Bid Document Upload
     """
     if self.request.validated['auction_status'] not in ['active.tendering', 'active.qualification']:
         self.request.errors.add('body', 'data', 'Can\'t add document in current ({}) auction status'.format(self.request.validated['auction_status']))
         self.request.errors.status = 403
         return
     auction = self.request.validated['auction']
     if self.request.validated['auction_status'] == 'active.tendering' and (auction.tenderPeriod.startDate and get_now() < auction.tenderPeriod.startDate or get_now() > auction.tenderPeriod.endDate):
         self.request.errors.add('body', 'data', 'Document can be added only during the tendering period: from ({}) to ({}).'.format(auction.auctionPeriod.startDate and auction.auctionPeriod.startDate.isoformat(), auction.auctionPeriod.endDate.isoformat()))
         self.request.errors.status = 403
         return
     if self.request.validated['auction_status'] == 'active.qualification' and not [i for i in self.request.validated['auction'].awards if i.status == 'pending' and i.bid_id == self.request.validated['bid_id']]:
         self.request.errors.add('body', 'data', 'Can\'t add document because award of bid is not in pending state')
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     self.context.documents.append(document)
     if self.request.validated['auction_status'] == 'active.tendering':
         self.request.validated['auction'].modified = False
     if save_auction(self.request):
         self.LOGGER.info('Created auction bid document {}'.format(document.id),
                     extra=context_unpack(self.request, {'MESSAGE_ID': 'auction_bid_document_create'}, {'document_id': document.id}))
         self.request.response.status = 201
         document_route = self.request.matched_route.name.replace("collection_", "")
         self.request.response.headers['Location'] = self.request.current_route_url(_route_name=document_route, document_id=document.id, _query={})
         return {'data': document.serialize("view")}
Ejemplo n.º 11
0
 def put(self):
     """Tender Award Document Update"""
     if self.request.validated['tender_status'] != 'active.qualification':
         self.request.errors.add(
             'body', 'data',
             'Can\'t update document in current ({}) tender status'.format(
                 self.request.validated['tender_status']))
         self.request.errors.status = 403
         return
     if any([
             i.status != 'active'
             for i in self.request.validated['tender'].lots
             if i.id == self.request.validated['award'].lotID
     ]):
         self.request.errors.add(
             'body', 'data',
             'Can update document only in active lot status')
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     self.request.validated['award'].documents.append(document)
     if save_tender(self.request):
         self.LOGGER.info('Updated tender award document {}'.format(
             self.request.context.id),
                          extra=context_unpack(
                              self.request,
                              {'MESSAGE_ID': 'tender_award_document_put'}))
         return {'data': document.serialize("view")}
Ejemplo n.º 12
0
 def collection_post(self):
     """Auction Cancellation Document Upload
     """
     if self.request.validated['auction_status'] in [
             'complete', 'cancelled', 'unsuccessful'
     ]:
         self.request.errors.add(
             'body', 'data',
             'Can\'t add document in current ({}) auction status'.format(
                 self.request.validated['auction_status']))
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     self.context.documents.append(document)
     if save_auction(self.request):
         self.LOGGER.info(
             'Created auction cancellation document {}'.format(document.id),
             extra=context_unpack(
                 self.request,
                 {'MESSAGE_ID': 'auction_cancellation_document_create'},
                 {'document_id': document.id}))
         self.request.response.status = 201
         document_route = self.request.matched_route.name.replace(
             "collection_", "")
         self.request.response.headers[
             'Location'] = self.request.current_route_url(
                 _route_name=document_route,
                 document_id=document.id,
                 _query={})
         return {'data': document.serialize("view")}
 def put(self):
     """Tender Bid Document Update"""
     if self.request.validated['tender_status'] not in [
             'active.tendering', 'active.qualification'
     ]:
         self.request.errors.add(
             'body', 'data',
             'Can\'t update document in current ({}) tender status'.format(
                 self.request.validated['tender_status']))
         self.request.errors.status = 403
         return
     if self.request.validated[
             'tender_status'] == 'active.qualification' and not [
                 i for i in self.request.validated['tender'].awards
                 if i.status == 'pending'
                 and i.bid_id == self.request.validated['bid_id']
             ]:
         self.request.errors.add(
             'body', 'data',
             'Can\'t update document because award of bid is not in pending state'
         )
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     self.request.validated['bid'].documents.append(document)
     if save_tender(self.request):
         LOGGER.info('Updated tender bid document {}'.format(
             self.request.context.id),
                     extra=context_unpack(
                         self.request,
                         {'MESSAGE_ID': 'tender_bid_document_put'}))
         return {'data': document.serialize("view")}
 def collection_post(self):
     """Tender Bid Document Upload
     """
     if self.request.validated['tender_status'] not in ['active.tendering', 'active.qualification']:
         self.request.errors.add('body', 'data', 'Can\'t add document in current ({}) tender status'.format(self.request.validated['tender_status']))
         self.request.errors.status = 403
         return
     if self.request.validated['tender_status'] == 'active.qualification' and not [i for i in self.request.validated['tender'].awards if i.status == 'pending' and i.bid_id == self.request.validated['bid_id']]:
         self.request.errors.add('body', 'data', 'Can\'t add document because award of bid is not in pending state')
         self.request.errors.status = 403
         return
     if self.context.status in ['invalid', 'unsuccessful', 'deleted']:
         self.request.errors.add('body', 'data', 'Can\'t add document to \'{}\' bid'.format(self.context.status))
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     getattr(self.context, self.container).append(document)
     if self.request.validated['tender_status'] == 'active.tendering':
         self.request.validated['tender'].modified = False
     if save_tender(self.request):
         self.LOGGER.info('Created tender bid document {}'.format(document.id),
                     extra=context_unpack(self.request, {'MESSAGE_ID': 'tender_bid_document_create'}, {'document_id': document.id}))
         self.request.response.status = 201
         document_route = self.request.matched_route.name.replace("collection_", "")
         self.request.response.headers['Location'] = self.request.current_route_url(_route_name=document_route, document_id=document.id, _query={})
         return {'data': document.serialize("view")}
Ejemplo n.º 15
0
 def put(self):
     """Plan Document Update"""
     document = upload_file(self.request)
     self.request.context.__parent__.documents.append(document)
     if save_plan(self.request):
         self._put_document_log()
         return {"data": document.serialize("view")}
Ejemplo n.º 16
0
 def collection_post(self):
     """Auction Bid Document Upload
     """
     if not self.validate_bid_document('add'):
         return
     document = upload_file(self.request)
     self.context.documents.append(document)
     if self.request.validated['auction_status'] == 'active.tendering':
         self.request.validated['auction'].modified = False
     if save_auction(self.request):
         self.LOGGER.info('Created auction bid document {}'.format(
             document.id),
                          extra=context_unpack(
                              self.request,
                              {'MESSAGE_ID': 'auction_bid_document_create'},
                              {'document_id': document.id}))
         self.request.response.status = 201
         document_route = self.request.matched_route.name.replace(
             "collection_", "")
         self.request.response.headers[
             'Location'] = self.request.current_route_url(
                 _route_name=document_route,
                 document_id=document.id,
                 _query={})
         return {'data': document.serialize("view")}
 def collection_post(self):
     """Auction Award Complaint Document Upload
     """
     if self.request.validated['auction_status'] not in ['active.qualification', 'active.awarded']:
         self.request.errors.add('body', 'data', 'Can\'t add document in current ({}) auction status'.format(self.request.validated['auction_status']))
         self.request.errors.status = 403
         return
     if any([i.status != 'active' for i in self.request.validated['auction'].lots if i.id == self.request.validated['award'].lotID]):
         self.request.errors.add('body', 'data', 'Can add document only in active lot status')
         self.request.errors.status = 403
         return
     if self.context.status not in STATUS4ROLE.get(self.request.authenticated_role, []):
         self.request.errors.add('body', 'data', 'Can\'t add document in current ({}) complaint status'.format(self.context.status))
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     document.author = self.request.authenticated_role
     self.context.documents.append(document)
     if save_auction(self.request):
         self.LOGGER.info('Created auction award complaint document {}'.format(document.id),
                     extra=context_unpack(self.request, {'MESSAGE_ID': 'auction_award_complaint_document_create'}, {'document_id': document.id}))
         self.request.response.status = 201
         document_route = self.request.matched_route.name.replace("collection_", "")
         self.request.response.headers['Location'] = self.request.current_route_url(_route_name=document_route, document_id=document.id, _query={})
         return {'data': document.serialize("view")}
Ejemplo n.º 18
0
 def collection_post(self):
     """Tender Contract Document Upload
     """
     if self.request.validated['tender_status'] not in ['active.qualification', 'active.awarded']:
         self.request.errors.add('body', 'data', 'Can\'t add document in current ({}) tender status'.format(self.request.validated['tender_status']))
         self.request.errors.status = 403
         return
     tender = self.request.validated['tender']
     contract = self.request.validated['contract']
     if any([i.status != 'active' for i in tender.lots if i.id in [a.lotID for a in tender.awards if a.id == contract.awardID]]):
         self.request.errors.add('body', 'data', 'Can add document only in active lot status')
         self.request.errors.status = 403
         return
     if contract.status not in ['pending', 'active']:
         self.request.errors.add('body', 'data', 'Can\'t add document in current contract status')
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     self.context.documents.append(document)
     if save_tender(self.request):
         self.LOGGER.info('Created tender contract document {}'.format(document.id),
                     extra=context_unpack(self.request, {'MESSAGE_ID': 'tender_contract_document_create'}, {'document_id': document.id}))
         self.request.response.status = 201
         document_route = self.request.matched_route.name.replace("collection_", "")
         self.request.response.headers['Location'] = self.request.current_route_url(_route_name=document_route, document_id=document.id, _query={})
         return {'data': document.serialize("view")}
Ejemplo n.º 19
0
 def collection_post(self):
     """Tender Award Complaint Document Upload
     """
     if not self.validate_complaint_document("add"):
         return
     document = upload_file(self.request)
     document.author = self.request.authenticated_role
     self.context.documents.append(document)
     if save_tender(self.request):
         self.LOGGER.info(
             "Created tender award complaint document {}".format(
                 document.id),
             extra=context_unpack(
                 self.request,
                 {"MESSAGE_ID": "tender_award_complaint_document_create"},
                 {"document_id": document.id}),
         )
         self.request.response.status = 201
         document_route = self.request.matched_route.name.replace(
             "collection_", "")
         self.request.response.headers[
             "Location"] = self.request.current_route_url(
                 _route_name=document_route,
                 document_id=document.id,
                 _query={})
         return {"data": document.serialize("view")}
Ejemplo n.º 20
0
 def put(self):
     """Tender Qualification Document Update"""
     if self.request.validated[
             'tender_status'] != 'active.pre-qualification':
         self.request.errors.add(
             'body', 'data',
             'Can\'t update document in current ({}) tender status'.format(
                 self.request.validated['tender_status']))
         self.request.errors.status = 403
         return
     qualification = self.request.validated['qualification']
     if qualification.status != 'pending':
         self.request.errors.add(
             'body', 'data',
             'Can\'t update document in current qualification status')
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     self.request.validated['qualification'].documents.append(document)
     if save_tender(self.request):
         self.LOGGER.info(
             'Updated tender qualification document {}'.format(
                 self.request.context.id),
             extra=context_unpack(
                 self.request,
                 {'MESSAGE_ID': 'tender_qualification_document_put'}))
         return {'data': document.serialize("view")}
Ejemplo n.º 21
0
 def collection_post(self):
     """Tender Document Upload"""
     if self.request.validated['tender_status'] != 'active':
         self.request.errors.add(
             'body', 'data',
             'Can\'t add document in current ({}) tender status'.format(
                 self.request.validated['tender_status']))
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     self.request.validated['tender'].documents.append(document)
     if save_tender(self.request):
         self.LOGGER.info(
             'Created tender document {}'.format(document.id),
             extra=context_unpack(self.request,
                                  {'MESSAGE_ID': 'tender_document_create'},
                                  {'document_id': document.id}))
         self.request.response.status = 201
         document_route = self.request.matched_route.name.replace(
             "collection_", "")
         self.request.response.headers[
             'Location'] = self.request.current_route_url(
                 _route_name=document_route,
                 document_id=document.id,
                 _query={})
         return {'data': document.serialize("view")}
Ejemplo n.º 22
0
 def collection_post(self):
     """Tender Document Upload"""
     if self.request.authenticated_role != 'auction' and self.request.validated['tender_status'] != 'active.enquiries' or \
        self.request.authenticated_role == 'auction' and self.request.validated['tender_status'] not in ['active.auction', 'active.qualification']:
         self.request.errors.add(
             'body', 'data',
             'Can\'t add document in current ({}) tender status'.format(
                 self.request.validated['tender_status']))
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     self.request.validated['tender'].documents.append(document)
     if save_tender(self.request):
         update_journal_handler_params({'document_id': document.id})
         LOGGER.info('Created tender document {}'.format(document.id),
                     extra={'MESSAGE_ID': 'tender_document_create'})
         self.request.response.status = 201
         document_route = self.request.matched_route.name.replace(
             "collection_", "")
         self.request.response.headers[
             'Location'] = self.request.current_route_url(
                 _route_name=document_route,
                 document_id=document.id,
                 _query={})
         return {'data': document.serialize("view")}
Ejemplo n.º 23
0
 def collection_post(self):
     """Tender Document Upload"""
     if not self.validate_update_tender():
         raise error_handler(self.request.errors)
     document = upload_file(self.request)
     document.author = self.request.authenticated_role
     self.context.documents.append(document)
     if self.request.authenticated_role == 'tender_owner' and self.request.validated[
             'tender_status'] == 'active.tendering':
         self.context.invalidate_bids_data()
     if save_tender(self.request):
         self.LOGGER.info(
             'Created tender document {}'.format(document.id),
             extra=context_unpack(self.request,
                                  {'MESSAGE_ID': 'tender_document_create'},
                                  {'document_id': document.id}))
         self.request.response.status = 201
         document_route = self.request.matched_route.name.replace(
             "collection_", "")
         self.request.response.headers[
             'Location'] = self.request.current_route_url(
                 _route_name=document_route,
                 document_id=document.id,
                 _query={})
         return {'data': document.serialize("view")}
 def put(self):
     """Tender Complaint Document Update"""
     if self.request.authenticated_role != self.context.author:
         self.request.errors.add('url', 'role',
                                 'Can update document only author')
         self.request.errors.status = 403
         return
     if self.request.validated['tender_status'] not in [
             'active.enquiries', 'active.tendering', 'active.auction',
             'active.qualification', 'active.awarded'
     ]:
         self.request.errors.add(
             'body', 'data',
             'Can\'t update document in current ({}) tender status'.format(
                 self.request.validated['tender_status']))
         self.request.errors.status = 403
         return
     if self.request.validated['complaint'].status not in STATUS4ROLE.get(
             self.request.authenticated_role, []):
         self.request.errors.add(
             'body', 'data',
             'Can\'t update document in current ({}) complaint status'.
             format(self.request.validated['complaint'].status))
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     document.author = self.request.authenticated_role
     self.request.validated['complaint'].documents.append(document)
     if save_tender(self.request):
         LOGGER.info('Updated tender complaint document {}'.format(
             self.request.context.id),
                     extra=context_unpack(
                         self.request,
                         {'MESSAGE_ID': 'tender_complaint_document_put'}))
         return {'data': document.serialize("view")}
 def collection_post(self):
     """Tender Award Complaint Document Upload
     """
     if self.request.validated["tender_status"] not in ["active.qualification", "active.awarded"]:
         self.request.errors.add(
             "body",
             "data",
             "Can't add document in current ({}) tender status".format(self.request.validated["tender_status"]),
         )
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     self.request.validated["complaint"].documents.append(document)
     if save_tender(self.request):
         update_journal_handler_params({"document_id": document.id})
         LOGGER.info(
             "Created tender award complaint document {}".format(document.id),
             extra={"MESSAGE_ID": "tender_award_complaint_document_create"},
         )
         self.request.response.status = 201
         document_route = self.request.matched_route.name.replace("collection_", "")
         self.request.response.headers["Location"] = self.request.current_route_url(
             _route_name=document_route, document_id=document.id, _query={}
         )
         return {"data": document.serialize("view")}
Ejemplo n.º 26
0
 def collection_post(self):
     """Tender Bid Document Upload
     """
     if self.request.validated["tender_status"] not in ["active.tendering", "active.qualification"]:
         self.request.errors.add(
             "body",
             "data",
             "Can't add document in current ({}) tender status".format(self.request.validated["tender_status"]),
         )
         self.request.errors.status = 403
         return
     if self.request.validated["tender_status"] == "active.qualification" and not [
         i
         for i in self.request.validated["tender"].awards
         if i.status == "pending" and i.bid_id == self.request.validated["bid_id"]
     ]:
         self.request.errors.add("body", "data", "Can't add document because award of bid is not in pending state")
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     self.context.documents.append(document)
     if save_tender(self.request):
         LOGGER.info(
             "Created tender bid document {}".format(document.id),
             extra=context_unpack(
                 self.request, {"MESSAGE_ID": "tender_bid_document_create"}, {"document_id": document.id}
             ),
         )
         self.request.response.status = 201
         document_route = self.request.matched_route.name.replace("collection_", "")
         self.request.response.headers["Location"] = self.request.current_route_url(
             _route_name=document_route, document_id=document.id, _query={}
         )
         return {"data": document.serialize("view")}
Ejemplo n.º 27
0
 def put(self):
     """Tender Bid Document Update"""
     if self.request.validated["tender_status"] not in ["active.tendering", "active.qualification"]:
         self.request.errors.add(
             "body",
             "data",
             "Can't update document in current ({}) tender status".format(self.request.validated["tender_status"]),
         )
         self.request.errors.status = 403
         return
     if self.request.validated["tender_status"] == "active.qualification" and not [
         i
         for i in self.request.validated["tender"].awards
         if i.status == "pending" and i.bid_id == self.request.validated["bid_id"]
     ]:
         self.request.errors.add(
             "body", "data", "Can't update document because award of bid is not in pending state"
         )
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     self.request.validated["bid"].documents.append(document)
     if save_tender(self.request):
         LOGGER.info(
             "Updated tender bid document {}".format(self.request.context.id),
             extra=context_unpack(self.request, {"MESSAGE_ID": "tender_bid_document_put"}),
         )
         return {"data": document.serialize("view")}
 def put(self):
     """Auction Award Complaint Document Update"""
     if self.request.authenticated_role != self.context.author:
         self.request.errors.add('url', 'role', 'Can update document only author')
         self.request.errors.status = 403
         return
     if self.request.validated['auction_status'] not in ['active.qualification', 'active.awarded']:
         self.request.errors.add('body', 'data', 'Can\'t update document in current ({}) auction status'.format(self.request.validated['auction_status']))
         self.request.errors.status = 403
         return
     if any([i.status != 'active' for i in self.request.validated['auction'].lots if i.id == self.request.validated['award'].lotID]):
         self.request.errors.add('body', 'data', 'Can update document only in active lot status')
         self.request.errors.status = 403
         return
     if self.request.validated['complaint'].status not in STATUS4ROLE.get(self.request.authenticated_role, []):
         self.request.errors.add('body', 'data', 'Can\'t update document in current ({}) complaint status'.format(self.request.validated['complaint'].status))
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     document.author = self.request.authenticated_role
     self.request.validated['complaint'].documents.append(document)
     if save_auction(self.request):
         self.LOGGER.info('Updated auction award complaint document {}'.format(self.request.context.id),
                     extra=context_unpack(self.request, {'MESSAGE_ID': 'auction_award_complaint_document_put'}))
         return {'data': document.serialize("view")}
 def collection_post(self):
     """Tender Bid Document Upload
     """
     if self.request.validated['tender_status'] not in [
             'active.tendering', 'active.qualification', 'active.awarded'
     ]:
         self.request.errors.add(
             'body', 'data',
             'Can\'t add document in current ({}) tender status'.format(
                 self.request.validated['tender_status']))
         self.request.errors.status = 403
         return
     tender = self.request.validated['tender']
     if self.request.validated['tender_status'] == 'active.tendering' and (
             tender.tenderPeriod.startDate
             and get_now() < tender.tenderPeriod.startDate
             or get_now() > tender.tenderPeriod.endDate):
         self.request.errors.add(
             'body', 'data',
             'Document can be added only during the tendering period: from ({}) to ({}).'
             .format(
                 tender.tenderPeriod.startDate
                 and tender.tenderPeriod.startDate.isoformat(),
                 tender.tenderPeriod.endDate.isoformat()))
         self.request.errors.status = 403
         return
     if self.request.validated['tender_status'] in ['active.qualification', 'active.awarded'] and \
             not [i for i in self.request.validated['tender'].awards if i.status in ['pending', 'active'] and i.bid_id == self.request.validated['bid_id']]:
         self.request.errors.add(
             'body', 'data',
             'Can\'t add document because award of bid is not in pending or active state'
         )
         self.request.errors.status = 403
         return
     if self.context.status in ['invalid', 'unsuccessful', 'deleted']:
         self.request.errors.add(
             'body', 'data', 'Can\'t add document to \'{}\' bid'.format(
                 self.context.status))
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     getattr(self.context, self.container).append(document)
     if self.request.validated['tender_status'] == 'active.tendering':
         self.request.validated['tender'].modified = False
     if save_tender(self.request):
         self.LOGGER.info(
             'Created tender bid document {}'.format(document.id),
             extra=context_unpack(
                 self.request, {'MESSAGE_ID': 'tender_bid_document_create'},
                 {'document_id': document.id}))
         self.request.response.status = 201
         document_route = self.request.matched_route.name.replace(
             "collection_", "")
         self.request.response.headers[
             'Location'] = self.request.current_route_url(
                 _route_name=document_route,
                 document_id=document.id,
                 _query={})
         return {'data': document.serialize("view")}
Ejemplo n.º 30
0
 def put(self):
     """Tender Document Update"""
     document = upload_file(self.request)
     self.request.validated['tender'].documents.append(document)
     if save_tender(self.request):
         self.LOGGER.info('Updated tender document {}'.format(self.request.context.id),
                     extra=context_unpack(self.request, {'MESSAGE_ID': 'tender_document_put'}))
         return {'data': document.serialize("view")}
 def put(self):
     """Contract Document Update"""
     document = upload_file(self.request)
     self.request.validated['contract'].documents.append(document)
     if save_contract(self.request):
         self.LOGGER.info('Updated contract document {}'.format(self.request.context.id),
                     extra=context_unpack(self.request, {'MESSAGE_ID': 'contract_document_put'}))
         return {'data': document.serialize("view")}
 def put(self):
     document = upload_file(self.request)
     getattr(self.request.validated[self.context_short_name], self.container).append(document)
     if self.save(self.request):
         self.LOGGER.info(
             "Updated {} document {}".format(self.context_pretty_name, self.request.context.id),
             extra=context_unpack(self.request, {"MESSAGE_ID": "{}_document_put".format(self.context_name)}),
         )
         return {"data": document.serialize("view")}
Ejemplo n.º 33
0
 def put(self):
     """Auction Award Complaint Document Update"""
     document = upload_file(self.request)
     document.author = self.request.authenticated_role
     self.request.validated['complaint'].documents.append(document)
     if save_auction(self.request):
         self.LOGGER.info('Updated auction award complaint document {}'.format(self.request.context.id),
                     extra=context_unpack(self.request, {'MESSAGE_ID': 'auction_award_complaint_document_put'}))
         return {'data': document.serialize("view")}
 def put(self):
     """Tender Cancellation Document Update"""
     document = upload_file(self.request)
     self.request.validated["cancellation"].documents.append(document)
     if save_tender(self.request):
         self.LOGGER.info(
             "Updated tender cancellation document {}".format(self.request.context.id),
             extra=context_unpack(self.request, {"MESSAGE_ID": "tender_cancellation_document_put"}),
         )
         return {"data": document.serialize("view")}
 def put(self):
     """Auction Award Document Update"""
     if not self.validate_award_document('update'):
         return
     document = upload_file(self.request)
     self.request.validated['award'].documents.append(document)
     if save_auction(self.request):
         self.LOGGER.info('Updated auction award document {}'.format(self.request.context.id),
                     extra=context_unpack(self.request, {'MESSAGE_ID': 'auction_award_document_put'}))
         return {'data': document.serialize("view")}
Ejemplo n.º 36
0
 def put(self):
     """Auction Award Document Update"""
     if not self.validate_award_document('update'):
         return
     document = upload_file(self.request)
     self.request.validated['award'].documents.append(document)
     if save_auction(self.request):
         self.LOGGER.info('Updated auction award document {}'.format(self.request.context.id),
                     extra=context_unpack(self.request, {'MESSAGE_ID': 'auction_award_document_put'}))
         return {'data': document.serialize("view")}
 def put(self):
     """Tender Document Update"""
     if not self.validate_update_tender('update'):
         return
     document = upload_file(self.request)
     self.request.validated['tender'].documents.append(document)
     if save_tender(self.request):
         LOGGER.info('Updated tender document {}'.format(self.request.context.id),
                     extra=context_unpack(self.request, {'MESSAGE_ID': 'tender_document_put'}))
         return {'data': document.serialize("view")}
 def put(self):
     """Tender Bid Document Update"""
     if self.request.validated['tender_status'] not in [
             'active.tendering', 'active.qualification'
     ]:
         self.request.errors.add(
             'body', 'data',
             'Can\'t update document in current ({}) tender status'.format(
                 self.request.validated['tender_status']))
         self.request.errors.status = 403
         return
     tender = self.request.validated['tender']
     if self.request.validated['tender_status'] == 'active.tendering' and (
             tender.tenderPeriod.startDate
             and get_now() < tender.tenderPeriod.startDate
             or get_now() > tender.tenderPeriod.endDate):
         self.request.errors.add(
             'body', 'data',
             'Document can be updated only during the tendering period: from ({}) to ({}).'
             .format(
                 tender.tenderPeriod.startDate
                 and tender.tenderPeriod.startDate.isoformat(),
                 tender.tenderPeriod.endDate.isoformat()))
         self.request.errors.status = 403
         return
     if self.request.validated[
             'tender_status'] == 'active.qualification' and not [
                 i for i in self.request.validated['tender'].awards
                 if i.status == 'pending'
                 and i.bid_id == self.request.validated['bid_id']
             ]:
         self.request.errors.add(
             'body', 'data',
             'Can\'t update document because award of bid is not in pending state'
         )
         self.request.errors.status = 403
         return
     bid = getattr(self.context, "__parent__")
     if bid and bid.status in ['invalid', 'unsuccessful', 'deleted']:
         self.request.errors.add(
             'body', 'data',
             'Can\'t update document in \'{}\' bid'.format(bid.status))
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     getattr(self.request.validated['bid'], self.container).append(document)
     if self.request.validated['tender_status'] == 'active.tendering':
         self.request.validated['tender'].modified = False
     if save_tender(self.request):
         self.LOGGER.info('Updated tender bid document {}'.format(
             self.request.context.id),
                          extra=context_unpack(
                              self.request,
                              {'MESSAGE_ID': 'tender_bid_document_put'}))
         return {'data': document.serialize("view")}
Ejemplo n.º 39
0
 def put(self):
     """Tender Award Complaint Document Update"""
     document = upload_file(self.request)
     document.author = self.request.authenticated_role
     self.request.validated["complaint"].documents.append(document)
     if save_tender(self.request):
         self.LOGGER.info(
             "Updated tender award complaint document {}".format(self.request.context.id),
             extra=context_unpack(self.request, {"MESSAGE_ID": "tender_award_complaint_document_put"}),
         )
         return {"data": document.serialize("view")}
Ejemplo n.º 40
0
 def put(self):
     """Tender Bid Document Update"""
     tender = self.request.validated['tender']
     if tender.status not in ['active.tendering', 'active.auction', 'active.qualification']:
         self.request.errors.add('body', 'data', 'Can\'t update document in current tender status')
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     self.request.validated['bid'].documents.append(document)
     save_tender(self.request)
     return {'data': document.serialize("view")}
 def put(self):
     """Tender Complaint Document Update"""
     if self.request.validated['tender_status'] not in ['active.enquiries', 'active.tendering', 'active.auction', 'active.qualification', 'active.awarded']:
         self.request.errors.add('body', 'data', 'Can\'t update document in current ({}) tender status'.format(self.request.validated['tender_status']))
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     self.request.validated['complaint'].documents.append(document)
     if save_tender(self.request):
         LOGGER.info('Updated tender complaint document {}'.format(self.request.context.id), extra={'MESSAGE_ID': 'tender_complaint_document_put'})
         return {'data': document.serialize("view")}
Ejemplo n.º 42
0
 def put(self):
     """Contract Document Update"""
     document = upload_file(self.request)
     self.request.validated["contract"].documents.append(document)
     if save_contract(self.request):
         self.LOGGER.info(
             "Updated contract document {}".format(self.request.context.id),
             extra=context_unpack(self.request,
                                  {"MESSAGE_ID": "contract_document_put"}),
         )
         return {"data": document.serialize("view")}
 def collection_post(self):
     """Contract Document Upload"""
     document = upload_file(self.request)
     self.context.documents.append(document)
     if save_contract(self.request):
         self.LOGGER.info('Created contract document {}'.format(document.id),
                     extra=context_unpack(self.request, {'MESSAGE_ID': 'contract_document_create'}, {'document_id': document.id}))
         self.request.response.status = 201
         document_route = self.request.matched_route.name.replace("collection_", "")
         self.request.response.headers['Location'] = self.request.current_route_url(_route_name=document_route, document_id=document.id, _query={})
         return {'data': document.serialize("view")}
Ejemplo n.º 44
0
 def put(self):
     """Tender Document Update"""
     tender = self.request.validated['tender']
     if tender.status != 'active.enquiries':
         self.request.errors.add('body', 'data', 'Can\'t update document in current tender status')
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     tender.documents.append(document)
     save_tender(self.request)
     return {'data': document.serialize("view")}
 def put(self):
     """Tender Cancellation Document Update"""
     if self.request.validated['tender_status'] in ['complete', 'cancelled', 'unsuccessful']:
         self.request.errors.add('body', 'data', 'Can\'t update document in current ({}) tender status'.format(self.request.validated['tender_status']))
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     self.request.validated['cancellation'].documents.append(document)
     if save_tender(self.request):
         LOGGER.info('Updated tender cancellation document {}'.format(self.request.context.id), extra={'MESSAGE_ID': 'tender_cancellation_document_put'})
         return {'data': document.serialize("view")}
Ejemplo n.º 46
0
 def collection_post(self):
     """Tender Document Upload"""
     document = upload_file(self.request)
     self.context.documents.append(document)
     if save_tender(self.request):
         self.LOGGER.info('Created tender document {}'.format(document.id),
                     extra=context_unpack(self.request, {'MESSAGE_ID': 'tender_document_create'}, {'document_id': document.id}))
         self.request.response.status = 201
         document_route = self.request.matched_route.name.replace("collection_", "")
         self.request.response.headers['Location'] = self.request.current_route_url(_route_name=document_route, document_id=document.id, _query={})
         return {'data': document.serialize("view")}
Ejemplo n.º 47
0
 def put(self):
     """Tender Award Document Update"""
     if self.request.validated['tender_status'] != 'active.qualification':
         self.request.errors.add('body', 'data', 'Can\'t update document in current ({}) tender status'.format(self.request.validated['tender_status']))
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     self.request.validated['award'].documents.append(document)
     if save_tender(self.request):
         LOGGER.info('Updated tender award document {}'.format(self.request.context.id), extra={'MESSAGE_ID': 'tender_award_document_put'})
         return {'data': document.serialize("view")}
 def put(self):
     """Tender Award Complaint Document Update"""
     if not self.validate_complaint_document('update'):
         return
     document = upload_file(self.request)
     document.author = self.request.authenticated_role
     self.request.validated['complaint'].documents.append(document)
     if save_tender(self.request):
         self.LOGGER.info('Updated tender award complaint document {}'.format(self.request.context.id),
                     extra=context_unpack(self.request, {'MESSAGE_ID': 'tender_award_complaint_document_put'}))
         return {'data': document.serialize("view")}
 def collection_post(self):
     """Tender Document Upload"""
     tender = self.request.validated['tender']
     if tender.status != 'active.enquiries':
         self.request.errors.add('body', 'data', 'Can\'t add document in current tender status')
         self.request.errors.status = 403
         return
     src = tender.serialize("plain")
     data = self.request.validated['file']
     document = Document()
     document.id = generate_id()
     document.title = data.filename
     document.format = data.type
     key = generate_id()
     document.url = self.request.route_url('Tender Documents', tender_id=tender.id, id=document.id, _query={'download': key})
     tender.documents.append(document)
     upload_file(tender, document, key, data.file, self.request)
     save_tender(tender, src, self.request)
     self.request.response.status = 201
     self.request.response.headers['Location'] = self.request.route_url('Tender Documents', tender_id=tender.id, id=document.id)
     return {'data': document.serialize("view")}
 def put(self):
     """Tender Document Update"""
     if not self.validate_update_tender('update'):
         return
     document = upload_file(self.request)
     self.request.validated['tender'].documents.append(document)
     if self.request.authenticated_role == 'tender_owner' and self.request.validated['tender_status'] == 'active.tendering':
         self.request.validated['tender'].invalidate_bids_data()
     if save_tender(self.request):
         self.LOGGER.info('Updated tender document {}'.format(self.request.context.id),
                     extra=context_unpack(self.request, {'MESSAGE_ID': 'tender_document_put'}))
         return {'data': document.serialize("view")}
 def put(self):
     """Auction Bid Document Update"""
     if not self.validate_bid_document('update'):
         return
     document = upload_file(self.request)
     self.request.validated['bid'].documents.append(document)
     if self.request.validated['auction_status'] == 'active.tendering':
         self.request.validated['auction'].modified = False
     if save_auction(self.request):
         self.LOGGER.info('Updated auction bid document {}'.format(self.request.context.id),
                     extra=context_unpack(self.request, {'MESSAGE_ID': 'auction_bid_document_put'}))
         return {'data': document.serialize("view")}
 def put(self):
     """Auction Cancellation Document Update"""
     if self.request.validated['auction_status'] in ['complete', 'cancelled', 'unsuccessful']:
         self.request.errors.add('body', 'data', 'Can\'t update document in current ({}) auction status'.format(self.request.validated['auction_status']))
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     self.request.validated['cancellation'].documents.append(document)
     if save_auction(self.request):
         self.LOGGER.info('Updated auction cancellation document {}'.format(self.request.context.id),
                     extra=context_unpack(self.request, {'MESSAGE_ID': 'auction_cancellation_document_put'}))
         return {'data': document.serialize("view")}
Ejemplo n.º 53
0
 def collection_post(self):
     """Plan Document Upload"""
     document = upload_file(self.request)
     self.context.documents.append(document)
     if save_plan(self.request):
         self._post_document_log(document)
         self.request.response.status = 201
         document_route = self.request.matched_route.name.replace("collection_", "")
         self.request.response.headers["Location"] = self.request.current_route_url(
             _route_name=document_route, document_id=document.id, _query={}
         )
         return {"data": document.serialize("view")}
 def put(self):
     """Auction Document Update"""
     if self.request.authenticated_role != 'auction' and self.request.validated['auction_status'] != 'active.enquiries' or \
        self.request.authenticated_role == 'auction' and self.request.validated['auction_status'] not in ['active.auction', 'active.qualification']:
         self.request.errors.add('body', 'data', 'Can\'t update document in current ({}) auction status'.format(self.request.validated['auction_status']))
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     self.request.validated['auction'].documents.append(document)
     if save_auction(self.request):
         self.LOGGER.info('Updated auction document {}'.format(self.request.context.id),
                     extra=context_unpack(self.request, {'MESSAGE_ID': 'auction_document_put'}))
         return {'data': document.serialize("view")}
Ejemplo n.º 55
0
 def collection_post(self):
     """Tender Document Upload"""
     tender = self.request.validated['tender']
     if tender.status != 'active.enquiries':
         self.request.errors.add('body', 'data', 'Can\'t add document in current tender status')
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     tender.documents.append(document)
     save_tender(self.request)
     self.request.response.status = 201
     document_route = self.request.matched_route.name.replace("collection_", "")
     self.request.response.headers['Location'] = self.request.current_route_url(_route_name=document_route, document_id=document.id, _query={})
     return {'data': document.serialize("view")}
 def collection_post(self):
     """Tender Document Upload"""
     if not self.validate_update_tender('add'):
         return
     document = upload_file(self.request)
     self.context.documents.append(document)
     if self.request.authenticated_role == 'tender_owner' and self.request.validated['tender_status'] == 'active.tendering':
         self.context.invalidate_bids_data()
     if save_tender(self.request):
         self.LOGGER.info('Created tender document {}'.format(document.id),
                     extra=context_unpack(self.request, {'MESSAGE_ID': 'tender_document_create'}, {'document_id': document.id}))
         self.request.response.status = 201
         document_route = self.request.matched_route.name.replace("collection_", "")
         self.request.response.headers['Location'] = self.request.current_route_url(_route_name=document_route, document_id=document.id, _query={})
         return {'data': document.serialize("view")}
Ejemplo n.º 57
0
 def put(self):
     """Tender Bid Document Update"""
     if self.request.validated['tender_status'] not in ['active.tendering', 'active.qualification']:
         self.request.errors.add('body', 'data', 'Can\'t update document in current ({}) tender status'.format(self.request.validated['tender_status']))
         self.request.errors.status = 403
         return
     if self.request.validated['tender_status'] == 'active.qualification' and not [i for i in self.request.validated['tender'].awards if i.status == 'pending' and i.bid_id == self.request.validated['bid_id']]:
         self.request.errors.add('body', 'data', 'Can\'t update document because award of bid is not in pending state')
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     self.request.validated['bid'].documents.append(document)
     if save_tender(self.request):
         LOGGER.info('Updated tender bid document {}'.format(self.request.context.id), extra={'MESSAGE_ID': 'tender_bid_document_put'})
         return {'data': document.serialize("view")}
 def collection_post(self):
     """Tender Document Upload"""
     if self.request.validated['tender_status'] != 'active':
         self.request.errors.add('body', 'data', 'Can\'t add document in current ({}) tender status'.format(self.request.validated['tender_status']))
         self.request.errors.status = 403
         return
     document = upload_file(self.request)
     self.request.validated['tender'].documents.append(document)
     if save_tender(self.request):
         self.LOGGER.info('Created tender document {}'.format(document.id),
                          extra=context_unpack(self.request, {'MESSAGE_ID': 'tender_document_create'}, {'document_id': document.id}))
         self.request.response.status = 201
         document_route = self.request.matched_route.name.replace("collection_", "")
         self.request.response.headers['Location'] = self.request.current_route_url(_route_name=document_route, document_id=document.id, _query={})
         return {'data': document.serialize("view")}
 def collection_post(self):
     """Tender Award Complaint Document Upload
     """
     if not self.validate_complaint_document('add'):
         return
     document = upload_file(self.request)
     document.author = self.request.authenticated_role
     self.context.documents.append(document)
     if save_tender(self.request):
         self.LOGGER.info('Created tender award complaint document {}'.format(document.id),
                     extra=context_unpack(self.request, {'MESSAGE_ID': 'tender_award_complaint_document_create'}, {'document_id': document.id}))
         self.request.response.status = 201
         document_route = self.request.matched_route.name.replace("collection_", "")
         self.request.response.headers['Location'] = self.request.current_route_url(_route_name=document_route, document_id=document.id, _query={})
         return {'data': document.serialize("view")}