Skip to content

Commit

Permalink
merge a149761705666692_fix_periods into production
Browse files Browse the repository at this point in the history
  • Loading branch information
ktarasz committed Jul 4, 2016
2 parents b0ef87a + eee988f commit abe8fd9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
16 changes: 11 additions & 5 deletions openprocurement/tender/openuadefense/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from schematics.types.compound import ModelType
from schematics.types.serializable import serializable
from zope.interface import implementer
from openprocurement.api.models import ITender, Period, get_now
from openprocurement.api.models import ITender, Period, get_now,TZ
from openprocurement.tender.openua.models import (
Tender as BaseTender, EnquiryPeriod, Lot as BaseLot, get_tender, calc_auction_end_time, validate_lots_uniq,
)
Expand All @@ -16,8 +16,10 @@

STAND_STILL_TIME = timedelta(days=4)
ENQUIRY_STAND_STILL_TIME = timedelta(days=2)
CLAIM_SUBMIT_TIME = timedelta(days=2)
COMPLAINT_SUBMIT_TIME = timedelta(days=3)
CLAIM_SUBMIT_TIME = timedelta(days=3)
COMPLAINT_SUBMIT_TIME = timedelta(days=2)
COMPLAINT_OLD_SUBMIT_TIME = timedelta(days=3)
COMPLAINT_OLD_SUBMIT_TIME_BEFORE = datetime(2016, 7, 5, tzinfo=TZ)
TENDER_PERIOD = timedelta(days=6)
ENQUIRY_PERIOD_TIME = timedelta(days=3)
TENDERING_EXTRA_PERIOD = timedelta(days=2)
Expand Down Expand Up @@ -81,5 +83,9 @@ def validate_tenderPeriod(self, data, period):

@serializable(type=ModelType(Period))
def complaintPeriod(self):
return Period(dict(startDate=self.tenderPeriod.startDate,
endDate=calculate_business_date(self.tenderPeriod.endDate, -COMPLAINT_SUBMIT_TIME, self)))
if self.tenderPeriod.startDate < COMPLAINT_OLD_SUBMIT_TIME_BEFORE:
return Period(dict(startDate=self.tenderPeriod.startDate,
endDate=calculate_business_date(self.tenderPeriod.endDate, -COMPLAINT_OLD_SUBMIT_TIME, self)))
else:
return Period(dict(startDate=self.tenderPeriod.startDate,
endDate=calculate_business_date(self.tenderPeriod.endDate, -COMPLAINT_SUBMIT_TIME, self, True)))
10 changes: 5 additions & 5 deletions openprocurement/tender/openuadefense/views/complaint.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ def collection_post(self):
return
complaint = self.request.validated['complaint']
if complaint.status == 'claim':
if get_now() > calculate_business_date(tender.tenderPeriod.endDate, -CLAIM_SUBMIT_TIME, tender):
if get_now() > calculate_business_date(tender.tenderPeriod.endDate, -CLAIM_SUBMIT_TIME, tender, True):
self.request.errors.add('body', 'data', 'Can submit claim not later than {0.days} days before tenderPeriod end'.format(CLAIM_SUBMIT_TIME))
self.request.errors.status = 403
return
complaint.dateSubmitted = get_now()
elif complaint.status == 'pending':
if get_now() > calculate_business_date(tender.tenderPeriod.endDate, -COMPLAINT_SUBMIT_TIME, tender):
if get_now() > tender.complaintPeriod.endDate:
self.request.errors.add('body', 'data', 'Can submit complaint not later than {0.days} days before tenderPeriod end'.format(COMPLAINT_SUBMIT_TIME))
self.request.errors.status = 403
return
Expand Down Expand Up @@ -89,14 +89,14 @@ def patch(self):
elif self.request.authenticated_role == 'complaint_owner' and tender.status == 'active.tendering' and self.context.status == 'draft' and data.get('status', self.context.status) == self.context.status:
apply_patch(self.request, save=False, src=self.context.serialize())
elif self.request.authenticated_role == 'complaint_owner' and tender.status == 'active.tendering' and self.context.status == 'draft' and data.get('status', self.context.status) == 'claim':
if get_now() > calculate_business_date(tender.tenderPeriod.endDate, -CLAIM_SUBMIT_TIME, tender):
if get_now() > calculate_business_date(tender.tenderPeriod.endDate, -CLAIM_SUBMIT_TIME, tender, True):
self.request.errors.add('body', 'data', 'Can submit claim not later than {0.days} days before tenderPeriod end'.format(CLAIM_SUBMIT_TIME))
self.request.errors.status = 403
return
apply_patch(self.request, save=False, src=self.context.serialize())
self.context.dateSubmitted = get_now()
elif self.request.authenticated_role == 'complaint_owner' and tender.status == 'active.tendering' and self.context.status in ['draft', 'claim'] and data.get('status', self.context.status) == 'pending':
if get_now() > calculate_business_date(tender.tenderPeriod.endDate, -COMPLAINT_SUBMIT_TIME, tender):
if get_now() > tender.complaintPeriod.endDate:
self.request.errors.add('body', 'data', 'Can submit complaint not later than {0.days} days before tenderPeriod end'.format(COMPLAINT_SUBMIT_TIME))
self.request.errors.status = 403
return
Expand All @@ -108,7 +108,7 @@ def patch(self):
elif self.request.authenticated_role == 'complaint_owner' and self.context.status == 'answered' and data.get('satisfied', self.context.satisfied) is True and data.get('status', self.context.status) == 'resolved':
apply_patch(self.request, save=False, src=self.context.serialize())
elif self.request.authenticated_role == 'complaint_owner' and self.context.status == 'answered' and data.get('satisfied', self.context.satisfied) is False and data.get('status', self.context.status) == 'pending':
if get_now() > calculate_business_date(tender.tenderPeriod.endDate, -COMPLAINT_SUBMIT_TIME, tender):
if get_now() > tender.complaintPeriod.endDate:
self.request.errors.add('body', 'data', 'Can submit complaint not later than {0.days} days before tenderPeriod end'.format(COMPLAINT_SUBMIT_TIME))
self.request.errors.status = 403
return
Expand Down

0 comments on commit abe8fd9

Please sign in to comment.