Skip to content

Commit

Permalink
Condensed listing
Browse files Browse the repository at this point in the history
  • Loading branch information
kroman0 committed Oct 27, 2014
1 parent 20950e6 commit 061826a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 51 deletions.
1 change: 1 addition & 0 deletions src/openprocurement/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
}

Expand Down
6 changes: 6 additions & 0 deletions src/openprocurement/api/tests/tender.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
53 changes: 2 additions & 51 deletions src/openprocurement/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,64 +127,15 @@ 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"
}
]
}
"""
# 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):
Expand Down

0 comments on commit 061826a

Please sign in to comment.