|
12 | 12 | from django.template.loader import render_to_string |
13 | 13 | from django.utils.text import slugify |
14 | 14 |
|
| 15 | +import debug # pyflakes:ignore |
15 | 16 |
|
16 | 17 | from ietf.person.name import name_parts, initials |
17 | 18 | from ietf.utils.mail import send_mail_preformatted |
@@ -55,10 +56,22 @@ def ascii_name(self): |
55 | 56 | # It's possibly overkill with unidecode() here, but needed until |
56 | 57 | # we're validating the content of the ascii field, and have |
57 | 58 | # verified that the field is ascii clean in the database: |
58 | | - self._cached_ascii_name = unidecode(self.ascii) |
| 59 | + if not all(ord(c) < 128 for c in self.ascii): |
| 60 | + self._cached_ascii_name = unidecode(self.ascii).strip() |
| 61 | + else: |
| 62 | + self._cached_ascii_name = self.ascii |
59 | 63 | else: |
60 | | - self._cached_ascii_name = unidecode(self.plain_name()) |
| 64 | + self._cached_ascii_name = unidecode(self.plain_name()).strip() |
61 | 65 | return self._cached_ascii_name |
| 66 | + def plain_ascii(self): |
| 67 | + if not hasattr(self, '_cached_plain_ascii'): |
| 68 | + if self.ascii: |
| 69 | + ascii = unidecode(self.ascii).strip() |
| 70 | + else: |
| 71 | + ascii = unidecode(self.name).strip() |
| 72 | + prefix, first, middle, last, suffix = name_parts(ascii) |
| 73 | + self._cached_plain_ascii = u" ".join([first, last]) |
| 74 | + return self._cached_plain_ascii |
62 | 75 | def initials(self): |
63 | 76 | return initials(self.ascii or self.name) |
64 | 77 | def last_name(self): |
|
0 commit comments