[PATCH 06/10] templates: Generate and use a "handle"

Andy Doan andy.doan at linaro.org
Fri Jun 24 04:24:55 AEST 2016


On 06/13/2016 05:41 AM, Stephen Finucane wrote:
> In the absence of a name, the email is currently used. Some emails are
> long and rather unreadable. The likelihood of someone's localpart (i.e.
> the bit before the '@') conflicting with that of someone else on the
> same patchwork instance and project is very low, so form a "handle"
> from just this.
>
> Signed-off-by: Stephen Finucane <stephen.finucane at intel.com>

Reviewed-by: Andy Doan <andy.doan at linaro.org>

> ---
>   patchwork/bin/parsemail.py       |    2 +-
>   patchwork/models.py              |    7 +++++++
>   patchwork/templatetags/person.py |   12 ++++--------
>   3 files changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/patchwork/bin/parsemail.py b/patchwork/bin/parsemail.py
> index 8baacf6..ddcd9e7 100755
> --- a/patchwork/bin/parsemail.py
> +++ b/patchwork/bin/parsemail.py
> @@ -284,7 +284,7 @@ def parse_version(subject, subject_prefixes):
>       if m:
>           return int(m.group(1))
>
> -    m = re.search(r'\(([vV]\d+)\)', subject)
> +    m = re.search(r'\([vV](\d+)\)', subject)
>       if m:
>           return int(m.group(1))

got a bit confused on this, until I realized it belonged in patch 4.

> diff --git a/patchwork/models.py b/patchwork/models.py
> index 67ea012..d2d4079 100644
> --- a/patchwork/models.py
> +++ b/patchwork/models.py
> @@ -54,6 +54,13 @@ class Person(models.Model):
>           self.name = user.profile.name
>           self.user = user
>
> +    @property
> +    def handle(self):
> +        if self.user:
> +            return self.user.name
> +        else:
> +            return self.email.split('@')[0]
> +
>       def __str__(self):
>           if self.name:
>               return '%s <%s>' % (self.name, self.email)
> diff --git a/patchwork/templatetags/person.py b/patchwork/templatetags/person.py
> index 7af021f..98c0f2b 100644
> --- a/patchwork/templatetags/person.py
> +++ b/patchwork/templatetags/person.py
> @@ -33,14 +33,10 @@ register = template.Library()
>   @register.filter
>   def personify(person, project):
>
> -    if person.name:
> -        linktext = escape(person.name)
> -    else:
> -        linktext = escape(person.email)
> -
>       url = reverse('patch-list',
>                     kwargs={'project_id': project.linkname})
> -    str = '<a href="%s?%s=%s">%s</a>' % (
> -        url, SubmitterFilter.param, escape(person.id), linktext)
> +    elem = '<a href="%s?%s=%s" title="%s">%s</a>' % (
> +        url, SubmitterFilter.param, escape(person.id), str(person),
> +        person.name or person.handle)
>
> -    return mark_safe(str)
> +    return mark_safe(elem)
>



More information about the Patchwork mailing list