Skip to content

Commit

Permalink
Modify tender only if patch data available
Browse files Browse the repository at this point in the history
  • Loading branch information
kroman0 committed Oct 27, 2014
1 parent 238c22e commit 20950e6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
9 changes: 9 additions & 0 deletions src/openprocurement/api/tests/tender.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,15 @@ def test_patch_tender(self):
self.assertEqual(tender, new_tender)
self.assertNotEqual(modified, new_modified)

response = self.app.patch_json('/tenders/{}'.format(
tender['id']), {'data': {'modified': new_modified}})
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.content_type, 'application/json')
new_tender2 = response.json['data']
new_modified2 = new_tender2.pop('modified')
self.assertEqual(new_tender, new_tender2)
self.assertEqual(new_modified, new_modified2)

def test_modified_tender(self):
response = self.app.get('/tenders')
self.assertEqual(response.status, '200 OK')
Expand Down
15 changes: 8 additions & 7 deletions src/openprocurement/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,13 +490,14 @@ def patch(self):
self.request.errors.status = 404
return
tender_data = filter_data(self.request.json_body['data'])
if 'tenderID' not in tender_data:
tender_data['tenderID'] = tender.tenderID
try:
tender.import_data(tender_data)
tender.store(self.db)
except Exception, e:
return self.request.errors.add('body', 'data', str(e))
if tender_data:
if 'tenderID' not in tender_data:
tender_data['tenderID'] = tender.tenderID
try:
tender.import_data(tender_data)
tender.store(self.db)
except Exception, e:
return self.request.errors.add('body', 'data', str(e))
return {'data': tender.serialize("view")}


Expand Down

0 comments on commit 20950e6

Please sign in to comment.