16 lines
606 B
Python
16 lines
606 B
Python
|
class SuperUserRequiredMixin(object):
|
||
|
"""
|
||
|
View mixin which requires that the authenticated user is a super user
|
||
|
(i.e. `is_superuser` is True).
|
||
|
"""
|
||
|
|
||
|
@method_decorator(login_required)
|
||
|
def dispatch(self, request, *args, **kwargs):
|
||
|
if not request.user.is_superuser:
|
||
|
messages.error(
|
||
|
request,
|
||
|
'You do not have the permission required to perform the '
|
||
|
'requested operation.')
|
||
|
return redirect(settings.LOGIN_URL)
|
||
|
return super(SuperUserRequiredMixin, self).dispatch(request,
|
||
|
*args, **kwargs)
|