from django.contrib.auth.mixins import UserPassesTestMixin


class UserIsOrgaMixin(UserPassesTestMixin):
    """
    The view is accessible only if the request user is orga or superuser
    """

    def test_func(self):
        return (
            self.get_object().orga == self.request.user
            or self.request.user.is_superuser
        )
