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]):
             create_awards(self.request)
         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)
         }
    def collection_post(self):
        """Report auction results.

        Report auction results
        ----------------------

        Example request to report auction results:

        .. sourcecode:: http

            POST /auctions/4879d3f8ee2443169b5fbbc9f89fa607/auction HTTP/1.1
            Host: example.com
            Accept: application/json

            {
                "data": {
                    "dateModified": "2014-10-27T08:06:58.158Z",
                    "bids": [
                        {
                            "value": {
                                "amount": 400,
                                "currency": "UAH"
                            }
                        },
                        {
                            "value": {
                                "amount": 385,
                                "currency": "UAH"
                            }
                        }
                    ]
                }
            }

        This is what one should expect in response:

        .. sourcecode:: http

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

            {
                "data": {
                    "dateModified": "2014-10-27T08:06:58.158Z",
                    "bids": [
                        {
                            "value": {
                                "amount": 400,
                                "currency": "UAH",
                                "valueAddedTaxIncluded": true
                            }
                        },
                        {
                            "value": {
                                "amount": 385,
                                "currency": "UAH",
                                "valueAddedTaxIncluded": true
                            }
                        }
                    ],
                    "minimalStep":{
                        "amount": 35,
                        "currency": "UAH"
                    },
                    "tenderPeriod":{
                        "startDate": "2014-11-04T08:00:00"
                    }
                }
            }

        """
        apply_patch(self.request,
                    save=False,
                    src=self.request.validated['auction_src'])
        auction = self.request.validated['auction']
        invalidate_bids_under_threshold(auction)
        if any([i.status == 'active' for i in auction.bids]):
            create_awards(self.request)
        else:
            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)
            }