Message ID | 1476051921-24922-6-git-send-email-stephen@that.guru |
---|---|
State | Superseded |
Headers | show |
On 10/10/16 09:25, 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@that.guru> > Reviewed-by: Andy Doan <andy.doan@linaro.org> Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
diff --git a/patchwork/models.py b/patchwork/models.py index 4a55c1d..26cae9f 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)