Ejemplo n.º 1
0
    def collection_post(self):
        """Post a question
        """
        save = None

        manager = self.request.registry.queryMultiAdapter(
            (self.request, self.context), IAuctionManager)

        question = manager.add_question()
        if question:
            save = manager.save()

        if save:
            msg = 'Created auction question {}'.format(question['id'])
            extra = context_unpack(self.request,
                                   {'MESSAGE_ID': 'auction_question_create'},
                                   {'document_id': question['id']})
            self.LOGGER.info(msg, extra=extra)

            self.request.response.status = 201

            route = self.request.matched_route.name.replace("collection_", "")
            location = self.request.current_route_url(
                _route_name=route, question_id=question['id'], _query={})
            self.request.response.headers['Location'] = location
            return {'data': question.serialize("view")}
 def patch(self):
     """Post an Answer
     """
     auction = self.request.validated['auction']
     if auction.status != 'active.tendering':
         self.request.errors.add(
             'body', 'data',
             'Can\'t update question 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.request.context.relatedItem
     ]):
         self.request.errors.add(
             'body', 'data',
             'Can update question only in active lot status')
         self.request.errors.status = 403
         return
     if apply_patch(self.request, src=self.request.context.serialize()):
         self.LOGGER.info(
             'Updated auction question {}'.format(self.request.context.id),
             extra=context_unpack(self.request,
                                  {'MESSAGE_ID': 'auction_question_patch'}))
         return {'data': self.request.context.serialize(auction.status)}
    def collection_post(self):
        """Auction Document Upload"""
        save = None

        manager = self.request.registry.queryMultiAdapter(
            (self.request, self.context), IManager)

        applicant = self.request.validated.get(
            'document', self.request.validated.get('file'))
        document = manager.create(applicant)

        if document:
            save = manager.save()

        if save:
            msg = 'Created auction document {}'.format(document.id)
            extra = context_unpack(self.request,
                                   {'MESSAGE_ID': 'auction_document_create'},
                                   {'document_id': document['id']})
            self.LOGGER.info(msg, extra=extra)

            self.request.response.status = 201

            route = self.request.matched_route.name.replace("collection_", "")
            locations = self.request.current_route_url(_route_name=route,
                                                       document_id=document.id,
                                                       _query={})
            self.request.response.headers['Location'] = locations
            return {'data': document.serialize("view")}
 def collection_post(self):
     """Post a question
     """
     auction = self.request.validated['auction']
     if auction.status != 'active.tendering' or get_now(
     ) < auction.enquiryPeriod.startDate or get_now(
     ) > auction.enquiryPeriod.endDate:
         self.request.errors.add('body', 'data',
                                 'Can add question only in enquiryPeriod')
         self.request.errors.status = 403
         return
     question = self.request.validated['question']
     if any([
             i.status != 'active' for i in auction.lots
             if i.id == question.relatedItem
     ]):
         self.request.errors.add(
             'body', 'data', 'Can add question only in active lot status')
         self.request.errors.status = 403
         return
     auction.questions.append(question)
     if save_auction(self.request):
         self.LOGGER.info(
             'Created auction question {}'.format(question.id),
             extra=context_unpack(self.request,
                                  {'MESSAGE_ID': 'auction_question_create'},
                                  {'question_id': question.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, question_id=question.id, _query={})
         return {'data': question.serialize("view")}
 def patch(self):
     self.request.registry.getAdapter(
         self.context, IAuctionManager).change_auction(self.request)
     auction = self.context
     if self.request.authenticated_role != 'Administrator' and auction.status in [
             'complete', 'unsuccessful', 'cancelled'
     ]:
         self.request.errors.add(
             'body', 'data',
             'Can\'t update auction in current ({}) status'.format(
                 auction.status))
         self.request.errors.status = 403
         return
     if self.request.authenticated_role == 'chronograph' and not auction.suspended:
         apply_patch(self.request,
                     save=False,
                     src=self.request.validated['auction_src'])
         check_status(self.request)
         save_auction(self.request)
     else:
         apply_patch(self.request,
                     save=False,
                     src=self.request.validated['auction_src'])
         if self.request.authenticated_role == 'auction_owner':
             invalidate_bids_data(self.request.context)
         save_auction(self.request)
     self.LOGGER.info('Updated auction {}'.format(auction.id),
                      extra=context_unpack(self.request,
                                           {'MESSAGE_ID': 'auction_patch'}))
     return {'data': auction.serialize(auction.status)}
Ejemplo n.º 6
0
 def collection_post(self):
     """Post a complaint
     """
     auction = self.context
     if auction.status not in ['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):
     """Auction Document Upload"""
     if self.request.authenticated_role != 'auction' and self.request.validated['auction_status'] != 'active.tendering' 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 add document in current ({}) auction status'.format(
                 self.request.validated['auction_status']))
         self.request.errors.status = 403
         return
     document = dgf_upload_file(self.request)
     self.context.documents.append(document)
     if save_auction(self.request):
         self.LOGGER.info(
             'Created auction document {}'.format(document.id),
             extra=context_unpack(self.request,
                                  {'MESSAGE_ID': 'auction_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 = self.context.serialize()
     adapter = self.request.registry.getAdapter(self.context,
                                                IAuctionManager)
     merge_auction_results(auction, self.request)
     apply_patch(self.request,
                 save=False,
                 src=self.request.validated['auction_src'])
     remove_draft_bids(self.request)
     auction = self.request.validated['auction']
     invalidate_empty_bids(auction)
     if any([i.status == 'active' for i in auction.bids]):
         self.request.content_configurator.start_awarding()
     else:
         adapter.pendify_auction_status('unsuccessful')
     if save_auction(self.request):
         self.LOGGER.info(
             'Report auction results',
             extra=context_unpack(self.request,
                                  {'MESSAGE_ID': 'auction_auction_post'}))
         return {
             'data':
             self.request.validated['auction'].serialize(
                 self.request.validated['auction'].status)
         }
Ejemplo n.º 9
0
 def patch(self):
     """Auction 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.tendering', 'active.auction', '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 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
     if apply_patch(self.request, src=self.request.context.serialize()):
         update_file_content_type(self.request)
         self.LOGGER.info(
             'Updated auction complaint document {}'.format(
                 self.request.context.id),
             extra=context_unpack(
                 self.request,
                 {'MESSAGE_ID': 'auction_complaint_document_patch'}))
         return {'data': self.request.context.serialize("view")}
 def collection_post(self):
     """Auction Document Upload"""
     if not self.validate_document_editing_period('add'):
         return
     document = upload_file(self.request)
     if self.request.authenticated_role != "auction":
         if not self.request.auction.rectificationPeriod:
             self.request.auction.rectificationPeriod = generate_rectificationPeriod(
                 self.request.auction)
         invalidate_bids_data(self.request.auction)
     self.context.documents.append(document)
     if save_auction(self.request):
         self.LOGGER.info(
             'Created auction document {}'.format(document.id),
             extra=context_unpack(self.request,
                                  {'MESSAGE_ID': 'auction_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 patch(self):
     """Post a complaint resolution
     """
     auction = self.request.validated['auction']
     if auction.status not in ['active.tendering', 'active.auction', 'active.qualification', 'active.awarded']:
         self.request.errors.add('body', 'data', 'Can\'t update complaint in current ({}) auction status'.format(auction.status))
         self.request.errors.status = 403
         return
     if self.context.status not in ['draft', 'claim', 'answered', 'pending']:
         self.request.errors.add('body', 'data', 'Can\'t update complaint in current ({}) status'.format(self.context.status))
         self.request.errors.status = 403
         return
     data = self.request.validated['data']
     # complaint_owner
     if self.request.authenticated_role == 'complaint_owner' and self.context.status in ['draft', 'claim', 'answered', 'pending'] and data.get('status', self.context.status) == 'cancelled':
         apply_patch(self.request, save=False, src=self.context.serialize())
         self.context.dateCanceled = get_now()
     elif self.request.authenticated_role == 'complaint_owner' and auction.status in ['active.tendering'] and self.context.status == 'draft' and data.get('status', self.context.status) == self.context.status:
         apply_patch(self.request, save=False, src=self.context.serialize())
     elif self.request.authenticated_role == 'complaint_owner' and auction.status in ['active.tendering'] and self.context.status == 'draft' and data.get('status', self.context.status) == 'claim':
         apply_patch(self.request, save=False, src=self.context.serialize())
         self.context.dateSubmitted = get_now()
     elif self.request.authenticated_role == 'complaint_owner' and self.context.status == 'answered' and data.get('status', self.context.status) == self.context.status:
         apply_patch(self.request, save=False, src=self.context.serialize())
     elif self.request.authenticated_role == 'complaint_owner' and self.context.status == 'answered' and data.get('satisfied', self.context.satisfied) is True and data.get('status', self.context.status) == 'resolved':
         apply_patch(self.request, save=False, src=self.context.serialize())
     elif self.request.authenticated_role == 'complaint_owner' and self.context.status == 'answered' and data.get('satisfied', self.context.satisfied) is False and data.get('status', self.context.status) == 'pending':
         apply_patch(self.request, save=False, src=self.context.serialize())
         self.context.type = 'complaint'
         self.context.dateEscalated = get_now()
     elif self.request.authenticated_role == 'auction_owner' and self.context.status == 'claim' and data.get('status', self.context.status) == self.context.status:
         apply_patch(self.request, save=False, src=self.context.serialize())
     elif self.request.authenticated_role == 'auction_owner' and self.context.status == 'claim' and data.get('resolution', self.context.resolution) and data.get('resolutionType', self.context.resolutionType) and data.get('status', self.context.status) == 'answered':
         if len(data.get('resolution', self.context.resolution)) < 20:
             self.request.errors.add('body', 'data', 'Can\'t update complaint: resolution too short')
             self.request.errors.status = 403
             return
         apply_patch(self.request, save=False, src=self.context.serialize())
         self.context.dateAnswered = get_now()
     elif self.request.authenticated_role == 'auction_owner' and self.context.status == 'pending':
         apply_patch(self.request, save=False, src=self.context.serialize())
     # reviewers
     elif self.request.authenticated_role == 'reviewers' and self.context.status == 'pending' and data.get('status', self.context.status) == self.context.status:
         apply_patch(self.request, save=False, src=self.context.serialize())
     elif self.request.authenticated_role == 'reviewers' and self.context.status == 'pending' and data.get('status', self.context.status) in ['resolved', 'invalid', 'declined']:
         apply_patch(self.request, save=False, src=self.context.serialize())
         self.context.dateDecision = get_now()
     else:
         self.request.errors.add('body', 'data', 'Can\'t update complaint')
         self.request.errors.status = 403
         return
     if self.context.tendererAction and not self.context.tendererActionDate:
         self.context.tendererActionDate = get_now()
     if self.context.status not in ['draft', 'claim', 'answered', 'pending'] and auction.status in ['active.qualification', 'active.awarded']:
         check_auction_status(self.request)
     if save_auction(self.request):
         self.LOGGER.info('Updated auction complaint {}'.format(self.context.id),
                     extra=context_unpack(self.request, {'MESSAGE_ID': 'auction_complaint_patch'}))
         return {'data': self.context.serialize("view")}
Ejemplo n.º 12
0
    def delete(self):
        """Cancelling the proposal

        Example request for cancelling the proposal:

        .. sourcecode:: http

            DELETE /auctions/4879d3f8ee2443169b5fbbc9f89fa607/bids/71b6c23ed8944d688e92a31ec8c3f61a HTTP/1.1
            Host: example.com
            Accept: application/json

        And here is the response to be expected:

        .. sourcecode:: http

            HTTP/1.0 200 OK
            Content-Type: application/json

            {
                "data": {
                    "value": {
                        "amount": 489,
                        "currency": "UAH",
                        "valueAddedTaxIncluded": true
                    }
                }
            }

        """
        bid = self.request.context
        if self.request.validated['auction_status'] != 'active.tendering':
            self.request.errors.add(
                'body', 'data',
                'Can\'t delete bid in current ({}) auction status'.format(
                    self.request.validated['auction_status']))
            self.request.errors.status = 403
            return
        auction = self.request.validated['auction']
        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 deleted 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
        res = bid.serialize("view")
        self.request.validated['auction'].bids.remove(bid)
        self.request.validated['auction'].modified = False
        if save_auction(self.request):
            self.LOGGER.info(
                'Deleted auction bid {}'.format(self.request.context.id),
                extra=context_unpack(self.request,
                                     {'MESSAGE_ID': 'auction_bid_delete'}))
            return {'data': res}
Ejemplo n.º 13
0
 def patch(self):
     if apply_patch(self.request, src=self.request.context.serialize()):
         update_file_content_type(self.request)
         self.LOGGER.info(
             'Updated lot item {}'.format(self.request.context.id),
             extra=context_unpack(self.request,
                                  {'MESSAGE_ID': 'lot_item_patch'}))
         return {'data': self.request.context.serialize("view")}
 def patch(self):
     """Lot Item Update"""
     if apply_patch(self.request, src=self.request.context.serialize()):
         self.LOGGER.info(
             'Updated lot item {}'.format(self.request.context.id),
             extra=context_unpack(self.request,
                                  {'MESSAGE_ID': 'auction_item_patch'}))
         return {'data': self.request.context.serialize("view")}
Ejemplo n.º 15
0
def check_auction_status(request):
    auction = request.validated['auction']
    if auction.awards:
        awards_statuses = set([award.status for award in auction.awards])
    else:
        awards_statuses = set([""])
    if not awards_statuses.difference(set(['unsuccessful', 'cancelled'])):
        LOGGER.info('Switched auction {} to {}'.format(auction.id,
                                                       'unsuccessful'),
                    extra=context_unpack(
                        request,
                        {'MESSAGE_ID': 'switched_auction_unsuccessful'}))
        auction.status = 'unsuccessful'
    if auction.contracts and auction.contracts[-1].status == 'active':
        LOGGER.info('Switched auction {} to {}'.format(auction.id, 'complete'),
                    extra=context_unpack(
                        request, {'MESSAGE_ID': 'switched_auction_complete'}))
        auction.status = 'complete'
Ejemplo n.º 16
0
    def post(self):
        manager = self.request.registry.queryMultiAdapter((self.request, self.context), IManager)

        manager.report()

        if manager.save():
            extra = context_unpack(self.request, {'MESSAGE_ID': 'auction_auction_post'})
            self.LOGGER.info('Report auction results', extra=extra)
            return {'data': self.request.validated['auction'].serialize("auction_view")}
Ejemplo n.º 17
0
    def patch(self):
        manager = self.request.registry.queryMultiAdapter((self.request, self.context), IManager)

        manager.change()
        save = manager.save()

        if save:
            extra = context_unpack(self.request, {'MESSAGE_ID': 'auction_auction_patch'})
            self.LOGGER.info('Updated auction urls', extra=extra)
            return {'data': self.request.validated['auction'].serialize("auction_view")}
 def patch(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
     if apply_patch(self.request, src=self.request.context.serialize()):
         update_file_content_type(self.request)
         self.LOGGER.info('Updated auction cancellation document {}'.format(self.request.context.id),
                     extra=context_unpack(self.request, {'MESSAGE_ID': 'auction_cancellation_document_patch'}))
         return {'data': self.request.context.serialize("view")}
 def patch(self):
     """Update of lot
     """
     auction = self.request.validated['auction']
     if auction.status not in ['active.tendering']:
         self.request.errors.add('body', 'data', 'Can\'t update lot in current ({}) auction status'.format(auction.status))
         self.request.errors.status = 403
         return
     if apply_patch(self.request, src=self.request.context.serialize()):
         self.LOGGER.info('Updated auction lot {}'.format(self.request.context.id),
                     extra=context_unpack(self.request, {'MESSAGE_ID': 'auction_lot_patch'}))
         return {'data': self.request.context.serialize("view")}
Ejemplo n.º 20
0
    def patch(self):
        """Lot Item Update"""

        if self.request.authenticated_role == 'auction_owner':
            invalidate_bids_data(self.request.auction)

        if apply_patch(self.request, src=self.request.context.serialize()):
            self.LOGGER.info(
                'Updated lot item {}'.format(self.request.context.id),
                extra=context_unpack(self.request, {'MESSAGE_ID': 'auction_item_patch'})
            )
            return {'data': self.request.context.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.º 22
0
def remove_invalid_bids(request):
    auction = request.validated['auction']
    if [
            bid for bid in auction.bids
            if getattr(bid, "status", "active") == "invalid"
    ]:
        LOGGER.info('Remove invalid bids',
                    extra=context_unpack(
                        request, {'MESSAGE_ID': 'remove_invalid_bids'}))
        auction.bids = [
            bid for bid in auction.bids
            if getattr(bid, "status", "active") != "invalid"
        ]
Ejemplo n.º 23
0
 def collection_patch(self):
     """Set urls for access to auction.
     """
     if apply_patch(self.request,
                    src=self.request.validated['auction_src']):
         self.LOGGER.info(
             'Updated auction urls',
             extra=context_unpack(self.request,
                                  {'MESSAGE_ID': 'auction_auction_patch'}))
         return {
             'data':
             self.request.validated['auction'].serialize("auction_view")
         }
Ejemplo n.º 24
0
    def patch(self):
        manager = self.request.registry.queryMultiAdapter(
            (self.request, self.context), IManager)

        manager.change()
        save = manager.save()

        if save:
            extra = context_unpack(self.request,
                                   {'MESSAGE_ID': 'auction_patch'})
            self.LOGGER.info('Updated auction {}'.format(self.context.id),
                             extra=extra)
            return {'data': self.context.serialize(self.context.status)}
    def patch(self):
        """Auction Document Update"""
        save = None

        manager = self.request.registry.queryMultiAdapter((self.request, self.context), IDocumentManager)

        manager.change()
        save = manager.save()

        if save:
            extra = context_unpack(self.request, {'MESSAGE_ID': 'auction_document_patch'})
            msg = 'Updated auction document {}'.format(self.request.context.id)
            self.LOGGER.info(msg, extra=extra)
            return {'data': self.request.context.serialize("view")}
Ejemplo n.º 26
0
 def patch(self):
     """Auction Bid Document Update"""
     if not self.validate_bid_document('update'):
         return
     if self.request.validated['auction_status'] == 'active.tendering':
         self.request.validated['auction'].modified = False
     if apply_patch(self.request, src=self.request.context.serialize()):
         update_file_content_type(self.request)
         self.LOGGER.info('Updated auction bid document {}'.format(
             self.request.context.id),
                          extra=context_unpack(
                              self.request,
                              {'MESSAGE_ID': 'auction_bid_document_patch'}))
         return {'data': self.request.context.serialize("view")}
Ejemplo n.º 27
0
 def put(self):
     """Auction Document Update"""  # TODO rm black box
     if not self.validate_document_editing_period('update'):
         return
     document = upload_file(self.request)
     if self.request.authenticated_role != "auction":
         invalidate_bids_data(self.request.auction)
     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")}
 def delete(self):
     """Lot deleting
     """
     auction = self.request.validated['auction']
     if auction.status not in ['active.tendering']:
         self.request.errors.add('body', 'data', 'Can\'t delete lot in current ({}) auction status'.format(auction.status))
         self.request.errors.status = 403
         return
     lot = self.request.context
     res = lot.serialize("view")
     auction.lots.remove(lot)
     if save_auction(self.request):
         self.LOGGER.info('Deleted auction lot {}'.format(self.request.context.id),
                     extra=context_unpack(self.request, {'MESSAGE_ID': 'auction_lot_delete'}))
         return {'data': res}
Ejemplo n.º 29
0
 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")}
Ejemplo n.º 30
0
 def post(self):
     """Report auction results for lot.
     """
     apply_patch(self.request, save=False, src=self.request.validated['auction_src'])
     auction = self.request.validated['auction']
     if all([i.auctionPeriod and i.auctionPeriod.endDate for i in auction.lots if i.numberOfBids > 1 and i.status == 'active']):
         cleanup_bids_for_cancelled_lots(auction)
         invalidate_bids_under_threshold(auction)
         if any([i.status == 'active' for i in auction.bids]):
             self.request.content_configurator.start_awarding()
         else:
             auction.status = 'unsuccessful'
     if save_auction(self.request):
         self.LOGGER.info('Report auction results', extra=context_unpack(self.request, {'MESSAGE_ID': 'auction_lot_auction_post'}))
         return {'data': self.request.validated['auction'].serialize(self.request.validated['auction'].status)}