Skip to content

Commit

Permalink
Refactor method to get public conceptschemes. Refs #777
Browse files Browse the repository at this point in the history
  • Loading branch information
koenedaele committed Feb 24, 2023
1 parent eb35469 commit 9e15c74
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions atramhasis/views/views.py
Expand Up @@ -81,10 +81,9 @@ def favicon_view(self):
)
return response

@view_config(route_name='home', renderer='atramhasis:templates/home.jinja2')
def home_view(self):
def _get_public_conceptschemes(self):
"""
Display the homepage.
Get all conceptschemes that are visible through the public UI.
"""
conceptschemes = [
{'id': x.get_metadata()['id'],
Expand All @@ -93,19 +92,23 @@ def home_view(self):
for not_shown in ['external', 'hidden']])
]

return conceptschemes

@view_config(route_name='home', renderer='atramhasis:templates/home.jinja2')
def home_view(self):
"""
Display the homepage.
"""
conceptschemes = self._get_public_conceptschemes()

return {'conceptschemes': conceptschemes}

@view_config(route_name='conceptschemes', renderer='atramhasis:templates/conceptschemes.jinja2')
def conceptschemes_view(self):
"""
Display a list of available conceptschemes.
"""
conceptschemes = [
{'id': x.get_metadata()['id'],
'conceptscheme': x.concept_scheme}
for x in self.skos_registry.get_providers() if not any([not_shown in x.get_metadata()['subject']
for not_shown in ['external', 'hidden']])
]
conceptschemes = self._get_public_conceptschemes()

return {'conceptschemes': conceptschemes}

Expand All @@ -115,12 +118,7 @@ def conceptscheme_view(self):
"""
Display a single conceptscheme.
"""
conceptschemes = [
{'id': x.get_metadata()['id'],
'conceptscheme': x.concept_scheme}
for x in self.skos_registry.get_providers() if not any([not_shown in x.get_metadata()['subject']
for not_shown in ['external', 'hidden']])
]
conceptschemes = self._get_public_conceptschemes()

scheme_id = self.request.matchdict['scheme_id']
provider = self.request.skos_registry.get_provider(scheme_id)
Expand Down

0 comments on commit 9e15c74

Please sign in to comment.