Expand description
R-CMS admin section.
Mounts at /cms-admin/ (distinct from rustango’s /__admin/ —
the framework admin’s POST handlers do raw insert_returning
against the DB, bypassing our Page::create_root /
Page::create_child paths and producing malformed rows with
empty path, depth = 0, and no type-whitelist enforcement).
This module owns the page-tree-aware CRUD surface. router is
unauthenticated on its own: wrap it in with_login_required, which
redirects anonymous visitors to the login URL and requires the
cms_admin.access codename (or superuser) of signed-in users.
§Wiring
ⓘ
use std::sync::Arc;
use tera::Tera;
let mut tera = Tera::new("templates/**/*.html")?;
rustango_cms::admin::register_templates(&mut tera)?;
let tera = Arc::new(tera);
let cms_admin = rustango_cms::admin::with_login_required(
rustango_cms::admin::router(tera.clone()),
"/login",
);
let router = Router::new()
.merge(cms_admin)
.merge(rustango_cms::router(tera));Modules§
- admin_
page - Extension point for custom admin pages.
- chooser
- Generic chooser registry — register a chooser for any
#[derive(Model)]type, generalising the three hand-rolled choosers (page / snippet / document). - cms_
admin - A generic admin editor for a host app’s own models.
- model_
admin - Generic model-admin — a
ModelViewSet-style CRUD admin for arbitrary#[derive(Model)]types, rendered inside the CMS admin chrome. - pagination
- Shared pagination context for admin list pages.
- report
- Extensible report framework — a registerable
Reporttrait - resources
- Admin-resource registry — single source of truth for the CRUD
permissions matrix on
/cms-admin/roles/{id}/edit.
Structs§
- List
Query - Query string for the page list / search view.
- Page
Form - Form payload for the new-page and edit-page POST handlers.
Enums§
- Member
Login Error - Why a member sign-in was refused.
Constants§
- NOTIFICATION_
MANAGE_ CODENAME - Permission gating notification destinations — see
notifications::CODENAME. Permission required to manage notification destinations. - SITE_
MANAGE_ CODENAME - Permission gating hostname → root-page mappings — see
sites::CODENAME. Permission required to bind hostnames to pages. - TEMPLATE_
EDIT_ CODENAME - Permission codename gating the per-tenant template editor. Re-exported so seeding and the handler cannot drift apart on the string. Permission required to read or write templates.
Functions§
- add_
chrome - Fill a template context with the admin chrome — sidebar, branding, locale, the signed-in user.
- authenticate_
member - Sign a member in by username OR (lowercased) email + password, in
tenant_slug(the tenantpoolbelongs to). - extend_
ui_ catalog - Merge host-supplied UI-catalog entries into the shared admin translator
so a consumer’s own template chrome localizes through the same
translatebinding without clobbering the admin catalog. Merge extra UI-catalog entries into the shared admin translator’s per-locale catalogs, so a host that also wants to localize its own hardcoded template chrome can feed those strings through the SAMEtranslate(locale=LANG)binding instead of registering a competing one (which would silently clobber the admin catalog — see rcms-blog). - issue_
password_ reset_ link - A one-hour password-reset link for the active user
usernameoforg, whose tenant database ispool, orNonewhen there is no such user. - public_
router - Companion to
router— routes that must remain reachable without authentication (password reset). Host apps merge this alongside the protected admin router so anonymous visitors can hit/cms-admin/password-reset*even when the rest of/cms-admin/*is gated bywith_login_required. - public_
router_ with_ mailer - Like
public_router, with the mailer that sends password-reset emails. Without it/cms-admin/password-resetaccepts the request but can’t send anything. Pass the same mailer andFrom:address asrouter_with_mailer. - register_
templates - Register the bundled admin templates and the Tera helpers
they depend on (named URL reversal via
{{ url(...) }}, the{% querystring %}filter,humanizefilters, and thecsrf_inputfilter) on aTerainstance. - router
- Build the admin router. Mount with
Router::mergein the host app’s main router. - router_
with_ invalidator - Like
routerbut takes a page-cache invalidator. Hosts using the public router’sCachePageLayershould wire the same cache backend into acrate::cache_invalidate::BoxedCacheInvalidatorso admin saves purge the matching cache keys immediately. - router_
with_ mailer - Like
routerbut takes both a cache invalidator AND a mailer. The mailer powers workflow notifications — submit / approve / reject / cancel each fire emails to the relevant parties.from_addris theFrom:address stamped onto every notification. - with_
cms_ admin_ access - Gate the CMS-admin router on the
cms_admin.accesscodename. - with_
codename_ gate - Hard-gate
routeron an arbitrary permission codename — the generalized form ofwith_cms_admin_access. A non-superuser lackingcodenameis redirected tono_access_url; superusers pass; anonymous flows fall through to the layeredlogin_requiredbounce. Static assets + the no-access page itself always pass so the redirect can’t loop and the page can style itself. - with_
login_ required - Layer
rustango::auth_decorators::login_requiredon top of the supplied router. Every protected route 302s anonymous visitors tologin_urlwith?next=<original_url>so the framework’s login handler can resume them after auth.