Skip to content

Commit

Permalink
feat: use surname/initials for author name (#7510)
Browse files Browse the repository at this point in the history
* feat: use surname/initials for author name

* test: test new method

* fix: handle case where author name is empty
  • Loading branch information
jennifer-richards authored Jun 6, 2024
1 parent 786ae3e commit da0a217
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ietf/templates/submit/announce_to_lists.txt
Original file line number Diff line number Diff line change
@@ -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 %}

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 %}
Name: {{ submission.name }}-{{ submission.rev }}.txt
Pages: {{ submission.pages }}
Expand Down
2 changes: 1 addition & 1 deletion ietf/templates/submit/approval_request.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ To approve the Internet-Draft, go to this URL (note: you need to login to be abl


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 %}
{% endautoescape %}

Expand Down
2 changes: 1 addition & 1 deletion ietf/templates/submit/manual_post_request.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ I-D Submission Tool URL:


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 %}

Comment to the secretariat:
Expand Down
2 changes: 1 addition & 1 deletion ietf/templates/submit/submission_status.html
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ <h2 class="mt-5">Meta-data from the submission</h2>
<tr>
<th scope="row">Author {{ forloop.counter }}</th>
<td>
{{ author.name }}
{% if author.name %}{{ author.name }}{% endif %}
{% if author.email %}&lt;{{ author.email|linkify }}&gt;{% endif %}
<br>
{% if author.affiliation %}
Expand Down
14 changes: 8 additions & 6 deletions ietf/templates/submit/submitter_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ <h3 class="mt-5">Submitter</h3>
</p>
{% load ietf_filters %}
{% for author in submission.authors %}
<button type="button"
class="author btn btn-primary mb-3"
data-name="{{ author.name }}"
data-email="{% if author.email %}{{ author.email }}{% endif %}">
{{ author.name }}
</button>
{% if author.name %}
<button type="button"
class="author btn btn-primary mb-3"
data-name="{{ author.name }}"
data-email="{% if author.email %}{{ author.email }}{% endif %}">
{{ author.name }}
</button>
{% endif %}
{% endfor %}
{% bootstrap_form_errors submitter_form %}
{% bootstrap_field submitter_form.name %}
Expand Down
45 changes: 45 additions & 0 deletions ietf/utils/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,51 @@ def test_parse_docname(self):
("-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):

Expand Down
25 changes: 24 additions & 1 deletion ietf/utils/xmldraft.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,29 @@ def get_creation_date(self):
# abstract = self.xmlroot.findtext('front/abstract')
# 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):
"""Get detailed author list
Expand All @@ -197,7 +220,7 @@ def get_author_list(self):

for author in self.xmlroot.findall('front/author'):
info = {
'name': author.attrib.get('fullname'),
'name': self.render_author_name(author),
'email': author.findtext('address/email'),
'affiliation': author.findtext('organization'),
}
Expand Down

2 comments on commit da0a217

@Shahinmc

This comment was marked as spam.

@Shahinmc

This comment was marked as spam.

Please sign in to comment.