JourneyJoker/clients/mixins.py

18 lines
525 B
Python
Raw Normal View History

from django.urls import reverse_lazy
2021-05-26 16:42:22 +00:00
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):
2021-05-26 16:42:22 +00:00
return reverse_lazy("clients:register")
class ClientBaseMixin(MultiPermissionMixin):
MIXINS = [LoginRequiredMixin, ClientProfileRequiredMixin]