1. Kenneth Love
  2. django-postman


Patrick Samson  committed 2b3fdd0

'or_me' filter improvement

  • Participants
  • Parent commits 0e80f45
  • Branches default

Comments (0)

Files changed (2)

File postman/models.py

View file
         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)
             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)
             return self._obfuscated_email()

File postman/templatetags/postman_tags.py

View file
     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
 def compact_date(value, arg):