-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Insider Auction models and views for auction substatuses #45
base: production
Are you sure you want to change the base?
Changes from 5 commits
d70ae24
a886347
69869a5
6e862f8
a149ff3
48440fc
2a4cec5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,15 +7,18 @@ | |
save_auction, | ||
apply_patch, | ||
opresource, | ||
remove_draft_bids | ||
) | ||
from openprocurement.auctions.insider.validation import ( | ||
validate_auction_auction_data, | ||
remove_draft_bids, | ||
) | ||
from openprocurement.auctions.dgf.views.financial.auction import ( | ||
FinancialAuctionAuctionResource, | ||
) | ||
from openprocurement.auctions.insider.utils import create_awards, invalidate_empty_bids, merge_auction_results | ||
from openprocurement.auctions.insider.utils import ( | ||
create_awards, | ||
invalidate_empty_bids, | ||
merge_auction_results, | ||
) | ||
from openprocurement.auctions.insider.validation import validate_auction_auction_data | ||
from openprocurement.auctions.insider.constants import TENDER_PERIOD_STATUSES | ||
|
||
|
||
@opresource(name='dgfInsider:Auction Auction', | ||
|
@@ -27,7 +30,7 @@ class InsiderAuctionAuctionResource(FinancialAuctionAuctionResource): | |
|
||
@json_view(permission='auction') | ||
def collection_get(self): | ||
if self.request.validated['auction_status'] not in ['active.tendering', 'active.auction']: | ||
if self.request.validated['auction_status'] not in TENDER_PERIOD_STATUSES: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Хіба тобі потрібна константа There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @yarsanich, не знав як логічно виділити групу статусів, за яких в кожній з процедур можна робити GET запити до аукціону. |
||
self.request.errors.add('body', 'data', 'Can\'t get auction info in current ({}) auction status'.format( | ||
self.request.validated['auction_status'])) | ||
self.request.errors.status = 403 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from openprocurement.api.models import get_now | ||
from openprocurement.api.utils import ( | ||
json_view, | ||
context_unpack, | ||
set_ownership, | ||
) | ||
from openprocurement.auctions.core.utils import ( | ||
opresource, | ||
apply_patch, | ||
save_auction, | ||
) | ||
from openprocurement.auctions.core.validation import ( | ||
validate_bid_data, | ||
validate_patch_bid_data, | ||
) | ||
from openprocurement.auctions.dgf.views.financial.bid import ( | ||
FinancialAuctionBidResource, | ||
) | ||
|
||
from openprocurement.api.utils import ( | ||
json_view, | ||
context_unpack, | ||
set_ownership | ||
) | ||
from openprocurement.api.models import get_now | ||
from openprocurement.auctions.core.validation import validate_bid_data, validate_patch_bid_data | ||
from openprocurement.auctions.insider.constants import TENDER_PERIOD_STATUSES | ||
|
||
|
||
@opresource(name='dgfInsider:Auction Bids', | ||
collection_path='/auctions/{auction_id}/bids', | ||
path='/auctions/{auction_id}/bids/{bid_id}', | ||
|
@@ -138,6 +140,88 @@ def collection_post(self): | |
} | ||
} | ||
|
||
@json_view(permission='view_auction') | ||
def collection_get(self): | ||
"""Bids Listing | ||
|
||
Get Bids List | ||
------------- | ||
|
||
Example request to get bids list: | ||
|
||
.. sourcecode:: http | ||
|
||
GET /auctions/4879d3f8ee2443169b5fbbc9f89fa607/bids HTTP/1.1 | ||
Host: example.com | ||
Accept: application/json | ||
|
||
This is what one should expect in response: | ||
|
||
.. sourcecode:: http | ||
|
||
HTTP/1.1 200 OK | ||
Content-Type: application/json | ||
|
||
{ | ||
"data": [ | ||
{ | ||
"value": { | ||
"amount": 489, | ||
"currency": "UAH", | ||
"valueAddedTaxIncluded": true | ||
} | ||
} | ||
] | ||
} | ||
|
||
""" | ||
auction = self.request.validated['auction'] | ||
if self.request.validated['auction_status'] in TENDER_PERIOD_STATUSES: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Знову ж таки валідатор. |
||
self.request.errors.add('body', 'data', 'Can\'t view bids in current ({}) auction status'.format( | ||
self.request.validated['auction_status'])) | ||
self.request.errors.status = 403 | ||
return | ||
return {'data': [i.serialize(self.request.validated['auction_status']) for i in auction.bids]} | ||
|
||
@json_view(permission='view_auction') | ||
def get(self): | ||
"""Retrieving the proposal | ||
|
||
Example request for retrieving the proposal: | ||
|
||
.. sourcecode:: http | ||
|
||
GET /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": 600, | ||
"currency": "UAH", | ||
"valueAddedTaxIncluded": true | ||
} | ||
} | ||
} | ||
|
||
""" | ||
if self.request.authenticated_role == 'bid_owner': | ||
return {'data': self.request.context.serialize('view')} | ||
if self.request.validated['auction_status'] in TENDER_PERIOD_STATUSES: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Винеси у валідатор. |
||
self.request.errors.add('body', 'data', 'Can\'t view bid in current ({}) auction status'.format( | ||
self.request.validated['auction_status'])) | ||
self.request.errors.status = 403 | ||
return | ||
return {'data': self.request.context.serialize(self.request.validated['auction_status'])} | ||
|
||
@json_view(content_type="application/json", permission='edit_bid', validators=(validate_patch_bid_data,)) | ||
def patch(self): | ||
"""Update of proposal | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,12 @@ | |
|
||
from openprocurement.auctions.core.utils import ( | ||
opresource, | ||
add_next_award, | ||
) | ||
from openprocurement.auctions.dgf.views.financial.cancellation import ( | ||
FinancialAuctionCancellationResource, | ||
) | ||
from openprocurement.auctions.insider.constants import TENDER_PERIOD_STATUSES | ||
|
||
|
||
@opresource(name='dgfInsider:Auction Cancellations', | ||
|
@@ -14,4 +16,29 @@ | |
auctionsprocurementMethodType="dgfInsider", | ||
description="Insider auction cancellations") | ||
class InsiderAuctionCancellationResource(FinancialAuctionCancellationResource): | ||
pass | ||
|
||
def cancel_auction(self): | ||
auction = self.request.validated['auction'] | ||
if auction.status in TENDER_PERIOD_STATUSES: | ||
auction.bids = [] | ||
auction.status = 'cancelled' | ||
|
||
def cancel_lot(self, cancellation=None): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Що змінилося у There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Пропоную то все винести в окрему функцію, або у валідатор і змінити самі views з використанням валідатору, щоб не копіювати кучу коду, якщо таке можливо звичайно. |
||
|
||
if not cancellation: | ||
cancellation = self.context | ||
auction = self.request.validated['auction'] | ||
[setattr(i, 'status', 'cancelled') for i in auction.lots if i.id == cancellation.relatedLot] | ||
statuses = set([lot.status for lot in auction.lots]) | ||
if statuses == set(['cancelled']): | ||
self.cancel_auction() | ||
elif not statuses.difference(set(['unsuccessful', 'cancelled'])): | ||
auction.status = 'unsuccessful' | ||
elif not statuses.difference(set(['complete', 'unsuccessful', 'cancelled'])): | ||
auction.status = 'complete' | ||
if 'active.auction' in auction.status and all([ | ||
i.auctionPeriod and i.auctionPeriod.endDate | ||
for i in self.request.validated['auction'].lots | ||
if i.numberOfBids > 1 and i.status == 'active' | ||
]): | ||
add_next_award(self.request) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я б ці підстатуси розідлив. Бо
active.tendering
наприклад - це статус процедури, аactive.auction.dutch
то є підстатус аукціону. А константа за це відповідає однаTENDER_PREIOD_STATUSES
не дуже логічно.