Skip to content

Commit

Permalink
Fix broken links to private people. (#1120)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartfeenstra authored Dec 29, 2023
1 parent 610060a commit 422bbba
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% import 'macro/person.html.j2' as person_macros %}
{% set embedded = embedded | default(False) %}
{% set person_context = entity_contexts['Person'] %}
{% if not embedded and person_context != entity and entity is not has_generated_entity_id -%}
{% if not embedded and person_context != entity and entity is not has_generated_entity_id and entity is public -%}
<a href="{{ entity | url }}">
{%- endif %}
{% if entity.private or entity.name is not none and entity.name.private -%}
Expand All @@ -11,6 +11,6 @@
{%- else -%}
<span class="nn" title="{% trans %}This person's name is unknown.{% endtrans %}">n.n.</span>
{%- endif %}
{% if not embedded and person_context != entity and entity is not has_generated_entity_id -%}
{% if not embedded and person_context != entity and entity is not has_generated_entity_id and entity is public -%}
</a>
{%- endif %}
8 changes: 7 additions & 1 deletion betty/extension/trees/assets/public/localized/people.json.j2
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
{% set ns = namespace(people={}) %}
{% for person in app.project.ancestry['Person'] %}
{% if person.public %}
{% set person_label = person.label | localize %}
{% else %}
{% set person_label = _('private') %}
{% endif %}
{% do ns.people.update({
person.id: {
'id': person.id,
'label': person.label | localize,
'label': person_label,
'url': person | url,
'parentIds': person.parents | map(attribute='id') | list,
'childIds': person.children | map(attribute='id') | list,
'private': person.private,
}
}) %}
{% endfor %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ async def test_private(self) -> None:
id='P0',
private=True,
)
expected = '<a href="/person/P0/index.html"><span class="private" title="This person\'s details are unavailable to protect their privacy.">private</span></a>'
expected = '<span class="private" title="This person\'s details are unavailable to protect their privacy.">private</span>'
async with self._render(data={
'entity': person,
}) as (actual, _):
Expand Down

0 comments on commit 422bbba

Please sign in to comment.