Commits

Patrick Samson committed 2b3fdd0

'or_me' filter improvement

Comments (0)

Files changed (2)

postman/models.py

         shrunken_digest = '..'.join((digest[:4], digest[-4:])) # 32 characters is too long and is useless
         bits = email.split('@')
         if len(bits) <> 2:
-            return ''
+            return u''
         domain = bits[1]
         return '@'.join((shrunken_digest, domain.rsplit('.',1)[0])) # leave off the TLD to gain some space
 
     def obfuscated_sender(self):
         """Return the sender either as a username or as an undisclosed email."""
         if self.sender:
-            return str(self.sender)
+            return unicode(self.sender)
         else:
             return self._obfuscated_email()
 
     def obfuscated_recipient(self):
         """Return the recipient either as a username or as an undisclosed email."""
         if self.recipient:
-            return str(self.recipient)
+            return unicode(self.recipient)
         else:
             return self._obfuscated_email()
 

postman/templatetags/postman_tags.py

     Typical usage: sender|or_me:user
 
     """
-    return _('<me>') if str(value) == str(arg) else value
+    if not isinstance(value, (unicode, str)):
+        value = unicode(value)
+    if not isinstance(arg, (unicode, str)):
+        arg = unicode(arg)
+    return _('<me>') if value == arg else value
 
 @register.filter
 def compact_date(value, arg):