-
Notifications
You must be signed in to change notification settings - Fork 21
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
WIP: Add rectification period dgfOtherAssets #112
Changes from 3 commits
d3630a6
f9d5146
943e850
5995d9c
588c979
ceefe87
f0c1d1d
fec537e
3e2e7f5
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 |
---|---|---|
@@ -1,51 +1,49 @@ | ||
# -*- coding: utf-8 -*- | ||
from datetime import timedelta | ||
|
||
from pyramid.security import Allow | ||
from schematics.exceptions import ValidationError | ||
from schematics.transforms import whitelist | ||
from schematics.types import ( | ||
StringType, | ||
IntType, | ||
BooleanType, | ||
DateType, | ||
IntType, | ||
MD5Type, | ||
BooleanType | ||
StringType, | ||
) | ||
from schematics.types.compound import ModelType | ||
from schematics.types.serializable import serializable | ||
from urlparse import urlparse, parse_qs | ||
from string import hexdigits | ||
from zope.interface import implementer | ||
|
||
from openprocurement.auctions.core.constants import ( | ||
DGF_DECISION_REQUIRED_FROM, | ||
DGF_ELIGIBILITY_CRITERIA, | ||
DGF_ID_REQUIRED_FROM, | ||
DGF_PLATFORM_LEGAL_DETAILS, | ||
DGF_PLATFORM_LEGAL_DETAILS_FROM, | ||
DGF_ID_REQUIRED_FROM, | ||
DGF_DECISION_REQUIRED_FROM, | ||
) | ||
from openprocurement.auctions.core.includeme import IAwardingNextCheck | ||
from openprocurement.auctions.core.models import ( | ||
ListType, | ||
ComplaintModelType, | ||
IAuction, | ||
Auction as BaseAuction, | ||
Bid as BaseBid, | ||
dgfCancellation as Cancellation, | ||
dgfItem as Item, | ||
dgfDocument as Document, | ||
dgfComplaint as Complaint, | ||
ComplaintModelType, | ||
Feature, | ||
Period, | ||
FinancialOrganization, | ||
IAuction, | ||
ListType, | ||
Lot, | ||
Period, | ||
RectificationPeriod, | ||
calc_auction_end_time, | ||
dgfCancellation as Cancellation, | ||
dgfComplaint as Complaint, | ||
dgfDocument as Document, | ||
dgfItem as Item, | ||
dgf_auction_roles, | ||
get_auction, | ||
validate_features_uniq, | ||
validate_lots_uniq, | ||
validate_items_uniq, | ||
calc_auction_end_time, | ||
validate_lots_uniq, | ||
validate_not_available, | ||
FinancialOrganization | ||
) | ||
from openprocurement.auctions.core.plugins.awarding.v3.models import ( | ||
Award | ||
|
@@ -54,16 +52,19 @@ | |
Contract, | ||
) | ||
from openprocurement.auctions.core.utils import ( | ||
rounding_shouldStartAfter_after_midnigth, | ||
AUCTIONS_COMPLAINT_STAND_STILL_TIME, | ||
TZ, | ||
calculate_business_date, | ||
get_request_from_root, | ||
get_now, | ||
TZ | ||
get_request_from_root, | ||
rounding_shouldStartAfter_after_midnigth, | ||
) | ||
from openprocurement.auctions.core.validation import ( | ||
validate_disallow_dgfPlatformLegalDetails | ||
) | ||
from openprocurement.auctions.dgf.constants import ( | ||
RECTIFICATION_PERIOD_LENGTH_DAYS, | ||
) | ||
|
||
|
||
class DGFOtherBid(BaseBid): | ||
|
@@ -111,29 +112,52 @@ class IDgfFinancialAssetsAuction(IAuction): | |
|
||
@implementer(IDgfOtherAssetsAuction) | ||
class DGFOtherAssets(BaseAuction): | ||
"""Data regarding auction process - publicly inviting prospective contractors to submit bids for evaluation and selecting a winner or winners.""" | ||
"""Data regarding auction process | ||
|
||
publicly inviting prospective contractors to submit bids | ||
for evaluation and selecting a winner or winners. | ||
""" | ||
class Options: | ||
roles = dgf_auction_roles | ||
_procedure_type = "dgfOtherAssets" | ||
awards = ListType(ModelType(Award), default=list()) | ||
bids = ListType(ModelType(DGFOtherBid), default=list()) # A list of all the companies who entered submissions for the auction. | ||
# A list of all the companies who entered submissions for the auction. | ||
bids = ListType(ModelType(DGFOtherBid), default=list()) | ||
cancellations = ListType(ModelType(Cancellation), default=list()) | ||
complaints = ListType(ComplaintModelType(Complaint), default=list()) | ||
contracts = ListType(ModelType(Contract), default=list()) | ||
dgfID = StringType() | ||
merchandisingObject = MD5Type() | ||
dgfDecisionID = StringType() | ||
dgfDecisionDate = DateType() | ||
documents = ListType(ModelType(Document), default=list()) # All documents and attachments related to the auction. | ||
enquiryPeriod = ModelType(Period) # The period during which enquiries may be made and will be answered. | ||
tenderPeriod = ModelType(Period) # The period when the auction is open for submissions. The end date is the closing date for auction submissions. | ||
# All documents and attachments related to the auction. | ||
documents = ListType(ModelType(Document), default=list()) | ||
# The period during which enquiries may be made and will be answered. | ||
enquiryPeriod = ModelType(Period) | ||
# The period when the auction is open for submissions. The end date is the closing date for auction submissions. | ||
tenderPeriod = ModelType(Period) | ||
tenderAttempts = IntType(choices=[1, 2, 3, 4, 5, 6, 7, 8]) | ||
auctionPeriod = ModelType(AuctionAuctionPeriod, required=True, default={}) | ||
status = StringType(choices=['draft', 'pending.verification', 'invalid', 'active.tendering', 'active.auction', 'active.qualification', 'active.awarded', 'complete', 'cancelled', 'unsuccessful'], default='active.tendering') | ||
status = StringType( | ||
choices=[ | ||
'draft', | ||
'pending.verification', | ||
'invalid', | ||
'active.tendering', | ||
'active.auction', | ||
'active.qualification', | ||
'active.awarded', | ||
'complete', | ||
'cancelled', | ||
'unsuccessful' | ||
], | ||
default='active.tendering' | ||
) | ||
features = ListType(ModelType(Feature), validators=[validate_features_uniq, validate_not_available]) | ||
lots = ListType(ModelType(Lot), default=list(), validators=[validate_lots_uniq, validate_not_available]) | ||
items = ListType(ModelType(Item), default=list(), validators=[validate_items_uniq]) | ||
suspended = BooleanType() | ||
rectificationPeriod = ModelType(RectificationPeriod) | ||
|
||
def __acl__(self): | ||
return [ | ||
|
@@ -153,10 +177,35 @@ def get_role(self): | |
role = 'auction_{}'.format(request.method.lower()) | ||
elif request.authenticated_role == 'convoy': | ||
role = 'convoy' | ||
else: | ||
role = 'edit_{}'.format(request.context.status) | ||
else: # on PATCH of the owner | ||
self.generate_rectificationPeriod() | ||
now = get_now() | ||
if self.status == 'active.tendering': | ||
if ( | ||
now >= self.rectificationPeriod.startDate | ||
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. Точно! Я на цьому місці його і придумав, а тепер забув. |
||
and now <= self.rectificationPeriod.endDate | ||
): | ||
role = 'edit_active.tendering_during_rectificationPeriod' | ||
else: | ||
role = 'edit_active.tendering_after_rectificationPeriod' | ||
else: | ||
role = 'edit_{0}'.format(self.status) | ||
return role | ||
|
||
def generate_rectificationPeriod(self): | ||
# generate period only when it not defined | ||
if self.rectificationPeriod: | ||
return | ||
start = self.tenderPeriod.startDate | ||
period_length = timedelta(days=RECTIFICATION_PERIOD_LENGTH_DAYS) | ||
end = calculate_business_date(start, period_length, self, working_days=True) | ||
|
||
period = RectificationPeriod() | ||
period.startDate = start | ||
period.endDate = end | ||
|
||
self.rectificationPeriod = period | ||
|
||
def initialize(self): | ||
if not self.enquiryPeriod: | ||
self.enquiryPeriod = type(self).enquiryPeriod.model_class() | ||
|
@@ -176,6 +225,7 @@ def initialize(self): | |
for lot in self.lots: | ||
lot.date = now | ||
self.documents.append(type(self).documents.model_class(DGF_PLATFORM_LEGAL_DETAILS)) | ||
self.generate_rectificationPeriod() | ||
|
||
def validate_documents(self, data, docs): | ||
if (data.get('revisions')[0].date if data.get('revisions') else get_now()) > DGF_PLATFORM_LEGAL_DETAILS_FROM and \ | ||
|
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.
Тут одразу повинна бути
timedelta
i змінна тодіRECTIFICATION_PERIOD_DURATION