From a4d520561ab276ec04785a1d41ede6e0dd0fb94b Mon Sep 17 00:00:00 2001 From: Sergio Oliveira Date: Wed, 25 Sep 2013 14:38:21 -0300 Subject: [PATCH] Fixing profile link --- src/accounts/models.py | 5 +++++ src/super_archives/templates/message-preview.html | 15 ++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/accounts/models.py b/src/accounts/models.py index f5effec..9416823 100644 --- a/src/accounts/models.py +++ b/src/accounts/models.py @@ -2,6 +2,8 @@ from django.db import models from django.contrib.auth.models import AbstractUser +from django.core.urlresolvers import reverse + class User(AbstractUser): institution = models.CharField(max_length=128, null=True, blank=True) @@ -12,6 +14,9 @@ class User(AbstractUser): webpage = models.CharField(max_length=256, null=True, blank=True) verification_hash = models.CharField(max_length=32, null=True, blank=True) + def get_absolute_url(self): + return reverse('user_profile', kwargs={'username': self.username}) + # We need to have `email` field set as unique but Django does not # support field overriding (at least not until 1.6). # The following workaroud allows to change email field to unique diff --git a/src/super_archives/templates/message-preview.html b/src/super_archives/templates/message-preview.html index 8b08327..7b457e9 100644 --- a/src/super_archives/templates/message-preview.html +++ b/src/super_archives/templates/message-preview.html @@ -33,13 +33,18 @@
- {% trans "by" %} - {% if doc.from_address.get_full_name %} - - {{ doc.from_address.get_full_name }} + {% if doc.from_address.user.get_absolute_url or doc.from_address.get_full_name or doc.last_author or doc.Creator %} + {% trans "by" %} + {% endif %} + + {% if doc.from_address.user.get_absolute_url %} + + {{ doc.from_address.user.get_full_name }} + {% elif doc.from_address.get_full_name %} + {{ doc.from_address.get_full_name }} {% else %} - {% firstof doc.last_author doc.Creator _("anonymous") %} + {% firstof doc.last_author doc.Creator "" %} {% endif %} -- libgit2 0.21.2