mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
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:
1 parent
bffdea937c
commit
e4c27c6ff7
19 files changed
+495
-5
No files matched your search
@@ -0,0 +1,21 @@
|
||||
# Draft logbook entries from the API (docs/api.md, "Draft entries"): one
|
||||
# batch per visit, one unsigned entry per logbook; what the work resolves
|
||||
# (squawks, inspections) is held until every entry is signed.
|
||||
class CreateDraftBatches < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
create_table :draft_batches do |t|
|
||||
t.references :aircraft, null: false, foreign_key: true
|
||||
t.references :api_token, foreign_key: true
|
||||
t.references :created_by, foreign_key: { to_table: :users }
|
||||
t.string :external_ref
|
||||
t.string :status, null: false, default: "awaiting_signature" # awaiting_signature | completed | withdrawn
|
||||
t.string :signer_email
|
||||
t.json :held, null: false, default: {} # { "squawks" => [{ "id", "log" }], "inspections" => [{ "id", "log" }] }
|
||||
t.datetime :completed_at
|
||||
t.timestamps
|
||||
t.index :external_ref
|
||||
end
|
||||
add_reference :logbook_entries, :draft_batch, foreign_key: true
|
||||
add_column :logbook_entries, :external_ref, :string
|
||||
end
|
||||
end
|
||||
Generated
+25
-1
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.1].define(version: 2026_11_15_010000) do
|
||||
ActiveRecord::Schema[8.1].define(version: 2026_11_15_020000) do
|
||||
create_table "active_storage_attachments", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.string "record_type", null: false
|
||||
@@ -441,6 +441,23 @@ ActiveRecord::Schema[8.1].define(version: 2026_11_15_010000) do
|
||||
t.index ["document_collection_id"], name: "index_documents_on_document_collection_id"
|
||||
end
|
||||
|
||||
create_table "draft_batches", force: :cascade do |t|
|
||||
t.integer "aircraft_id", null: false
|
||||
t.integer "api_token_id"
|
||||
t.integer "created_by_id"
|
||||
t.string "external_ref"
|
||||
t.string "status", default: "awaiting_signature", null: false
|
||||
t.string "signer_email"
|
||||
t.json "held", default: {}, null: false
|
||||
t.datetime "completed_at"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["aircraft_id"], name: "index_draft_batches_on_aircraft_id"
|
||||
t.index ["api_token_id"], name: "index_draft_batches_on_api_token_id"
|
||||
t.index ["created_by_id"], name: "index_draft_batches_on_created_by_id"
|
||||
t.index ["external_ref"], name: "index_draft_batches_on_external_ref"
|
||||
end
|
||||
|
||||
create_table "drs_imports", force: :cascade do |t|
|
||||
t.integer "aircraft_id", null: false
|
||||
t.integer "user_id"
|
||||
@@ -569,9 +586,12 @@ ActiveRecord::Schema[8.1].define(version: 2026_11_15_010000) do
|
||||
t.decimal "component_since_overhaul_at_entry", precision: 8, scale: 1
|
||||
t.integer "supersedes_id"
|
||||
t.datetime "superseded_at"
|
||||
t.integer "draft_batch_id"
|
||||
t.string "external_ref"
|
||||
t.index ["aircraft_id"], name: "index_logbook_entries_on_aircraft_id"
|
||||
t.index ["component_id"], name: "index_logbook_entries_on_component_id"
|
||||
t.index ["document_id"], name: "index_logbook_entries_on_document_id"
|
||||
t.index ["draft_batch_id"], name: "index_logbook_entries_on_draft_batch_id"
|
||||
t.index ["supersedes_id"], name: "index_logbook_entries_on_supersedes_id"
|
||||
end
|
||||
|
||||
@@ -952,6 +972,9 @@ ActiveRecord::Schema[8.1].define(version: 2026_11_15_010000) do
|
||||
add_foreign_key "document_collections", "aircraft"
|
||||
add_foreign_key "documents", "aircraft"
|
||||
add_foreign_key "documents", "document_collections"
|
||||
add_foreign_key "draft_batches", "aircraft"
|
||||
add_foreign_key "draft_batches", "api_tokens"
|
||||
add_foreign_key "draft_batches", "users", column: "created_by_id"
|
||||
add_foreign_key "drs_imports", "aircraft", on_delete: :cascade
|
||||
add_foreign_key "drs_imports", "users", on_delete: :nullify
|
||||
add_foreign_key "entry_signatures", "logbook_entries"
|
||||
@@ -966,6 +989,7 @@ ActiveRecord::Schema[8.1].define(version: 2026_11_15_010000) do
|
||||
add_foreign_key "logbook_entries", "aircraft"
|
||||
add_foreign_key "logbook_entries", "components", on_delete: :nullify
|
||||
add_foreign_key "logbook_entries", "documents", on_delete: :nullify
|
||||
add_foreign_key "logbook_entries", "draft_batches"
|
||||
add_foreign_key "logbook_entries", "logbook_entries", column: "supersedes_id", on_delete: :nullify
|
||||
add_foreign_key "logbook_entry_parts", "components", on_delete: :cascade
|
||||
add_foreign_key "logbook_entry_parts", "logbook_entries", on_delete: :cascade
|
||||
|
||||
Reference in new issue
Block a user