Skip to content

Commit 061826a

Browse files
committed
Condensed listing
1 parent 20950e6 commit 061826a

File tree

3 files changed

+9
-51
lines changed

3 files changed

+9
-51
lines changed

src/openprocurement/api/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ class TenderDocument(SchematicsDocument, Tender):
164164
class Options:
165165
roles = {
166166
"view": (blacklist("_attachments") + SchematicsDocument.Options.roles['embedded']),
167+
"listing": whitelist("modified", "doc_id"),
167168
"auction": whitelist("modified", "bids", "tenderPeriod"),
168169
}
169170

src/openprocurement/api/tests/tender.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,20 @@ def test_listing(self):
4040
self.assertEqual(response.status, '200 OK')
4141
self.assertEqual(len(response.json['data']), 0)
4242

43+
tenders = []
44+
4345
for i in range(3):
4446
response = self.app.post_json('/tenders', {'data': {}})
4547
self.assertEqual(response.status, '201 Created')
4648
self.assertEqual(response.content_type, 'application/json')
49+
tenders.append(response.json['data'])
4750

4851
response = self.app.get('/tenders')
4952
self.assertEqual(response.status, '200 OK')
5053
self.assertEqual(len(response.json['data']), 3)
54+
self.assertEqual(set(response.json['data'][0]), set([u'id', u'modified']))
55+
self.assertEqual(set([i['id'] for i in response.json['data']]), set([i['id'] for i in tenders]))
56+
self.assertEqual(set([i['modified'] for i in response.json['data']]), set([i['modified'] for i in tenders]))
5157

5258
def test_create_tender_invalid(self):
5359
request_path = '/tenders'

src/openprocurement/api/views.py

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -127,64 +127,15 @@ def collection_get(self):
127127
"data": [
128128
{
129129
"id": "64e93250be76435397e8c992ed4214d1",
130-
"tenderID": "UA-2014-DUS-156",
131-
"modified": "2014-10-27T08:06:58.158Z",
132-
"procuringEntity": {
133-
"id": {
134-
"name": "Державне управління справами",
135-
"scheme": "https://ns.openprocurement.org/ua/edrpou",
136-
"uid": "00037256",
137-
"uri": "http://www.dus.gov.ua/"
138-
},
139-
"address": {
140-
"countryName": "Україна",
141-
"postalCode": "01220",
142-
"region": "м. Київ",
143-
"locality": "м. Київ",
144-
"streetAddress": "вул. Банкова, 11, корпус 1"
145-
}
146-
},
147-
"totalValue": {
148-
"amount": 500,
149-
"currency": "UAH",
150-
"valueAddedTaxIncluded": true
151-
},
152-
"itemsToBeProcured": [
153-
{
154-
"description": "футляри до державних нагород",
155-
"primaryClassification": {
156-
"scheme": "CPV",
157-
"id": "44617100-9",
158-
"description": "Cartons"
159-
},
160-
"additionalClassification": [
161-
{
162-
"scheme": "ДКПП",
163-
"id": "17.21.1",
164-
"description": "папір і картон гофровані, паперова й картонна тара"
165-
}
166-
],
167-
"unitOfMeasure": "item",
168-
"quantity": 5
169-
}
170-
],
171-
"clarificationPeriod": {
172-
"endDate": "2014-10-31T00:00:00"
173-
},
174-
"tenderPeriod": {
175-
"endDate": "2014-11-06T10:00:00"
176-
},
177-
"awardPeriod": {
178-
"endDate": "2014-11-13T00:00:00"
179-
}
130+
"modified": "2014-10-27T08:06:58.158Z"
180131
}
181132
]
182133
}
183134
184135
"""
185136
# limit, skip, descending
186137
results = TenderDocument.view(self.db, 'tenders/all')
187-
return {'data': [i.serialize("view") for i in results]}
138+
return {'data': [i.serialize("listing") for i in results]}
188139

189140
@view(content_type="application/json", validators=(validate_tender_data,))
190141
def collection_post(self):

0 commit comments

Comments
 (0)