diff --git a/src/openprocurement/api/models.py b/src/openprocurement/api/models.py index 323f311209..e15c23fcb3 100644 --- a/src/openprocurement/api/models.py +++ b/src/openprocurement/api/models.py @@ -164,6 +164,7 @@ class TenderDocument(SchematicsDocument, Tender): class Options: roles = { "view": (blacklist("_attachments") + SchematicsDocument.Options.roles['embedded']), + "listing": whitelist("modified", "doc_id"), "auction": whitelist("modified", "bids", "tenderPeriod"), } diff --git a/src/openprocurement/api/tests/tender.py b/src/openprocurement/api/tests/tender.py index b6b06c9817..90dc8a93c7 100644 --- a/src/openprocurement/api/tests/tender.py +++ b/src/openprocurement/api/tests/tender.py @@ -40,14 +40,20 @@ def test_listing(self): self.assertEqual(response.status, '200 OK') self.assertEqual(len(response.json['data']), 0) + tenders = [] + for i in range(3): response = self.app.post_json('/tenders', {'data': {}}) self.assertEqual(response.status, '201 Created') self.assertEqual(response.content_type, 'application/json') + tenders.append(response.json['data']) response = self.app.get('/tenders') self.assertEqual(response.status, '200 OK') self.assertEqual(len(response.json['data']), 3) + self.assertEqual(set(response.json['data'][0]), set([u'id', u'modified'])) + self.assertEqual(set([i['id'] for i in response.json['data']]), set([i['id'] for i in tenders])) + self.assertEqual(set([i['modified'] for i in response.json['data']]), set([i['modified'] for i in tenders])) def test_create_tender_invalid(self): request_path = '/tenders' diff --git a/src/openprocurement/api/views.py b/src/openprocurement/api/views.py index e506da9f63..8823c9c5e2 100644 --- a/src/openprocurement/api/views.py +++ b/src/openprocurement/api/views.py @@ -127,56 +127,7 @@ def collection_get(self): "data": [ { "id": "64e93250be76435397e8c992ed4214d1", - "tenderID": "UA-2014-DUS-156", - "modified": "2014-10-27T08:06:58.158Z", - "procuringEntity": { - "id": { - "name": "Державне управління справами", - "scheme": "https://ns.openprocurement.org/ua/edrpou", - "uid": "00037256", - "uri": "http://www.dus.gov.ua/" - }, - "address": { - "countryName": "Україна", - "postalCode": "01220", - "region": "м. Київ", - "locality": "м. Київ", - "streetAddress": "вул. Банкова, 11, корпус 1" - } - }, - "totalValue": { - "amount": 500, - "currency": "UAH", - "valueAddedTaxIncluded": true - }, - "itemsToBeProcured": [ - { - "description": "футляри до державних нагород", - "primaryClassification": { - "scheme": "CPV", - "id": "44617100-9", - "description": "Cartons" - }, - "additionalClassification": [ - { - "scheme": "ДКПП", - "id": "17.21.1", - "description": "папір і картон гофровані, паперова й картонна тара" - } - ], - "unitOfMeasure": "item", - "quantity": 5 - } - ], - "clarificationPeriod": { - "endDate": "2014-10-31T00:00:00" - }, - "tenderPeriod": { - "endDate": "2014-11-06T10:00:00" - }, - "awardPeriod": { - "endDate": "2014-11-13T00:00:00" - } + "modified": "2014-10-27T08:06:58.158Z" } ] } @@ -184,7 +135,7 @@ def collection_get(self): """ # limit, skip, descending results = TenderDocument.view(self.db, 'tenders/all') - return {'data': [i.serialize("view") for i in results]} + return {'data': [i.serialize("listing") for i in results]} @view(content_type="application/json", validators=(validate_tender_data,)) def collection_post(self):