*** Wartungsfenster jeden ersten Mittwoch vormittag im Monat ***

Skip to content
Snippets Groups Projects
Commit e1bb35e7 authored by Moser, Maximilian's avatar Moser, Maximilian
Browse files

Gracefully handle identifiers not being set

parent e426e32a
No related branches found
No related tags found
No related merge requests found
......@@ -20,9 +20,10 @@ blueprint = Blueprint(
@blueprint.app_template_filter("tuw_doi_identifier")
def tuw_doi_identifier(identifiers):
"""Extract DOI from sequence of identifiers."""
for identifier in identifiers:
if identifier.get("scheme") == "doi":
return identifier.get("identifier")
if identifiers is not None:
for identifier in identifiers:
if identifier.get("scheme") == "doi":
return identifier.get("identifier")
@blueprint.app_template_global("tuw_cite_as")
......@@ -47,9 +48,11 @@ def tuw_cite_as(record_metadata):
version if version.lower().startswith("v") else "Version {}".format(version)
)
fmt_resource_type = vocabulary.get_title_by_dict(resource_type)
fmt_doi = (
doi if doi.lower().startswith("http") else "https://doi.org/{}".format(doi)
)
fmt_doi = ""
if doi is not None:
fmt_doi = (
doi if doi.lower().startswith("http") else "https://doi.org/{}".format(doi)
)
# format the author names roughly according to the APA logic:
# https://research.moreheadstate.edu/c.php?g=107001&p=695202
......@@ -69,5 +72,5 @@ def tuw_cite_as(record_metadata):
fmt_resource_type,
publisher,
fmt_doi,
)
).strip()
return text
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment