Skip to content

Commit

Permalink
oai: fix error on document type processing
Browse files Browse the repository at this point in the history
* Closes #789.

Co-Authored-by: Bertrand Zuchuat <bertrand.zuchuat@rero.ch>
  • Loading branch information
Garfield-fr committed Mar 1, 2022
1 parent d0c0bf1 commit 9348f45
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
5 changes: 3 additions & 2 deletions sonar/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"""Document extension."""

from __future__ import absolute_import, print_function
from email.policy import default

import jinja2
import markdown
Expand Down Expand Up @@ -115,8 +116,8 @@ def init_views(self, app):
"""Initialize the main flask views."""
app.url_map.converters['org_code'] = OrganisationCodeConverter

@app.route('/')
@app.route('/<org_code:view>')
@app.route('/', defaults={'view': 'global'})
@app.route('/<org_code:view>', defaults={'view': 'global'})
def index(view):
"""Homepage."""
return render_template('sonar/frontpage.html', view=view)
Expand Down
8 changes: 3 additions & 5 deletions sonar/modules/documents/serializers/schemas/dc.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,9 @@ def get_titles(self, obj):

def get_types(self, obj):
"""Get types."""
if obj['metadata'].get('documentType'):
return [
'http://purl.org/coar/resource_type/{type}'.format(
type=obj['metadata']['documentType'].split(':')[1])
]
types = obj['metadata'].get('documentType', '').split(':')
if len(types) == 2:
return [f'http://purl.org/coar/resource_type/{types[1]}']

return []

Expand Down

0 comments on commit 9348f45

Please sign in to comment.