MishkaCmsCore.Runtime.Resources.Actions.RestoreVersion (Mishka CMS Core v0.0.1)

Copy Markdown View Source

The body of a versioned resource's :restore_version_api (a site's own call) and :master_restore_version (a master's) generic actions: read the record, refuse what may not be restored, check that the version is one of THIS record's, and run the resource's :restore_version update with the record's own site as the tenant.

The outer action is authorized by the resource's policies; the reads and the update here run as the system, so the checks below are the whole of what stands between a caller and the record.

Options

  • :resource and :version — the resource and its AshPaperTrail version resource. The version resource must have a :get_any read, and the resource a :restore_version update.
  • :read — the read action that finds the record: :read for a site's call, :master_get for a master's, :get_any for a resource that may be global.
  • :tenant_read? — read in the tenant of SiteWithGlobals.acting_site/1 (a site's call on a resource that is never global).
  • :global? — a site's call on a resource that may be global: a global record is not found by a caller with no site, and may not be restored by a site (:global words the refusal).
  • :archived and :foreign — the refusals for an archived record and for a version of another record, written with dgettext_noop("errors", …) where the action is declared.

A call with no site, or on another site's record, finds nothing.