Skip to main content

submit

Function submit 

Source
pub async fn submit(
    pool: &PgPool,
    actor: &Actor,
    change_id: Uuid,
) -> AppResult<Change>
Expand description

Submits a draft change for review and freezes its revisions.

§Invariants

  • Permission: CAD editor who is the author (or an administrator); the change is a draft (409) and the actor sees every item (403); it has an item and a reviewer, and no reviewer is deactivated (409); every revision is in a group the actor may edit (403) and not checked out by someone else (409); no dependency is unreleased unless it is in the change (409).
  • Locks: the change row (FOR UPDATE), then every revision (revisions::lock) before its state changes.
  • Review policy: every affected project group’s policy is met (409): enough reviewers for the minimum approvals, the required people and a reviewer from each role group.
  • Audit: change.submit.
  • Notifications: the reviewers (review requested) and the other watchers of the change; readers who may not see every item get a text without item names; never the actor.
  • Webhooks: change.submitted.
  • Data: the revisions go to in review (a check-out is cleared) and all reviews are reset to pending.
  • Atomic: one transaction.