API: draft logbook entries for signing

- POST /aircraft/:id/draft_batches turns a visit's work items into one
  unsigned entry per logbook, signed in the app (by a user with a
  certificate, or a mechanic through a returned or emailed invitation link).
- The squawks they resolve and inspections they complete (with their result)
  are held until every entry is signed, then applied, attributed to the last
  signer; draft_batch.completed webhook. A draft never clears a squawk alone.
- Drafts are for owners (integrations act for one, drafts:write scope);
  unsigned drafts can be withdrawn; lookup by external_ref.
- The signing and entry pages show where a draft came from and what signing
  will do.
- The suggested recordkeeping procedures describe the API once it's in use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-14 19:11:38 -05:00
1 parent bffdea937c
commit e4c27c6ff7
19 files changed
+495 -5

No files matched your search

+9 -1
View File
@@ -12,9 +12,10 @@ module ProceduresTemplates
t(:sign_in, sentence: sign_in_sentence, min: User::PASSWORD_MIN, minutes: User::LOCK_FOR.in_minutes.to_i,
tries: User::LOCK_AFTER, days: Authentication::SESSION_IDLE_TIMEOUT.in_days.to_i),
t(Sso.enabled? ? :signing_sso : :signing),
api_sentence,
t(:updates),
t(:secret_key)
].join("\n\n")
].compact.join("\n\n")
end
def additional
@@ -37,6 +38,13 @@ module ProceduresTemplates
end
end
# Only when the API is in use: who can reach the records through it, and that signing stays in the app.
def api_sentence
integrations = ApiToken.integration.active.order(:name).pluck(:name)
return if integrations.empty? && !ApiToken.personal.active.exists?
t(:api, integrations: integrations.any? ? t(:api_integrations, names: integrations.to_sentence) : t(:api_no_integrations))
end
def docker? = File.exist?("/.dockerenv")
def t(key, **opts) = I18n.t(key, scope: "services.procedures_templates", **opts)