1
0
Fork 0
mirror of https://github.com/Findus23/RPGnotes.git synced 2024-09-19 15:43:45 +02:00
RPGnotes/utils/mixin.py

18 lines
604 B
Python
Raw Normal View History

2021-08-29 22:09:22 +02:00
from django.contrib.auth.mixins import AccessMixin
2021-09-06 21:10:55 +02:00
from django.core.exceptions import PermissionDenied
2021-08-29 22:09:22 +02:00
from users.models import TenantUser
class PartOfTenantRequiredMixin(AccessMixin):
"""Verify that the current user is authenticated."""
permission_denied_message = "You are not part of this campaign"
def dispatch(self, request, *args, **kwargs):
current_user: TenantUser = self.request.user
if not current_user.tenants.filter(pk=self.request.tenant.pk).exists():
return self.handle_no_permission()
return super().dispatch(request, *args, **kwargs)