docs: def has_site_permission(user):
      """
      Checks if a staff user has staff-level access for the current site.
      The actual permission lookup occurs in ``SitePermissionMiddleware``
      which then marks the request with the ``has_site_permission`` flag,
      so that we only query the db once per request, so this function
      serves as the entry point for everything else to check access. We
      also fall back to an ``is_staff`` check if the middleware is not
      installed, to ease migration.
      """
      mw = "yacms.core.middleware.SitePermissionMiddleware"
      if mw not in get_middleware_setting():
          from warnings import warn
          warn(mw + " missing from settings.MIDDLEWARE - per site"
               "permissions not applied")
          return user.is_staff and user.is_active
      return getattr(user, "has_site_permission", False)