-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable changing of enquiry period, support new awarding
- Loading branch information
Showing
5 changed files
with
347 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
# -*- coding: utf-8 -*- | ||
from logging import getLogger | ||
from openprocurement.api.utils import ( | ||
save_tender, | ||
apply_patch, | ||
opresource, | ||
json_view, | ||
context_unpack, | ||
) | ||
from openprocurement.api.validation import ( | ||
validate_tender_auction_data, | ||
) | ||
from openprocurement.api.views.auction import TenderAuctionResource | ||
|
||
from openprocurement.tender.openua.utils import add_next_award | ||
|
||
LOGGER = getLogger(__name__) | ||
|
||
|
||
@opresource(name='Tender UA Auction', | ||
collection_path='/tenders/{tender_id}/auction', | ||
path='/tenders/{tender_id}/auction/{auction_lot_id}', | ||
procurementMethodType='aboveThresholdUA', | ||
description="Tender UA auction data") | ||
class TenderUaAuctionResource(TenderAuctionResource): | ||
|
||
@json_view(content_type="application/json", permission='auction', validators=(validate_tender_auction_data)) | ||
def collection_post(self): | ||
"""Report auction results. | ||
Report auction results | ||
---------------------- | ||
Example request to report auction results: | ||
.. sourcecode:: http | ||
POST /tenders/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['tender_src']) | ||
if all([i.auctionPeriod and i.auctionPeriod.endDate for i in self.request.validated['tender'].lots if i.numberOfBids > 1]): | ||
add_next_award(self.request) | ||
if save_tender(self.request): | ||
LOGGER.info('Report auction results', extra=context_unpack(self.request, {'MESSAGE_ID': 'tender_auction_post'})) | ||
return {'data': self.request.validated['tender'].serialize(self.request.validated['tender'].status)} | ||
|
||
@json_view(content_type="application/json", permission='auction', validators=(validate_tender_auction_data)) | ||
def patch(self): | ||
"""Set urls for access to auction for lot. | ||
""" | ||
if apply_patch(self.request, src=self.request.validated['tender_src']): | ||
LOGGER.info('Updated auction urls', extra=context_unpack(self.request, {'MESSAGE_ID': 'tender_lot_auction_patch'})) | ||
return {'data': self.request.validated['tender'].serialize("auction_view")} | ||
|
||
@json_view(content_type="application/json", permission='auction', validators=(validate_tender_auction_data)) | ||
def post(self): | ||
"""Report auction results for lot. | ||
""" | ||
apply_patch(self.request, save=False, src=self.request.validated['tender_src']) | ||
if all([i.auctionPeriod and i.auctionPeriod.endDate for i in self.request.validated['tender'].lots if i.numberOfBids > 1]): | ||
add_next_award(self.request) | ||
if save_tender(self.request): | ||
LOGGER.info('Report auction results', extra=context_unpack(self.request, {'MESSAGE_ID': 'tender_lot_auction_post'})) | ||
return {'data': self.request.validated['tender'].serialize(self.request.validated['tender'].status)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters