www-from-model/page_templates/publications.json.j2

50 lines
No EOL
1.4 KiB
Django/Jinja

{%- set result = [] -%}
{%- for pub in publications -%}
{%- set doi = (
pub.identifiers
| selectattr('schema_type', 'equalto', 'dlthings:DOI')
| list
| first
) if pub.identifiers is defined and pub.identifiers is sequence else none -%}
{%- set generation = (
pub.generated_by
| selectattr('object', 'equalto', 'obo:IAO_0000444')
| list
| first
) if pub.generated_by is defined and pub.generated_by is sequence else none -%}
{%- set authors = [] -%}
{%- for auth in pub.attributed_to -%}
{%- set _ = authors.append({
"pid": auth.object.pid | default(none),
"given_name": auth.object.given_name | default(none),
"family_name": auth.object.family_name | default(none)
}) -%}
{%- endfor -%}
{%- set topics = [] -%}
{%- for top in pub.about -%}
{%- set _ = topics.append({
"pid": top.pid | default(none),
"display_label": top.display_label | default(none)
}) -%}
{%- endfor -%}
{%- set item = {
"pid": pub.pid | default(none),
"doi": doi.notation | default(none) if doi else none,
"date": generation.at_time | default(none) if generation else none,
"title": pub.title | default(none),
"kind": pub.kind | default(none),
"author": authors,
"topic": topics
} -%}
{%- set _ = result.append(item) -%}
{%- endfor -%}
{{- result | tojson() -}}