Commit a4d520561ab276ec04785a1d41ede6e0dd0fb94b
1 parent
cd40a6d9
Exists in
master
and in
39 other branches
Fixing profile link
Showing
2 changed files
with
15 additions
and
5 deletions
Show diff stats
src/accounts/models.py
... | ... | @@ -2,6 +2,8 @@ |
2 | 2 | from django.db import models |
3 | 3 | from django.contrib.auth.models import AbstractUser |
4 | 4 | |
5 | +from django.core.urlresolvers import reverse | |
6 | + | |
5 | 7 | |
6 | 8 | class User(AbstractUser): |
7 | 9 | institution = models.CharField(max_length=128, null=True, blank=True) |
... | ... | @@ -12,6 +14,9 @@ class User(AbstractUser): |
12 | 14 | webpage = models.CharField(max_length=256, null=True, blank=True) |
13 | 15 | verification_hash = models.CharField(max_length=32, null=True, blank=True) |
14 | 16 | |
17 | + def get_absolute_url(self): | |
18 | + return reverse('user_profile', kwargs={'username': self.username}) | |
19 | + | |
15 | 20 | # We need to have `email` field set as unique but Django does not |
16 | 21 | # support field overriding (at least not until 1.6). |
17 | 22 | # The following workaroud allows to change email field to unique | ... | ... |
src/super_archives/templates/message-preview.html
... | ... | @@ -33,13 +33,18 @@ |
33 | 33 | |
34 | 34 | <div class="quiet"> |
35 | 35 | <span class="pull-left"> |
36 | - {% trans "by" %} | |
37 | - {% if doc.from_address.get_full_name %} | |
38 | - <a href="{{ doc.from_address.get_profile_link }}"> | |
39 | - {{ doc.from_address.get_full_name }} | |
36 | + {% if doc.from_address.user.get_absolute_url or doc.from_address.get_full_name or doc.last_author or doc.Creator %} | |
37 | + {% trans "by" %} | |
38 | + {% endif %} | |
39 | + | |
40 | + {% if doc.from_address.user.get_absolute_url %} | |
41 | + <a href="{{ doc.from_address.user.get_absolute_url }}"> | |
42 | + {{ doc.from_address.user.get_full_name }} | |
40 | 43 | </a> |
44 | + {% elif doc.from_address.get_full_name %} | |
45 | + <span>{{ doc.from_address.get_full_name }}</span> | |
41 | 46 | {% else %} |
42 | - {% firstof doc.last_author doc.Creator _("anonymous") %} | |
47 | + {% firstof doc.last_author doc.Creator "" %} | |
43 | 48 | {% endif %} |
44 | 49 | </span> |
45 | 50 | ... | ... |