Merge pull request #134 from zalun/username_if_wrong_nickname

Username if wrong nickname
This commit is contained in:
Arron Schaar 2012-02-23 10:49:06 -08:00
Родитель a1b618dc85 0e5d6ac8c8
Коммит ed25383c4b
4 изменённых файлов: 16 добавлений и 4 удалений

Просмотреть файл

@ -20,6 +20,6 @@ class Command(BaseCommand):
""" """
profiles = Profile.objects.filter(nickname__contains='?') profiles = Profile.objects.filter(nickname__contains='?')
for profile in profiles: for profile in profiles:
self.stdout.write("* Updating nickname: %s (%s)\n" % ( self.stdout.write("[%s] Updating nickname: %s (%s)\n" % (
profile.nickname, profile.user.email)) profile.user.username, profile.nickname, profile.user.email))
profile.update_from_AMO() profile.update_from_AMO()

Просмотреть файл

@ -53,7 +53,9 @@ class Profile(models.Model):
return reverse('jp_browser_user_libraries', args=[self.get_nickname()]) return reverse('jp_browser_user_libraries', args=[self.get_nickname()])
def get_profile_url(self): 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): def update_from_AMO(self, data=None):
if not data: if not data:

Просмотреть файл

@ -18,6 +18,6 @@
<ul class="seeProfile"> <ul class="seeProfile">
<li> <li>
See your See your
<a title="" href="{{ url('person_public_profile', profile.nickname or user.username) }}">public profile</a> <a title="" href="{{ profile.get_profile_url() }}">public profile</a>
</li> </li>
</ul> </ul>

Просмотреть файл

@ -60,6 +60,16 @@ class ProfileTest(TestCase):
response = self.client.get(reverse('person_dashboard')) response = self.client.get(reverse('person_dashboard'))
eq_(response.status_code, 200) 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): def test_fake_profile(self):
resp = self.client.get(reverse('person_public_profile', args=['xxx'])) resp = self.client.get(reverse('person_public_profile', args=['xxx']))
eq_(404, resp.status_code) eq_(404, resp.status_code)