Skip to content

Commit

Permalink
Updated bid actions validation in tendering period
Browse files Browse the repository at this point in the history
  • Loading branch information
kroman0 committed Apr 7, 2016
1 parent 69aea42 commit 0b74d9d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions openprocurement/tender/openua/views/bid.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ def patch(self):
self.request.errors.add('body', 'data', 'Can\'t update bid in current ({}) tender status'.format(self.request.validated['tender_status']))
self.request.errors.status = 403
return
tender = self.request.validated['tender']
if self.request.authenticated_role != 'Administrator' and (tender.tenderPeriod.startDate and get_now() < tender.tenderPeriod.startDate or get_now() > tender.tenderPeriod.endDate):
self.request.errors.add('body', 'data', 'Bid can be updated only during the tendering period: from ({}) to ({}).'.format(tender.tenderPeriod.startDate and tender.tenderPeriod.startDate.isoformat()(), tender.tenderPeriod.endDate.isoformat()))
self.request.errors.status = 403
return
bid_status_to = self.request.validated['data'].get("status")
if bid_status_to and bid_status_to != 'active':
self.request.errors.add('body', 'bid', 'Can\'t update bid to ({}) status'.format(bid_status_to))
Expand Down Expand Up @@ -225,6 +230,11 @@ def delete(self):
self.request.errors.add('body', 'data', 'Can\'t delete bid in current ({}) tender status'.format(self.request.validated['tender_status']))
self.request.errors.status = 403
return
tender = self.request.validated['tender']
if tender.tenderPeriod.startDate and get_now() < tender.tenderPeriod.startDate or get_now() > tender.tenderPeriod.endDate:
self.request.errors.add('body', 'data', 'Bid can be deleted only during the tendering period: from ({}) to ({}).'.format(tender.tenderPeriod.startDate and tender.tenderPeriod.startDate.isoformat(), tender.tenderPeriod.endDate.isoformat()))
self.request.errors.status = 403
return
bid.status = 'deleted'
self.request.validated['tender'].modified = False
if save_tender(self.request):
Expand Down

0 comments on commit 0b74d9d

Please sign in to comment.