feat: use surname/initials for author name (#7510)
* feat: use surname/initials for author name * test: test new method * fix: handle case where author name is empty
This commit is contained in:
parent
786ae3edc6
commit
da0a217a8c
|
@ -1,7 +1,7 @@
|
||||||
{% autoescape off %}{% filter wordwrap:78 %}Internet-Draft {{ submission.name }}-{{ submission.rev }}.txt is now available.{% if submission.group %} It is a work item of the {{ submission.group.name }} ({{ submission.group.acronym|upper }}){% if submission.group.type.name %} {{ submission.group.type.name }}{% endif %} of the {% if submission.group.type_id == "rg" %}IRTF{% else %}IETF{% endif %}.{% endif %}{% endfilter %}
|
{% autoescape off %}{% filter wordwrap:78 %}Internet-Draft {{ submission.name }}-{{ submission.rev }}.txt is now available.{% if submission.group %} It is a work item of the {{ submission.group.name }} ({{ submission.group.acronym|upper }}){% if submission.group.type.name %} {{ submission.group.type.name }}{% endif %} of the {% if submission.group.type_id == "rg" %}IRTF{% else %}IETF{% endif %}.{% endif %}{% endfilter %}
|
||||||
|
|
||||||
Title: {{ submission.title }}
|
Title: {{ submission.title }}
|
||||||
Author{{ submission.authors|pluralize:",s" }}: {% if submission.authors|length == 1 %} {% endif %}{% for author in submission.authors %}{{ author.name }}{% if not forloop.last %}
|
Author{{ submission.authors|pluralize:",s" }}: {% if submission.authors|length == 1 %} {% endif %}{% for author in submission.authors %}{% firstof author.name author.affiliation "Unknown" %}{% if not forloop.last %}
|
||||||
{% endif %}{% endfor %}
|
{% endif %}{% endfor %}
|
||||||
Name: {{ submission.name }}-{{ submission.rev }}.txt
|
Name: {{ submission.name }}-{{ submission.rev }}.txt
|
||||||
Pages: {{ submission.pages }}
|
Pages: {{ submission.pages }}
|
||||||
|
|
|
@ -24,7 +24,7 @@ To approve the Internet-Draft, go to this URL (note: you need to login to be abl
|
||||||
|
|
||||||
|
|
||||||
Authors:
|
Authors:
|
||||||
{% for author in submission.authors %} {{ author.name }}{% if author.email %} <{{ author.email }}>{% endif%}
|
{% for author in submission.authors %} {% if author.name or author.affiliation %}{% firstof author.name author.affiliation %} {% endif %}{% if author.email %}<{{ author.email }}>{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endautoescape %}
|
{% endautoescape %}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ I-D Submission Tool URL:
|
||||||
|
|
||||||
|
|
||||||
Authors:
|
Authors:
|
||||||
{% for author in submission.authors %} {{ author.name }}{% if author.email %} <{{ author.email }}>{% endif%}
|
{% for author in submission.authors %} {% if author.name or author.affiliation %}{% firstof author.name author.affiliation %} {% endif %}{% if author.email %}<{{ author.email }}>{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
Comment to the secretariat:
|
Comment to the secretariat:
|
||||||
|
|
|
@ -285,7 +285,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Author {{ forloop.counter }}</th>
|
<th scope="row">Author {{ forloop.counter }}</th>
|
||||||
<td>
|
<td>
|
||||||
{{ author.name }}
|
{% if author.name %}{{ author.name }}{% endif %}
|
||||||
{% if author.email %}<{{ author.email|linkify }}>{% endif %}
|
{% if author.email %}<{{ author.email|linkify }}>{% endif %}
|
||||||
<br>
|
<br>
|
||||||
{% if author.affiliation %}
|
{% if author.affiliation %}
|
||||||
|
|
|
@ -11,12 +11,14 @@
|
||||||
</p>
|
</p>
|
||||||
{% load ietf_filters %}
|
{% load ietf_filters %}
|
||||||
{% for author in submission.authors %}
|
{% for author in submission.authors %}
|
||||||
|
{% if author.name %}
|
||||||
<button type="button"
|
<button type="button"
|
||||||
class="author btn btn-primary mb-3"
|
class="author btn btn-primary mb-3"
|
||||||
data-name="{{ author.name }}"
|
data-name="{{ author.name }}"
|
||||||
data-email="{% if author.email %}{{ author.email }}{% endif %}">
|
data-email="{% if author.email %}{{ author.email }}{% endif %}">
|
||||||
{{ author.name }}
|
{{ author.name }}
|
||||||
</button>
|
</button>
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% bootstrap_form_errors submitter_form %}
|
{% bootstrap_form_errors submitter_form %}
|
||||||
{% bootstrap_field submitter_form.name %}
|
{% bootstrap_field submitter_form.name %}
|
||||||
|
|
|
@ -486,6 +486,51 @@ class XMLDraftTests(TestCase):
|
||||||
("-01", None),
|
("-01", None),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_render_author_name(self):
|
||||||
|
self.assertEqual(
|
||||||
|
XMLDraft.render_author_name(lxml.etree.Element("author", fullname="Joanna Q. Public")),
|
||||||
|
"Joanna Q. Public",
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
XMLDraft.render_author_name(lxml.etree.Element(
|
||||||
|
"author",
|
||||||
|
fullname="Joanna Q. Public",
|
||||||
|
asciiFullname="Not the Same at All",
|
||||||
|
)),
|
||||||
|
"Joanna Q. Public",
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
XMLDraft.render_author_name(lxml.etree.Element(
|
||||||
|
"author",
|
||||||
|
fullname="Joanna Q. Public",
|
||||||
|
initials="J. Q.",
|
||||||
|
surname="Public-Private",
|
||||||
|
)),
|
||||||
|
"Joanna Q. Public",
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
XMLDraft.render_author_name(lxml.etree.Element(
|
||||||
|
"author",
|
||||||
|
initials="J. Q.",
|
||||||
|
surname="Public",
|
||||||
|
)),
|
||||||
|
"J. Q. Public",
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
XMLDraft.render_author_name(lxml.etree.Element(
|
||||||
|
"author",
|
||||||
|
surname="Public",
|
||||||
|
)),
|
||||||
|
"Public",
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
XMLDraft.render_author_name(lxml.etree.Element(
|
||||||
|
"author",
|
||||||
|
initials="J. Q.",
|
||||||
|
)),
|
||||||
|
"J. Q.",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class NameTests(TestCase):
|
class NameTests(TestCase):
|
||||||
|
|
||||||
|
|
|
@ -179,6 +179,29 @@ class XMLDraft(Draft):
|
||||||
# abstract = self.xmlroot.findtext('front/abstract')
|
# abstract = self.xmlroot.findtext('front/abstract')
|
||||||
# return abstract.strip() if abstract else ''
|
# return abstract.strip() if abstract else ''
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def render_author_name(author_elt):
|
||||||
|
"""Get a displayable name for an author, if possible
|
||||||
|
|
||||||
|
Based on TextWriter.render_author_name() from xml2rfc. If fullname is present, uses that.
|
||||||
|
If not, uses either initials + surname or just surname. Finally, returns None because this
|
||||||
|
author is evidently an organization, not a person.
|
||||||
|
|
||||||
|
Does not involve ascii* attributes because rfc7991 requires fullname if any of those are
|
||||||
|
present.
|
||||||
|
"""
|
||||||
|
# Use fullname attribute, if present
|
||||||
|
fullname = author_elt.attrib.get("fullname", "").strip()
|
||||||
|
if fullname:
|
||||||
|
return fullname
|
||||||
|
surname = author_elt.attrib.get("surname", "").strip()
|
||||||
|
initials = author_elt.attrib.get("initials", "").strip()
|
||||||
|
if surname or initials:
|
||||||
|
# This allows the possibility that only initials are used, which is a bit nonsensical
|
||||||
|
# but seems to be technically allowed by RFC 7991.
|
||||||
|
return f"{initials} {surname}".strip()
|
||||||
|
return None
|
||||||
|
|
||||||
def get_author_list(self):
|
def get_author_list(self):
|
||||||
"""Get detailed author list
|
"""Get detailed author list
|
||||||
|
|
||||||
|
@ -197,7 +220,7 @@ class XMLDraft(Draft):
|
||||||
|
|
||||||
for author in self.xmlroot.findall('front/author'):
|
for author in self.xmlroot.findall('front/author'):
|
||||||
info = {
|
info = {
|
||||||
'name': author.attrib.get('fullname'),
|
'name': self.render_author_name(author),
|
||||||
'email': author.findtext('address/email'),
|
'email': author.findtext('address/email'),
|
||||||
'affiliation': author.findtext('organization'),
|
'affiliation': author.findtext('organization'),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue