2021-05-26 12:08:15 +00:00
|
|
|
from django.urls import reverse_lazy
|
|
|
|
|
2021-05-26 16:42:22 +00:00
|
|
|
from localauth.mixins import UserPassesTestMixin, MultiPermissionMixin, LoginRequiredMixin
|
2021-04-11 06:36:19 +00:00
|
|
|
|
2021-05-26 12:08:15 +00:00
|
|
|
class ClientProfileRequiredMixin(UserPassesTestMixin):
|
2021-04-11 06:36:19 +00:00
|
|
|
def test_func(self):
|
|
|
|
try:
|
|
|
|
assert self.request.user.clientprofile
|
|
|
|
return True
|
|
|
|
except:
|
2021-05-26 12:08:15 +00:00
|
|
|
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]
|