Skip to content

Commit

Permalink
Implement new awarding
Browse files Browse the repository at this point in the history
  • Loading branch information
yshalenyk committed May 22, 2020
1 parent d643527 commit 099ef1b
Show file tree
Hide file tree
Showing 14 changed files with 243 additions and 98 deletions.
21 changes: 21 additions & 0 deletions src/openprocurement/tender/pricequotation/models/award.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from openprocurement.api.models import\
schematics_default_role, schematics_embedded_role
from openprocurement.tender.core.models import BaseAward
from openprocurement.tender.pricequotation.utils import get_bid_owned_award_acl


class Award(BaseAward):
Expand All @@ -18,9 +19,29 @@ class Options:
"status", "title", "title_en", "title_ru",
"description", "description_en", "description_ru"
),
"edit_tender_owner": whitelist(
"status", "title", "title_en", "title_ru",
"description", "description_en", "description_ru"
),
"edit_bid_owner": whitelist(
"status", "title", "title_en", "title_ru",
"description", "description_en", "description_ru"
),
"embedded": schematics_embedded_role,
"view": schematics_default_role,
"Administrator": whitelist(),
}

bid_id = MD5Type(required=True)

def __acl__(self):
return get_bid_owned_award_acl(self)

def get_role(self):
root = self.get_root()
request = root.request
if request.authenticated_role in ("tender_owner", "bid_owner"):
role = "edit_{}".format(request.authenticated_role)
else:
role = request.authenticated_role
return role
33 changes: 27 additions & 6 deletions src/openprocurement/tender/pricequotation/models/tender.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from schematics.types import IntType, StringType
from schematics.types.compound import ModelType
from schematics.types.serializable import serializable
from pyramid.security import Allow
from zope.interface import implementer
from openprocurement.api.constants import TZ, CPV_ITEMS_CLASS_FROM
from openprocurement.api.models import\
Expand Down Expand Up @@ -81,7 +82,6 @@ class Options:
"tenderPeriod",
"procuringEntity",
"guarantee",
"value",
"minimalStep",
)
_edit_role = _core_roles["edit"] \
Expand All @@ -92,12 +92,16 @@ class Options:
"profile"
)
_create_role = _core_roles["create"] + _edit_role
_edit_pq_bot_role = whitelist("items", "shortlistedFirms", "status", "criteria", "value")
_edit_pq_bot_role = whitelist(
"items", "shortlistedFirms",
"status", "criteria", "value",
)
_view_tendering_role = (
_core_roles["view"]
+ _edit_fields
+ whitelist(
"awards",
'value',
"awardPeriod",
"cancellations",
"contracts",
Expand All @@ -113,7 +117,7 @@ class Options:
"edit": _edit_role,
"edit_draft": _edit_role,
"edit_draft.unsuccessful": _edit_role,
"edit_draft.publishing": _all_forbidden,
"edit_draft.publishing": _edit_pq_bot_role,
"edit_active.tendering": _all_forbidden,
"edit_active.qualification": _all_forbidden,
"edit_active.awarded": _all_forbidden,
Expand Down Expand Up @@ -161,7 +165,7 @@ class Options:
validators=[validate_items_uniq],
)
# The total estimated value of the procurement.
value = ModelType(Value, required=True)
value = ModelType(Value)
# The period when the tender is open for submissions.
# The end date is the closing date for tender submissions.
tenderPeriod = ModelType(
Expand Down Expand Up @@ -211,8 +215,6 @@ def get_role(self):
if request.authenticated_role in\
("Administrator", "chronograph", "contracting", "bots"):
role = request.authenticated_role
elif request.authenticated_role == "auction":
role = "auction_{}".format(request.method.lower())
else:
role = "edit_{}".format(request.context.status)
return role
Expand All @@ -225,6 +227,12 @@ def next_check(self):

if self.status.startswith("active"):
for award in self.awards:
if award.status == 'pending':
checks.append(
calculate_tender_business_date(award.date,
timedelta(days=2),
self)
)
if award.status == "active" and not\
any([i.awardID == award.id for i in self.contracts]):
checks.append(award.date)
Expand Down Expand Up @@ -271,3 +279,16 @@ def validate_tenderPeriod(self, data, period):
and period.endDate < calculate_tender_business_date(period.startDate, timedelta(days=2), data, True)
):
raise ValidationError(u"the tenderPeriod cannot end earlier than 2 business days after the start")

def __local_roles__(self):
roles = dict([("{}_{}".format(self.owner, self.owner_token), "tender_owner")])
for i in self.bids:
roles["{}_{}".format(i.owner, i.owner_token)] = "bid_owner"
return roles

def __acl__(self):
acl = [
(Allow, "g:bots", "upload_award_documents"),
]
self._acl_cancellation(acl)
return acl
4 changes: 3 additions & 1 deletion src/openprocurement/tender/pricequotation/tests/award.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
patch_tender_award,
# patch_tender_award_unsuccessful,
get_tender_award,
# TenderLotAwardCheckResourceTest
check_tender_award,
check_tender_award_disqualification,
# TenderAwardDocumentResourceTest
not_found_award_document,
create_tender_award_document,
Expand Down Expand Up @@ -51,10 +51,12 @@ class TenderAwardDocumentResourceTestMixin(object):
class TenderAwardResourceTest(TenderContentWebTest, TenderAwardResourceTestMixin):
initial_status = "active.qualification"
initial_bids = test_bids
maxAwards = 1

test_create_tender_award = snitch(create_tender_award)
test_patch_tender_award = snitch(patch_tender_award)
test_check_tender_award = snitch(check_tender_award)
test_check_tender_award_disqualification = snitch(check_tender_award_disqualification)


class TenderAwardResourceScaleTest(TenderContentWebTest):
Expand Down
Loading

0 comments on commit 099ef1b

Please sign in to comment.