From 147627ac5d1a46cf70065ca8fe96ef371d0181c9 Mon Sep 17 00:00:00 2001 From: Piotr Zalewa Date: Thu, 23 Feb 2012 19:43:04 +0100 Subject: [PATCH 1/2] use username if questionmark in nickname --- apps/person/management/commands/fix_unicode_users.py | 4 ++-- apps/person/models.py | 4 +++- apps/person/templates/_dashboard_info.html | 2 +- apps/person/tests.py | 10 ++++++++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/apps/person/management/commands/fix_unicode_users.py b/apps/person/management/commands/fix_unicode_users.py index 401c0a3b..5c852cc8 100644 --- a/apps/person/management/commands/fix_unicode_users.py +++ b/apps/person/management/commands/fix_unicode_users.py @@ -20,6 +20,6 @@ class Command(BaseCommand): """ profiles = Profile.objects.filter(nickname__contains='?') for profile in profiles: - self.stdout.write("* Updating nickname: %s (%s)\n" % ( - profile.nickname, profile.user.email)) + self.stdout.write("[%s] Updating nickname: %s (%s)\n" % ( + profile.user.username, profile.nickname, profile.user.email)) profile.update_from_AMO() diff --git a/apps/person/models.py b/apps/person/models.py index 05c0f4a9..dd970c18 100644 --- a/apps/person/models.py +++ b/apps/person/models.py @@ -53,7 +53,9 @@ class Profile(models.Model): return reverse('jp_browser_user_libraries', args=[self.get_nickname()]) def get_profile_url(self): - return reverse('person_public_profile', args=[self.get_nickname()]) + if self.nickname and not '?' in self.nickname: + return reverse('person_public_profile', args=[self.nickname]) + return reverse('person_public_profile', args=[self.user.username]) def update_from_AMO(self, data=None): if not data: diff --git a/apps/person/templates/_dashboard_info.html b/apps/person/templates/_dashboard_info.html index fc207f45..aa191bb2 100644 --- a/apps/person/templates/_dashboard_info.html +++ b/apps/person/templates/_dashboard_info.html @@ -18,6 +18,6 @@ diff --git a/apps/person/tests.py b/apps/person/tests.py index 44b1dabb..e155eced 100644 --- a/apps/person/tests.py +++ b/apps/person/tests.py @@ -60,6 +60,16 @@ class ProfileTest(TestCase): response = self.client.get(reverse('person_dashboard')) eq_(response.status_code, 200) + def test_dashboard_with_question_mark(self): + user = User.objects.create(username='12345') + profile = Profile.objects.create(user=user, nickname='b?c') + user.set_password('secure') + user.save() + self.client.login(username=user.username, password='secure') + response = self.client.get(reverse('person_dashboard')) + eq_(response.status_code, 200) + eq_(profile.get_profile_url(), '/user/%s/' % user.username) + def test_fake_profile(self): resp = self.client.get(reverse('person_public_profile', args=['xxx'])) eq_(404, resp.status_code) From 0e5d6ac8c889c0011beff6924f8d9c43d7d4a84b Mon Sep 17 00:00:00 2001 From: Piotr Zalewa Date: Thu, 23 Feb 2012 19:47:21 +0100 Subject: [PATCH 2/2] use unly username until utf-8 in nickname will be solved --- apps/person/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/person/models.py b/apps/person/models.py index dd970c18..87798003 100644 --- a/apps/person/models.py +++ b/apps/person/models.py @@ -53,8 +53,8 @@ class Profile(models.Model): return reverse('jp_browser_user_libraries', args=[self.get_nickname()]) def get_profile_url(self): - if self.nickname and not '?' in self.nickname: - return reverse('person_public_profile', args=[self.nickname]) + #if self.nickname and not '?' in self.nickname: + # return reverse('person_public_profile', args=[self.nickname]) return reverse('person_public_profile', args=[self.user.username]) def update_from_AMO(self, data=None):