Skip to content

Commit

Permalink
Merge branch 'a158916227407145_Administrator_award_complaintPeriod'
Browse files Browse the repository at this point in the history
  • Loading branch information
kroman0 committed Jul 28, 2016
2 parents 6ce1da6 + 451b28c commit d27d757
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions openprocurement/tender/limited/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class Options:
'edit': blacklist('id', 'date', 'documents', 'complaints', 'complaintPeriod'),
'embedded': schematics_embedded_role,
'view': schematics_default_role,
'Administrator': whitelist('complaintPeriod'),
}

id = MD5Type(required=True, default=lambda: uuid4().hex)
Expand Down
29 changes: 29 additions & 0 deletions openprocurement/tender/limited/tests/award.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,35 @@ def test_get_tender_award(self):
class TenderNegotiationAwardResourceTest(TenderAwardResourceTest):
initial_data = test_tender_negotiation_data

def test_patch_tender_award_Administrator_change(self):
response = self.app.post_json('/tenders/{}/awards?acc_token={}'.format(
self.tender_id, self.tender_token), {'data': {'suppliers': [test_organization], 'status': 'pending'}})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
award = response.json['data']
complaintPeriod = award['complaintPeriod'][u'startDate']

authorization = self.app.authorization
self.app.authorization = ('Basic', ('administrator', ''))
response = self.app.patch_json('/tenders/{}/awards/{}'.format(self.tender_id, award['id']), {"data": {"complaintPeriod": {"endDate": award['complaintPeriod'][u'startDate']}}})
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.content_type, 'application/json')
self.assertIn("endDate", response.json['data']['complaintPeriod'])
self.assertEqual(response.json['data']['complaintPeriod']["endDate"], complaintPeriod)

self.app.authorization = authorization
response = self.app.patch_json('/tenders/{}/awards/{}?acc_token={}'.format(self.tender_id, award['id'], self.tender_token),
{"data": {"status": "active"}})
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.content_type, 'application/json')

self.app.authorization = ('Basic', ('administrator', ''))
response = self.app.patch_json('/tenders/{}/awards/{}'.format(self.tender_id, award['id']), {"data": {"complaintPeriod": {"endDate": award['complaintPeriod'][u'startDate']}}})
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.content_type, 'application/json')
self.assertIn("endDate", response.json['data']['complaintPeriod'])
self.assertEqual(response.json['data']['complaintPeriod']["endDate"], complaintPeriod)


class TenderNegotiationQuickAwardResourceTest(TenderNegotiationAwardResourceTest):
initial_data = test_tender_negotiation_quick_data
Expand Down
2 changes: 1 addition & 1 deletion openprocurement/tender/limited/views/award.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ def patch(self):
self.request.errors.add('body', 'data', 'Can\'t update award in current ({}) status'.format(award_status))
self.request.errors.status = 403
return
elif award_status != 'pending':
elif self.request.authenticated_role != 'Administrator' and award_status != 'pending':
self.request.errors.add('body', 'data', 'Can\'t update award in current ({}) status'.format(award_status))
self.request.errors.status = 403
return
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
import os

version = '2.3.6'
version = '2.3.7'

requires = [
'setuptools',
Expand Down

0 comments on commit d27d757

Please sign in to comment.