Skip to content

Commit

Permalink
Merge 0ffe230 into 5e05366
Browse files Browse the repository at this point in the history
  • Loading branch information
Wim-De-Clercq committed Jul 9, 2020
2 parents 5e05366 + 0ffe230 commit ee7982d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
6 changes: 3 additions & 3 deletions atramhasis/views/views.py
Expand Up @@ -255,8 +255,8 @@ def results_csv(self):
@view_config(route_name='scheme_tree', renderer='json', accept='application/json')
def results_tree_json(self):
scheme_id = self.request.matchdict['scheme_id']
locale = self.request.locale_name
dicts = self.get_results_tree(scheme_id, locale)
language = self.request.params.get('language', self.request.locale_name)
dicts = self.get_results_tree(scheme_id, language)
if dicts:
return dicts
else:
Expand All @@ -282,7 +282,7 @@ def get_scheme(self, scheme, locale):

def parse_thing(self, thing, parent_tree_id):
tree_id = self.create_treeid(parent_tree_id, thing.concept_id)
locale = self.request.locale_name
locale = self.request.params.get('language', self.request.locale_name)

if thing.type and thing.type == 'collection':
cs = [member for member in thing.members] if hasattr(thing, 'members') else []
Expand Down
16 changes: 16 additions & 0 deletions tests/test_functional.py
Expand Up @@ -520,6 +520,22 @@ def test_missing_labels(self):
self.assertEqual('label', response.json[0]['label'])
self.assertEqual(None, response.json[1]['label'])

def test_tree_language(self):
response = self.testapp.get('/conceptschemes/TREES/tree?language=nl',
headers=self._get_default_headers())
self.assertEqual(200, response.status_code)
self.assertEqual(
['De Lariks', 'De Paardekastanje'],
[child['label'] for child in response.json[0]['children']]
)
response = self.testapp.get('/conceptschemes/TREES/tree?language=en',
headers=self._get_default_headers())
self.assertEqual(200, response.status_code)
self.assertEqual(
['The Chestnut', 'The Larch'],
[child['label'] for child in response.json[0]['children']]
)

def test_no_tree(self):
response = self.testapp.get('/conceptschemes/FOO/tree?_LOCALE_=nl', headers=self._get_default_headers(),
status=404, expect_errors=True)
Expand Down

0 comments on commit ee7982d

Please sign in to comment.