← 返回首页
feat: show rfc titlepage names (#10863) · ietf-tools/datatracker@94955d4 · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

Commit 94955d4

Browse files
authored
feat: show rfc titlepage names (#10863)
* feat: use titlepage_name for person_links when it exists * test: test using titlepage_name when present, and test html rendering
1 parent 6e664ea commit 94955d4

4 files changed

Lines changed: 68 additions & 3 deletions

File tree

‎ietf/person/templatetags/person_filters.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def person_link(person, **kwargs):
5050
title = kwargs.get("title", "")
5151
cls = kwargs.get("class", "")
5252
with_email = kwargs.get("with_email", True)
53+
titlepage_name = kwargs.get("titlepage_name", None)
5354
if person is not None:
5455
plain_name = person.plain_name()
5556
name = (
@@ -61,6 +62,7 @@ def person_link(person, **kwargs):
6162
return {
6263
"name": name,
6364
"plain_name": plain_name,
65+
"titlepage_name": titlepage_name,
6466
"email": email,
6567
"title": title,
6668
"class": cls,

‎ietf/person/templatetags/tests.py‎

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Copyright The IETF Trust 2022, All Rights Reserved
2+
from django.template.loader import render_to_string
3+
24
from ietf.person.factories import PersonFactory
35
from ietf.utils.test_utils import TestCase
46

@@ -8,14 +10,14 @@
810
class PersonLinkTests(TestCase):
911
# Tests of the person_link template tag. These assume it is implemented as an
1012
# inclusion tag.
11-
# TODO test that the template actually renders the data in the dict
1213
def test_person_link(self):
1314
person = PersonFactory()
1415
self.assertEqual(
1516
person_link(person),
1617
{
1718
'name': person.name,
1819
'plain_name': person.plain_name(),
20+
'titlepage_name': None,
1921
'email': person.email_address(),
2022
'title': '',
2123
'class': '',
@@ -27,6 +29,7 @@ def test_person_link(self):
2729
{
2830
'name': person.name,
2931
'plain_name': person.plain_name(),
32+
'titlepage_name': None,
3033
'email': person.email_address(),
3134
'title': '',
3235
'class': '',
@@ -38,6 +41,7 @@ def test_person_link(self):
3841
{
3942
'name': person.name,
4043
'plain_name': person.plain_name(),
44+
'titlepage_name': None,
4145
'email': person.email_address(),
4246
'title': 'Random Title',
4347
'class': '',
@@ -50,12 +54,71 @@ def test_person_link(self):
5054
{
5155
'name': person.name,
5256
'plain_name': person.plain_name(),
57+
'titlepage_name': None,
5358
'email': person.email_address(),
5459
'title': '',
5560
'class': 'some-class',
5661
'with_email': True,
5762
}
5863
)
64+
self.assertEqual(
65+
person_link(person, titlepage_name='G. Surname'),
66+
{
67+
'name': person.name,
68+
'plain_name': person.plain_name(),
69+
'titlepage_name': 'G. Surname',
70+
'email': person.email_address(),
71+
'title': '',
72+
'class': '',
73+
'with_email': True,
74+
}
75+
)
76+
77+
def test_person_link_renders(self):
78+
"""Verifies person/person_link.html renders context dict values correctly."""
79+
person = PersonFactory()
80+
name = person.name
81+
email = person.email_address()
82+
base_context = {
83+
'name': name,
84+
'plain_name': person.plain_name(),
85+
'titlepage_name': None,
86+
'email': email,
87+
'title': '',
88+
'class': '',
89+
'with_email': True,
90+
}
91+
92+
# Default: name is used as link text with default title attribute
93+
html = render_to_string('person/person_link.html', base_context)
94+
self.assertIn(f'>{name}</a>', html)
95+
self.assertIn(f'Datatracker profile of {name}', html)
96+
self.assertIn('bi-envelope', html)
97+
98+
# titlepage_name overrides name as link text
99+
html = render_to_string('person/person_link.html', {**base_context, 'titlepage_name': 'G. Surname'})
100+
self.assertIn('>G. Surname</a>', html)
101+
self.assertNotIn(f'>{name}</a>', html)
102+
103+
# with_email=False suppresses the envelope link
104+
html = render_to_string('person/person_link.html', {**base_context, 'with_email': False})
105+
self.assertNotIn('bi-envelope', html)
106+
107+
# Custom title appears in the anchor title attribute
108+
html = render_to_string('person/person_link.html', {**base_context, 'title': 'Special Title'})
109+
self.assertIn('title="Special Title"', html)
110+
111+
# Empty context (None person) renders (None)
112+
self.assertInHTML(
113+
'<span class="text-body-secondary">(None)</span>',
114+
render_to_string('person/person_link.html', {}),
115+
)
116+
117+
# System email renders (System)
118+
self.assertInHTML(
119+
'<span class="text-body-secondary">(System)</span>',
120+
render_to_string('person/person_link.html', {'email': 'system@datatracker.ietf.org', 'name': ''}),
121+
)
59122

60123
def test_invalid_person(self):
61124
"""Generates correct context dict when input is invalid/missing"""

‎ietf/templates/doc/document_info.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
<td>
9898
{# Implementation that uses the current primary email for each author #}
9999
{% if doc.pk %}{% for author in doc.author_persons_or_names %}
100-
{% if author.person %}{% person_link author.person %}{% else %}{{ author.titlepage_name }}{% endif %}{% if not forloop.last %},{% endif %}
100+
{% if author.person %}{% person_link author.person titlepage_name=author.titlepage_name %}{% else %}{{ author.titlepage_name }}{% endif %}{% if not forloop.last %},{% endif %}
101101
{% endfor %}{% endif %}
102102
{% if document_html and not snapshot or document_html and doc.rev == latest_rev%}
103103
<br>

‎ietf/templates/person/person_link.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% if email and email == "system@datatracker.ietf.org" or name and name == "(System)" %}<span class="text-body-secondary">(System)</span>{% else %}<span {% if class %}class="{{ class }}"
22
{% endif %}>{% if email or name %}<a {% if class %}class="text-reset"{% endif %}
33
title="{% if title %}{{ title }}{% else %}Datatracker profile of {{ name }}{% endif %}"
4-
{% if email %} href="{% url 'ietf.person.views.profile' email_or_name=email %}" {% else %} href="{% url 'ietf.person.views.profile' email_or_name=name %}" {% endif %}>{{ name }}</a>{% if email and with_email %} <a {% if class %}class="text-reset"{% endif %}
4+
{% if email %} href="{% url 'ietf.person.views.profile' email_or_name=email %}" {% else %} href="{% url 'ietf.person.views.profile' email_or_name=name %}" {% endif %}>{% if titlepage_name %}{{ titlepage_name }}{% else %}{{ name }}{% endif %}</a>{% if email and with_email %} <a {% if class %}class="text-reset"{% endif %}
55
href="mailto:{{ email|urlencode }}"
66
aria-label="Compose email to {{ email }}"
77
title="Compose email to {{ email }}">

0 commit comments

Comments
 (0)

Footer

© 2026 GitHub, Inc.