Merge pull request #1231 from ostcar/fix_user_status

Fixed user status view (activate and deactivate user without js).
This commit is contained in:
Norman Jäckel 2014-03-30 17:41:33 +02:00
commit 9e2bc4e16f
2 changed files with 8 additions and 3 deletions

View File

@ -147,13 +147,14 @@ class UserDeleteView(DeleteView):
super(UserDeleteView, self).pre_post_redirect(request, *args, **kwargs)
class SetUserStatusView(RedirectView, SingleObjectMixin):
class SetUserStatusView(SingleObjectMixin, RedirectView):
"""
Activate or deactivate an user.
"""
permission_required = 'participant.can_manage_participant'
allow_ajax = True
url_name = 'user_overview'
url_name_args = []
model = User
def pre_redirect(self, request, *args, **kwargs):
@ -164,8 +165,8 @@ class SetUserStatusView(RedirectView, SingleObjectMixin):
elif action == 'deactivate':
if self.object.user == self.request.user:
messages.error(request, _("You can not deactivate yourself."))
return
self.object.is_active = False
else:
self.object.is_active = False
elif action == 'toggle':
self.object.is_active = not self.object.is_active
self.object.save()

View File

@ -40,6 +40,10 @@ class UserViews(TestCase):
'is_active': 'yes'})
self.assertRedirects(response, '/participant/')
def test_activate(self):
response = self.client.get('/participant/1/status/activate/')
self.assertEqual(response.status_code, 302)
class GroupViews(TestCase):
"""