academon/core/mixins/auth.py

12 lines
334 B
Python
Raw Normal View History

2022-08-08 09:43:31 +00:00
from django.contrib.auth.mixins import UserPassesTestMixin
from django.contrib import messages
class SuperuserRequiredMixin(UserPassesTestMixin):
def test_func(self):
return self.request.user.is_superuser
class StaffRequiredMixin(UserPassesTestMixin):
def test_func(self):
return self.request.user.is_staff