From: yomguy Date: Thu, 14 Feb 2013 17:51:03 +0000 (+0100) Subject: first and last name in place of the username X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=debf601005ed879668363ddc7c7a6676b3c702b5;p=django-postman.git first and last name in place of the username --- diff --git a/postman/models.py b/postman/models.py index 5174af5..fa592b4 100644 --- a/postman/models.py +++ b/postman/models.py @@ -45,7 +45,7 @@ def get_order_by(query_dict): ``query_dict``: a dictionary to look for a key dedicated to ordering purpose >>> get_order_by({}) - + >>> get_order_by({ORDER_BY_KEY: 'f'}) 'sender__username' >>> get_order_by({ORDER_BY_KEY: 'D'}) @@ -119,7 +119,7 @@ class MessageManager(models.Manager): """ return self.inbox(user, related=False, option=OPTION_MESSAGES).filter(read_at__isnull=True).count() - + def sent(self, user, **kwargs): """ Return all messages sent by a user but not marked as archived or deleted. diff --git a/postman/templatetags/postman_tags.py b/postman/templatetags/postman_tags.py index 4b3bad7..da421f8 100644 --- a/postman/templatetags/postman_tags.py +++ b/postman/templatetags/postman_tags.py @@ -33,10 +33,9 @@ def or_me(value, arg): Typical usage: sender|or_me:user """ - if not isinstance(value, (unicode, str)): - value = unicode(value) - if not isinstance(arg, (unicode, str)): - arg = unicode(arg) + value = unicode(value.first_name) + ' ' + unicode(value.last_name) + arg = unicode(arg.first_name) + ' ' + unicode(arg.last_name) + return _('') if value == arg else value @register.filter(**({'expects_localtime': True, 'is_safe': False} if VERSION >= (1, 4) else {}))