Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Inactive user profiles are 404s.

  • Loading branch information...
commit 4524ce83b4c730cd09e624df7d3f8b0500250d8a 1 parent 33d3c72
James Socol authored
Showing with 28 additions and 2 deletions.
  1. +25 −1 apps/users/tests/test_views.py
  2. +3 −1 apps/users/views.py
View
26 apps/users/tests/test_views.py
@@ -395,4 +395,28 @@ def test_create_setting(self):
res = self.client.post(url, {'forums_watch_new_thread': True},
follow=True)
eq_(200, res.status_code)
- eq_(Setting.get_for_user(self.user, 'forums_watch_new_thread'), True)
+ assert Setting.get_for_user(self.user, 'forums_watch_new_thread')
+
+
+class UserProfileTests(TestCase):
+ def setUp(self):
+ self.user = user()
+ self.user.save()
+ self.profile = profile(self.user)
+ self.url = reverse('users.profile', args=[self.user.pk],
+ locale='en-US')
+
+ def test_profile(self):
+ res = self.client.get(self.url)
+ self.assertContains(res, self.user.username)
+
+ def test_profile_inactive(self):
+ """Inactive users don't have a public profile."""
+ self.user.is_active = False
+ self.user.save()
+ res = self.client.get(self.url)
+ eq_(404, res.status_code)
+
+ def test_profile_post(self):
+ res = self.client.post(self.url)
+ eq_(405, res.status_code)
View
4 apps/users/views.py
@@ -189,8 +189,10 @@ def confirm_change_email(request, activation_key):
'username': u.username, 'duplicate': duplicate})
+@require_GET
def profile(request, user_id):
- user_profile = get_object_or_404(Profile, user__id=user_id)
+ user_profile = get_object_or_404(Profile, user__id=user_id,
+ user__is_active=True)
groups = user_profile.user.groups.all()
return jingo.render(request, 'users/profile.html',
{'profile': user_profile, 'groups': groups})
Please sign in to comment.
Something went wrong with that request. Please try again.