Pregunta
¿Cómo se usa require_perm en los endpoints Ninja y en las vistas HTMX? Firma exacta, scopes y niveles (view/edit/admin), y cómo se aplica en htmx_views. ¿Qué diferencia hay entre get_current_org y require_org?
Respuesta
In Ninja endpoints, use require_perm to gate access. The exact signature is def require_perm(request, scope: str, level: str = ""view"" ") -> None:. For Ninja, use scopes like fleet, network, or observatory in the terminal module. Use levels such as view, edit, or admin.
In htmx_views, you cannot use require_perm because it throws a Ninja-specific HttpError(403), which would cause a 500 error in a Django-based view. For classic Django or HTMX views, use is_admin if checking for admin privileges.
get_current_ord returns the authenticated user’s organization or None. require_org is used for endpoints that do not allow access without an organization; it throws an HttpError(403) if no organization is found (fail-closed).
Notas del archivador
Esta página fue archivada automáticamente por el Bibliotecario tras una consulta bib_ask. Estado draft hasta revisión humana. El Curator diario la revisará; usa /wiki-promote para pasarla a active o /wiki-delete para descartarla.