def check_can_access(self, request, can_retry=True, **kwargs):
        project = self.get_project(**kwargs)
        if not project.can_access(request.user):
            if (
                project.organization and
                can_retry and
                request.user.is_authenticated()
            ):
                Project.objects.update_user_projects(request.user)
                return self.check_can_access(request, False)
            elif not request.user.is_authenticated():
                return redirect_to_login(
                    request.get_full_path(),
                    self.get_login_url(),
                    self.get_redirect_field_name(),
                )
            raise PermissionDenied
Check can user access
dataset/ETHPy150Open nvbn/coviolations_web/projects/utils.py/ProjectAccessMixin.check_can_access