Skip to content

Commit

Permalink
fix: improve handling for other fields
Browse files Browse the repository at this point in the history
* fix show_dates
* fix _identifiers_for_group
* fix show_related_identifiers by filtering with selectattr: https://jinja.palletsprojects.com/en/stable/templates/#jinja-filters.selectattr
  • Loading branch information
Samk13 committed Dec 5, 2024
1 parent 9c97131 commit 3c86a5d
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ <h2>{{ add_description.type.title_l10n if add_description.type is defined else _

{% macro show_dates(dates) %}
{% for date in dates %}
<dt class="ui tiny header">{{ date.type.title_l10n }}</dt>
<dt class="ui tiny header">{{ date.type.title_l10n if date.type is defined else 'Unknown date type' }}</dt>
<dd>
<div>{{ date.date }}</div>
<div class="text-muted">{{ date.description }}</div>
Expand Down Expand Up @@ -160,24 +160,27 @@ <h2>{{ add_description.type.title_l10n if add_description.type is defined else _
{{ identifier.resource_type.title_l10n }}:
{% endif %}

{% set url = identifier.identifier|pid_url %}
{% set ident_val = identifier.identifier if identifier.identifier is defined else '' %}
{% set url = ident_val|pid_url %}
{% if url %}
<a href="{{ url }}" target="_blank" title="{{ _('Opens in new tab') }}">
{{ identifier.identifier }}
{{ ident_val }}
</a>
{% else %}
{{ identifier.identifier }}
{{ ident_val }}
{% endif %}

{{ ' (' + identifier.scheme | get_scheme_label + ')' }}
{% if identifier.scheme is defined %}
{{ ' (' ~ (identifier.scheme|get_scheme_label) ~ ')' }}
{% endif %}
</dd>
{% endfor %}
{% endmacro %}


{% macro show_related_identifiers(related_identifiers) %}
<dl class="details-list">
{%- for group in related_identifiers | groupby('relation_type.title_l10n') %}
{%- for group in (related_identifiers|selectattr("relation_type","defined")|list) | groupby('relation_type.title_l10n') %}
<dt class="ui tiny header">{{ group.grouper }}</dt>
{{ _identifiers_for_group(group.list) }}
{%- endfor %}
Expand Down

0 comments on commit 3c86a5d

Please sign in to comment.