Merge pull request #1231 from ostcar/fix_user_status
Fixed user status view (activate and deactivate user without js).
This commit is contained in:
commit
9e2bc4e16f
@ -147,13 +147,14 @@ class UserDeleteView(DeleteView):
|
|||||||
super(UserDeleteView, self).pre_post_redirect(request, *args, **kwargs)
|
super(UserDeleteView, self).pre_post_redirect(request, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class SetUserStatusView(RedirectView, SingleObjectMixin):
|
class SetUserStatusView(SingleObjectMixin, RedirectView):
|
||||||
"""
|
"""
|
||||||
Activate or deactivate an user.
|
Activate or deactivate an user.
|
||||||
"""
|
"""
|
||||||
permission_required = 'participant.can_manage_participant'
|
permission_required = 'participant.can_manage_participant'
|
||||||
allow_ajax = True
|
allow_ajax = True
|
||||||
url_name = 'user_overview'
|
url_name = 'user_overview'
|
||||||
|
url_name_args = []
|
||||||
model = User
|
model = User
|
||||||
|
|
||||||
def pre_redirect(self, request, *args, **kwargs):
|
def pre_redirect(self, request, *args, **kwargs):
|
||||||
@ -164,8 +165,8 @@ class SetUserStatusView(RedirectView, SingleObjectMixin):
|
|||||||
elif action == 'deactivate':
|
elif action == 'deactivate':
|
||||||
if self.object.user == self.request.user:
|
if self.object.user == self.request.user:
|
||||||
messages.error(request, _("You can not deactivate yourself."))
|
messages.error(request, _("You can not deactivate yourself."))
|
||||||
return
|
else:
|
||||||
self.object.is_active = False
|
self.object.is_active = False
|
||||||
elif action == 'toggle':
|
elif action == 'toggle':
|
||||||
self.object.is_active = not self.object.is_active
|
self.object.is_active = not self.object.is_active
|
||||||
self.object.save()
|
self.object.save()
|
||||||
|
@ -40,6 +40,10 @@ class UserViews(TestCase):
|
|||||||
'is_active': 'yes'})
|
'is_active': 'yes'})
|
||||||
self.assertRedirects(response, '/participant/')
|
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):
|
class GroupViews(TestCase):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user