]> git.openstreetmap.org Git - osqa.git/commitdiff
OSQA-617, better Unicode support for the User Profile and User Links. Using the Djang...
authorjordan <jordan@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Sun, 10 Apr 2011 16:38:27 +0000 (16:38 +0000)
committerjordan <jordan@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Sun, 10 Apr 2011 16:38:27 +0000 (16:38 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@960 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/models/user.py
forum/registry.py
forum/views/users.py

index e7365388eb2efce62bfba607f9b8be18f06839e5..665c4d46dd17356351e3e3c8e72992beb2e03777 100644 (file)
@@ -5,6 +5,8 @@ from django.contrib.contenttypes.models import ContentType
 from django.contrib.auth.models import User as DjangoUser, AnonymousUser as DjangoAnonymousUser
 from django.db.models import Q
 
+from django.utils.encoding import smart_unicode
+
 from forum.settings import TRUNCATE_LONG_USERNAMES, TRUNCATE_USERNAMES_LONGER_THAN
 
 import string
@@ -129,7 +131,7 @@ class User(BaseModel, DjangoUser):
     vote_down_count = DenormalizedField("actions", canceled=False, action_type="votedown")
 
     def __unicode__(self):
-        return self.username
+        return smart_unicode(self.username)
 
     @property
     def prop(self):
@@ -148,7 +150,7 @@ class User(BaseModel, DjangoUser):
 
     @property
     def decorated_name(self):
-        username = self.username
+        username = smart_unicode(self.username)
 
         if len(username) > TRUNCATE_USERNAMES_LONGER_THAN and TRUNCATE_LONG_USERNAMES:
             username = '%s...' % username[:TRUNCATE_USERNAMES_LONGER_THAN-3]
@@ -196,7 +198,7 @@ class User(BaseModel, DjangoUser):
 
     @models.permalink
     def get_profile_url(self):
-        return ('user_profile', (), {'id': self.id, 'slug': slugify(self.username)})
+        return ('user_profile', (), {'id': self.id, 'slug': slugify(smart_unicode(self.username))})
 
     def get_absolute_url(self):
         return self.get_profile_url()
index 43f11a7ac613e84e4c36a74b122579adfba966f2..ec973895e546aa70904168e993651d07fbf67554 100644 (file)
@@ -1,5 +1,6 @@
 from forum.modules import ui, get_modules_script
 from django.utils.translation import ugettext as _
+from django.utils.encoding import smart_unicode
 from django.core.urlresolvers import reverse
 from django.template.defaultfilters import slugify
 
@@ -29,7 +30,7 @@ ui.register(ui.HEADER_LINKS,
 
             ui.Link(
                     visibility=ui.Visibility.AUTHENTICATED,
-                    text=lambda u, c: u.username,
+                    text=lambda u, c: smart_unicode(u.username),
                     url=lambda u, c: u.get_profile_url(),
                     post_code=lambda u, c: get_score_badge(u),
                     weight=100, name='ACCOUNT'),
index e8f141c424001b96e745a3c7073ba5db8b88a121..8766851c31faa021833881ebd3f2f463ff7be8da 100644 (file)
@@ -11,6 +11,7 @@ from forum.http_responses import HttpResponseUnauthorized
 from django.utils.translation import ugettext as _\r
 from django.utils.http import urlquote_plus\r
 from django.utils.html import strip_tags\r
+from django.utils.encoding import smart_unicode\r
 from django.utils import simplejson\r
 from django.core.urlresolvers import reverse, NoReverseMatch\r
 from forum.forms import *\r
@@ -269,7 +270,7 @@ def user_view(template, tab_name, tab_title, tab_description, private=False, tab
         decorated = decorate.params.withfn(params)(fn)\r
 \r
         def result(context, request, user):\r
-            rev_page_title = user.username + " - " + tab_description\r
+            rev_page_title = smart_unicode(user.username) + " - " + tab_description\r
 \r
             context.update({\r
                 "tab": "users",\r