feat(cabana): mail templates screen over postcard overrides

- Settings -> Mail -> Mail templates in the internal pseudo-plugin when
  postcard's Mailer is published; system.manage_mail_templates and
  system.manage_mail_layouts registered with no role grants
- MailTemplate/MailLayout models, catalog-scoped list and form, layout
  relation over file and custom layouts, no create or delete
- save stamps is_custom, base_hash and customized_at and validates the
  override through postcard.Editor inside the save transaction
- serve-start postcard.SyncIndex through lagoon.OnDatabase, retried on
  the first mail list request
- copy en/pl, README and docs; TestMailScreensSmoke/templates

Plan 35-02, task 1
This commit is contained in:
Jakub Zych
2026-11-13 11:45:13 +01:00
parent 2acf8e46c4
commit 7efb9ed7ad
13 changed files with 1046 additions and 9 deletions

View File

@@ -70,6 +70,13 @@ A controller's `pact.AdminPermissioned.RequiredPermissions` are checked before a
The admin registers three permissions of its own on the System tab of the permission editor: `backend.manage_users` (`cabana.PermissionManageUsers`) opens the Administrators screen, `backend.manage_roles` (`cabana.PermissionManageRoles`) the Roles screen and `backend.view_plugins` (`cabana.PermissionViewPlugins`) the read-only Plugins screen (see [Admin SPA](admin-spa.md#plugins-screen)). None is granted to any role in code, so after an upgrade only superusers reach those screens until an administrator grants a code to a role or to an administrator.
When the application publishes postcard's Mailer (every application does, through `party.Activate`), the admin also registers two mail codes on the same tab:
- `system.manage_mail_templates` (`cabana.PermissionManageMailTemplates`) opens Settings → Mail → Mail templates, where an administrator edits the subject, message and layout of every mail template, previews it and sends a test to their own address.
- `system.manage_mail_layouts` (`cabana.PermissionManageMailLayouts`) opens the other Mail screens: layouts, partials, branding and the mail image library. These change every message the application sends, so the code is separate.
Neither is granted to any role in code either. An administrator holding only the templates code sees one Mail tile in Settings and is refused the other mail screens. See [Mail](../services/mail.md#editing-mail-in-the-admin).
An administrator's grants are the role's `permissions` merged with the administrator's own `backend_users.permissions`, the way WinterCMS merges them: the administrator's value for a code replaces the role's, and only `1` grants. A `-1` (or `0`) on the administrator therefore removes a permission the role grants, so rows copied from a WinterCMS database keep their denies. As in WinterCMS the merge compares codes exactly, so denying `acme.blog.access_posts` does not take it back from a role that grants `acme.blog.*`.
Actions registered through `pact.HasAdminActions`, bulk actions (`pact.HasAdminBulkActions`) and record actions (`pact.HasAdminRecordActions`) may each name extra permissions, checked on top of the controller's. An administrator who lacks them does not get the action in the list schema or in a record's `meta.actions`, and posting it answers 403 and is written to the authentication log. A bulk, record, toolbar or widget action that ran is logged with the controller, the action and the administrator, plus the affected count for a bulk action, the record id for a record action (and for a widget action posted from a saved record), and the kind `toolbar` or `field` for the other two, without record contents, posted values or payload.