Added a method Person.ascii_name() for use when generating 1id-*.txt files. Added caching for Person.plain_name(). Fixes a problem with non-ascii names in 1id-*.txt which lead to non-ascii names in xml2rfc reference files.
- Legacy-Id: 11510
This commit is contained in:
parent
8642e8da5e
commit
5acff0e95f
|
@ -239,7 +239,7 @@ def active_drafts_index_by_group(extra_values=()):
|
|||
if d:
|
||||
if "authors" not in d:
|
||||
d["authors"] = []
|
||||
d["authors"].append(unicode(a.author.person))
|
||||
d["authors"].append(a.author.person.ascii_name())
|
||||
|
||||
# put docs into groups
|
||||
for d in docs_dict.itervalues():
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
# Copyright The IETF Trust 2007, All Rights Reserved
|
||||
|
||||
import datetime
|
||||
from urlparse import urljoin
|
||||
from hashids import Hashids
|
||||
from unidecode import unidecode
|
||||
from urlparse import urljoin
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
|
@ -44,8 +45,20 @@ class PersonInfo(models.Model):
|
|||
prefix, first, middle, last, suffix = self.ascii_parts()
|
||||
return (first and first[0]+"." or "")+(middle or "")+" "+last+(suffix and " "+suffix or "")
|
||||
def plain_name(self):
|
||||
prefix, first, middle, last, suffix = name_parts(self.name)
|
||||
return u" ".join([first, last])
|
||||
if not hasattr(self, '_cached_plain_name'):
|
||||
prefix, first, middle, last, suffix = name_parts(self.name)
|
||||
self._cached_plain_name = u" ".join([first, last])
|
||||
return self._cached_plain_name
|
||||
def ascii_name(self):
|
||||
if not hasattr(self, '_cached_ascii_name'):
|
||||
if self.ascii:
|
||||
# It's possibly overkill with unidecode() here, but needed until
|
||||
# we're validating the content of the ascii field, and have
|
||||
# verified that the field is ascii clean in the database:
|
||||
self._cached_ascii_name = unidecode(self.ascii)
|
||||
else:
|
||||
self._cached_ascii_name = unidecode(self.plain_name())
|
||||
return self._cached_ascii_name
|
||||
def initials(self):
|
||||
return initials(self.ascii or self.name)
|
||||
def last_name(self):
|
||||
|
|
Loading…
Reference in a new issue