[PATCH v6 6/8] templates: Generate and use a "handle"
Daniel Axtens
dja at axtens.net
Wed Oct 26 20:39:32 AEDT 2016
Stephen Finucane <stephen at that.guru> writes:
> 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.
I'm a little nervous about:
- firstname at lastname.com domains
- me at name.com domains
- bob at companyA.com clashing with bob at companyB.com
...especially for something like kernel.org.
Is there any data supporting the assertion that conflict is low?
I would suggest some sort of fallback/uniqueness detection, but I can't
think of any way to do this in an efficient manner.
Just pondering...
Regards,
Daniel
>
> Signed-off-by: Stephen Finucane <stephen at that.guru>
> Reviewed-by: Andy Doan <andy.doan at linaro.org>
> ---
> patchwork/models.py | 7 +++++++
> patchwork/templatetags/person.py | 10 +++-------
> 2 files changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/patchwork/models.py b/patchwork/models.py
> index 49572ec..22c9bf1 100644
> --- a/patchwork/models.py
> +++ b/patchwork/models.py
> @@ -50,6 +50,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 adbabb0..8d12c03 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})
> - out = '<a href="%s?%s=%s">%s</a>' % (
> - url, SubmitterFilter.param, escape(person.id), linktext)
> + out = '<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(out)
> --
> 2.7.4
>
> _______________________________________________
> Patchwork mailing list
> Patchwork at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/patchwork
More information about the Patchwork
mailing list