Skip to content

Commit

Permalink
Merge branch 'complaints'
Browse files Browse the repository at this point in the history
Conflicts:
	openprocurement/tender/openua/models.py
	openprocurement/tender/openua/utils.py
	openprocurement/tender/openua/views/tender.py
  • Loading branch information
kroman0 committed Jan 19, 2016
2 parents aa7eecb + 635dd15 commit f66ffb1
Show file tree
Hide file tree
Showing 13 changed files with 3,508 additions and 2,174 deletions.
10 changes: 10 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[run]
omit =
*tests*

[report]
exclude_lines =
pragma: no cover
def __repr__
raise NotImplementedError
if __name__ == .__main__.:
70 changes: 66 additions & 4 deletions openprocurement/tender/openua/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,23 @@
from zope.interface import implementer
from schematics.types import IntType, StringType
from schematics.types.compound import ModelType, ListType
from schematics.transforms import whitelist
from schematics.transforms import whitelist, blacklist
from openprocurement.api.models import Tender as BaseTender
from openprocurement.api.models import Bid as BaseBid
from openprocurement.api.models import Period, IsoDateTimeType
from openprocurement.api.models import Complaint as BaseComplaint
from openprocurement.api.models import Award as BaseAward
from openprocurement.api.models import (
plain_role, create_role, edit_role, cancel_role, view_role, listing_role,
auction_view_role, auction_post_role, auction_patch_role, enquiries_role,
auction_role, chronograph_role, chronograph_view_role, view_bid_role,
Administrator_bid_role, Administrator_role, schematics_default_role, get_now)
Administrator_bid_role, Administrator_role, schematics_default_role,
TZ, get_now, schematics_embedded_role,
)
from openprocurement.tender.openua.interfaces import ITenderUA
from schematics.exceptions import ConversionError, ValidationError
from openprocurement.tender.openua.utils import calculate_buisness_date
from schematics.types.serializable import serializable

def bids_validation_wrapper(validation_func):
def validator(klass, data, value):
Expand Down Expand Up @@ -126,13 +131,29 @@ def validate_parameters(self, data, parameters):
BaseBid._validator_functions['parameters'](self, data, parameters)




class PeriodStartEndRequired(Period):
startDate = IsoDateTimeType(required=True, default=get_now) # The state date for the period.
endDate = IsoDateTimeType(required=True, default=get_now) # The end date for the period.


class Complaint(BaseComplaint):
class Options:
roles = {
'create': whitelist('author', 'title', 'description', 'status'),
'draft': whitelist('author', 'title', 'description', 'status'),
'cancellation': whitelist('cancellationReason', 'status'),
'satisfy': whitelist('satisfied', 'status'),
'answer': whitelist('resolution', 'resolutionType', 'status'),
'review': whitelist('decision', 'status'),
'embedded': (blacklist('owner_token', 'owner') + schematics_embedded_role),
'view': (blacklist('owner_token', 'owner') + schematics_default_role),
}


class Award(BaseAward):
complaints = ListType(ModelType(Complaint), default=list())


@implementer(ITenderUA)
class Tender(BaseTender):
"""Data regarding tender process - publicly inviting prospective contractors to submit bids for evaluation and selecting a winner or winners."""
Expand Down Expand Up @@ -172,6 +193,8 @@ class Options:
enquiryPeriod = ModelType(PeriodStartEndRequired, required=True)
tenderPeriod = ModelType(PeriodStartEndRequired, required=True)
bids = SifterListType(ModelType(Bid), default=list(), filter_by='status', filter_in_values=['invalidBid', 'deleted']) # A list of all the companies who entered submissions for the tender.
awards = ListType(ModelType(Award), default=list())
complaints = ListType(ModelType(Complaint), default=list())
procurementMethodType = StringType(default="aboveThresholdUA")
status = StringType(choices=['active.tendering', 'active.auction', 'active.qualification', 'active.awarded', 'complete', 'cancelled', 'unsuccessful'], default='active.tendering')

Expand All @@ -189,3 +212,42 @@ def initialize(self):
if not self.tenderPeriod.startDate:
self.tenderPeriod.startDate = self.enquiryPeriod.startDate

@serializable
def next_check(self):
now = get_now()
checks = []
if self.status == 'active.enquiries' and self.tenderPeriod.startDate:
checks.append(self.tenderPeriod.startDate.astimezone(TZ))
elif self.status == 'active.enquiries' and self.enquiryPeriod.endDate:
checks.append(self.enquiryPeriod.endDate.astimezone(TZ))
elif self.status == 'active.tendering' and self.tenderPeriod.endDate:
checks.append(self.tenderPeriod.endDate.astimezone(TZ))
elif not self.lots and self.status == 'active.awarded':
standStillEnds = [
a.complaintPeriod.endDate.astimezone(TZ)
for a in self.awards
if a.complaintPeriod.endDate
]
if standStillEnds:
standStillEnd = max(standStillEnds)
if standStillEnd > now:
checks.append(standStillEnd)
elif self.lots and self.status in ['active.qualification', 'active.awarded']:
lots_ends = []
for lot in self.lots:
if lot['status'] != 'active':
continue
lot_awards = [i for i in self.awards if i.lotID == lot.id]
standStillEnds = [
a.complaintPeriod.endDate.astimezone(TZ)
for a in lot_awards
if a.complaintPeriod.endDate
]
if not standStillEnds:
continue
standStillEnd = max(standStillEnds)
if standStillEnd > now:
lots_ends.append(standStillEnd)
if lots_ends:
checks.append(min(lots_ends))
return sorted(checks)[0].isoformat() if checks else None
3 changes: 3 additions & 0 deletions openprocurement/tender/openua/tests/auth.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ chrisr = chrisr
broker = broker
broker05 = broker05

[reviewers]
reviewer = reviewer

[admins]
test = token

0 comments on commit f66ffb1

Please sign in to comment.