MishkaDocument.Resources.Changes.AutoApplySectionDraft (Mishka Document v0.0.1)

Copy Markdown View Source

Automatically applies section draft changes when both approvals are granted.

This change is triggered on SectionDraft update actions. When both content_review_status and technical_review_status are set to :approved, it automatically applies the section.

A draft of an existing page writes only the fields it changes (its changed_fields, kept by MishkaDocument.Resources.Changes.StartFromSource); a draft of a new page writes all of itself.

The page is written, and the draft marked applied, as whoever approved the draft, in the draft's site, so the resources' own policies answer for the approval too. The page is looked up by id without the approver's read policies, since a lookup of a row the draft names must find it whatever the approver may list.

Summary

Functions

change(changeset, opts, context)

Callback implementation for Ash.Resource.Change.change/3.