JourneyJoker/clients/mixins.py

17 lines
525 B
Python

from django.urls import reverse_lazy
from localauth.mixins import UserPassesTestMixin, MultiPermissionMixin, LoginRequiredMixin
class ClientProfileRequiredMixin(UserPassesTestMixin):
def test_func(self):
try:
assert self.request.user.clientprofile
return True
except:
return False
def get_login_url(self):
return reverse_lazy("clients:register")
class ClientBaseMixin(MultiPermissionMixin):
MIXINS = [LoginRequiredMixin, ClientProfileRequiredMixin]