www-from-model/page_templates/project.md.j2
Michał Szczepanik 58090f9af2
Some checks failed
Deploy on webserver / Build site and deploy on success (push) Failing after 0s
feat: unify "part of" display
We present "part of" for Objective, Project, and Topic pages. This
commit makes the way it is shown more consistent:

- only show "Part of" if there are elements to show
- show this after the description
- in link targets, expect "xyzrins:" in PID, not "xyzrsens:";
  the latter is from the older demo-rse-group schema, we are using
  demo-research-information

Two minor inconsistencies remain. In project pages, "Part of" is a
header, staying similar to other sections of the page. In topic pages,
the link text uses display label, while others use title.
2026-04-10 19:25:01 +02:00

61 lines
2.9 KiB
Django/Jinja

{% macro taxonomy_terms(taxonomy, type, objects, typeattr='object.schema_type', pidattr='object.pid') -%}
{%- set matching = objects|selectattr(typeattr, 'eq', type)|map(attribute=pidattr)|map('replace', 'xyzrins:' ~ taxonomy ~ '/', '')|sort -%}
{% if matching|length -%}
{{ taxonomy }}:
{% for pid in matching -%}
- {{ pid }}
{% endfor -%}
{%- endif -%}
{%- endmacro -%}
{% macro assoc_period(ass, pre="") -%}
{% if ass.started is defined and ass.started.at_time is defined and ass.ended is defined and ass.ended.at_time is defined %}{{ pre ~ ass.started.at_time }} -- {{ ass.ended.at_time }}{% elif ass.started is defined and ass.started.at_time is defined %}{{ pre ~ "since"}} {{ass.started.at_time }}{% elif ass.ended is defined and ass.ended.at_time is defined %}{{pre ~ "until"}} {{ ass.ended.at_time }}{% endif %}
{%- endmacro -%}
---
title: "{{ title }}"
{{ taxonomy_terms('projects', 'xyzri:XYZProject', parts, typeattr='schema_type', pidattr='pid') -}}
{{ taxonomy_terms('objectives', 'xyzri:XYZObjective', influenced_by) -}}
{{ taxonomy_terms('persons', 'xyzri:XYZPerson', associated_with) -}}
{{ taxonomy_terms('instruments', 'xyzri:XYZInstrument', generated, typeattr='schema_type', pidattr='pid') -}}
params:
graphRootNodePID: {{ pid }}
---
{{ description }}
{% if part_of %}## Part of
{% for item in part_of -%}
- [{{ item.title }}](/{{ item.pid.replace('xyzrins:', '') }})
{% endfor %}
{% endif -%}
## Objectives
{% for inf in influenced_by if inf.object.schema_type == "xyzri:XYZObjective" and not inf.ended -%}
- [{{ inf.object.title }}](/{{ inf.object.pid|replace('xyzrins:', '') }}) ({%for role in inf.roles %}{{ ', ' if not loop.first }}{{ role.display_label|default(role.name) }}{% endfor -%})
{% endfor -%}
## People
### Currently associated
{% for ass in associated_with if ass.object.schema_type == "xyzri:XYZPerson" and not ass.ended -%}
- [{{ ass.object.given_name }} {{ ass.object.family_name }}](/{{ ass.object.pid|replace('xyzrins:', '') }}) ({% for role in ass.roles %}{{ ', ' if not loop.first }}{{ role.display_label|default(role.name) }}{% endfor -%}){{ (" \n " ~ ass.description).rstrip() }}
{% endfor -%}
{% with prev_associated = associated_with | selectattr("object.schema_type", "eq", "xyzri:XYZPerson") | selectattr("ended", "defined") -%}
{% for ass in prev_associated | sort(attribute="ended.at_time", reverse=True) -%}
{% if loop.first %}
### Previously associated
{% endif -%}
- [{{ ass.object.given_name }} {{ ass.object.family_name }}](/{{ ass.object.pid|replace('xyzrins:', '') }}) ({% for role in ass.roles %}{{ ', ' if not loop.first }}{{ role.display_label|default(role.name) }}{% endfor -%} {{ assoc_period(ass, "; ") }}){{ (" \n " ~ ass.description).rstrip() }}
{% endfor -%}
{% endwith -%}
{% if generated|length -%}
## Outputs
{% for gen in generated -%}
- [{{ gen.display_label|default(gen.title)|default(gen.name) }}]({{ gen.pid|replace('xyzrins:', '/') }})
{% endfor -%}
{% endif %}