mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
Compare commits
2
Commits
v2026.11.7
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6697e835c8 | ||
|
|
acb8b87ca3 |
No files matched your search
@@ -36,7 +36,7 @@ module Api
|
||||
render json: { data: Compliance.ad_rows(aircraft).map { ApiPresenter.ad(_1) } }
|
||||
end
|
||||
|
||||
# Logbook entries, oldest first (paged); ?log=AC|ENG|PROP|OTHER, ?signed=true|false.
|
||||
# Logbook entries, oldest first (paged); ?log=AC|ENG|PROP|AVIONICS|OTHER, ?signed=true|false.
|
||||
def logbook_entries
|
||||
aircraft = find_aircraft(params[:id])
|
||||
scope = aircraft.logbook_entries.includes(:signature)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class LogbookEntry < ApplicationRecord
|
||||
include Versioned
|
||||
LOG_TYPES = LabelSet.new("logbook_entry.log_types", %w[AC ENG PROP OTHER])
|
||||
LOG_TYPES = LabelSet.new("logbook_entry.log_types", %w[AC ENG PROP AVIONICS OTHER])
|
||||
ENTRY_TYPES = LabelSet.new("logbook_entry.entry_types", %w[MAINTENANCE INSPECTION FLIGHT HOURS_UPDATE OTHER])
|
||||
|
||||
# Kind of certificate of the person approving return to service (43.9(a)(4)).
|
||||
|
||||
@@ -22,7 +22,7 @@ class LogbookTemplate < ApplicationRecord
|
||||
existing = pluck(:name).to_set
|
||||
next_position = (maximum(:position) || 0) + 1
|
||||
added = defaults.reject { existing.include?(_1["name"]) }
|
||||
added.each_with_index { |d, i| create!(d.slice("name", "reference", "text", "log_type", "certificate_type").merge("position" => next_position + i)) }
|
||||
added.each_with_index { |d, i| create!(d.slice("name", "reference", "text", "entry_type", "log_type", "certificate_type").merge("position" => next_position + i)) }
|
||||
added.size
|
||||
end
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ Entry types:
|
||||
- OTHER: administrative entries, certifications
|
||||
|
||||
Fields:
|
||||
- log_type: AC (airframe), ENG (engine), PROP (propeller), or OTHER
|
||||
- log_type: AC (airframe), ENG (engine), PROP (propeller), AVIONICS (a separate avionics logbook: radios, transponder, autopilot, GPS…), or OTHER
|
||||
- text: the entry text verbatim, or a close paraphrase where wording is unclear; write [?] for illegible words
|
||||
- aircraft_hours: the tach/total time the entry records (a number), or null if none is written
|
||||
- signoff_person / signoff_location: a string, or null (the person's name only; certificate details go below)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"date": { "type": ["string", "null"], "description": "YYYY-MM-DD, or null if unreadable" },
|
||||
"log_type": { "type": "string", "enum": ["AC", "ENG", "PROP", "OTHER"] },
|
||||
"log_type": { "type": "string", "enum": ["AC", "ENG", "PROP", "AVIONICS", "OTHER"] },
|
||||
"entry_type": { "type": "string", "enum": ["MAINTENANCE", "INSPECTION", "FLIGHT", "HOURS_UPDATE", "OTHER"] },
|
||||
"text": { "type": "string" },
|
||||
"aircraft_hours": { "type": ["number", "null"] },
|
||||
|
||||
@@ -73,6 +73,7 @@ en:
|
||||
AC: Aircraft
|
||||
ENG: Engine
|
||||
PROP: Propeller
|
||||
AVIONICS: Avionics
|
||||
OTHER: Other
|
||||
entry_types:
|
||||
MAINTENANCE: Maintenance
|
||||
|
||||
@@ -85,11 +85,13 @@
|
||||
reference: "Part 43 App. A (c)(29)"
|
||||
text: "Removed, checked and reinstalled the magnetic chip detector: no particles found. Preventive maintenance per 14 CFR 43.3(g), Part 43 Appendix A paragraph (c)(29)."
|
||||
certificate_type: PILOT
|
||||
# Not maintenance (14 CFR 43.3(k)), so no entry is required and it isn't
|
||||
# signed off as preventive maintenance; this just keeps a note of it.
|
||||
- name: "Updating the navigation database"
|
||||
reference: "Part 43 App. A (c)(31)"
|
||||
text: "Updated the __ navigation database to cycle __. Preventive maintenance per 14 CFR 43.3(g), Part 43 Appendix A paragraph (c)(31)."
|
||||
certificate_type: PILOT
|
||||
reference: "14 CFR 43.3(k)"
|
||||
text: "Updated the __ navigation database to cycle __ from the flight deck, per the manufacturer's instructions, without tools or disassembly. Database update under 14 CFR 43.3(k); not maintenance."
|
||||
entry_type: OTHER
|
||||
- name: "Swapping a tray-mounted nav/com unit"
|
||||
reference: "Part 43 App. A (c)(32)"
|
||||
text: "Removed and reinstalled the tray-mounted __ unit. Checked operation. Preventive maintenance per 14 CFR 43.3(g), Part 43 Appendix A paragraph (c)(32)."
|
||||
reference: "Part 43 App. A (c)(31)"
|
||||
text: "Removed and reinstalled the self-contained, panel-mounted, tray-mounted __ unit per the manufacturer's instructions. Performed an operational check before use. Preventive maintenance per 14 CFR 43.3(g), Part 43 Appendix A paragraph (c)(31)."
|
||||
certificate_type: PILOT
|
||||
@@ -0,0 +1,37 @@
|
||||
# Two built-in logbook templates cited the wrong rule. A tray-mounted nav/com
|
||||
# swap is Part 43 Appendix A (c)(31), not (c)(32) (which doesn't exist), and a
|
||||
# navigation database update isn't preventive maintenance at all: 14 CFR
|
||||
# 43.3(k) says it isn't maintenance. Copies already in the database are fixed
|
||||
# where an admin hasn't changed their text; edited ones are left alone.
|
||||
class FixAvionicsTemplateCitations < ActiveRecord::Migration[8.1]
|
||||
class Template < ActiveRecord::Base
|
||||
self.table_name = "logbook_templates"
|
||||
end
|
||||
|
||||
FIXES = [
|
||||
{ name: "Swapping a tray-mounted nav/com unit",
|
||||
old_reference: "Part 43 App. A (c)(32)",
|
||||
old_text: "Removed and reinstalled the tray-mounted __ unit. Checked operation. Preventive maintenance per 14 CFR 43.3(g), Part 43 Appendix A paragraph (c)(32).",
|
||||
new: { reference: "Part 43 App. A (c)(31)",
|
||||
text: "Removed and reinstalled the self-contained, panel-mounted, tray-mounted __ unit per the manufacturer's instructions. Performed an operational check before use. Preventive maintenance per 14 CFR 43.3(g), Part 43 Appendix A paragraph (c)(31)." } },
|
||||
{ name: "Updating the navigation database",
|
||||
old_reference: "Part 43 App. A (c)(31)",
|
||||
old_text: "Updated the __ navigation database to cycle __. Preventive maintenance per 14 CFR 43.3(g), Part 43 Appendix A paragraph (c)(31).",
|
||||
new: { reference: "14 CFR 43.3(k)",
|
||||
text: "Updated the __ navigation database to cycle __ from the flight deck, per the manufacturer's instructions, without tools or disassembly. Database update under 14 CFR 43.3(k); not maintenance.",
|
||||
entry_type: "OTHER", certificate_type: nil } }
|
||||
].freeze
|
||||
|
||||
def up
|
||||
FIXES.each do |fix|
|
||||
Template.where(name: fix[:name], reference: fix[:old_reference], text: fix[:old_text]).update_all(fix[:new].merge(updated_at: Time.current))
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
FIXES.each do |fix|
|
||||
Template.where(name: fix[:name], reference: fix[:new][:reference], text: fix[:new][:text])
|
||||
.update_all(reference: fix[:old_reference], text: fix[:old_text], entry_type: "MAINTENANCE", certificate_type: "PILOT", updated_at: Time.current)
|
||||
end
|
||||
end
|
||||
end
|
||||
Generated
+1
-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_16_020000) do
|
||||
ActiveRecord::Schema[8.1].define(version: 2026_11_16_030000) do
|
||||
create_table "access_invitation_redemptions", force: :cascade do |t|
|
||||
t.integer "access_invitation_id", null: false
|
||||
t.integer "user_id", null: false
|
||||
|
||||
+2
-2
@@ -63,7 +63,7 @@ Squawks have an `external_ref`: your own id for them, such as `redmine:issue:451
|
||||
| `GET /aircraft/:id/due` | Everything coming due, soonest first; items due by hours get a projected date |
|
||||
| `GET /aircraft/:id/inspections` | Each inspection's status and next due date and hours |
|
||||
| `GET /aircraft/:id/ads` | Each AD's status and next due date and hours |
|
||||
| `GET /aircraft/:id/logbook_entries` | Logbook entries, with their signatures (`?log=AC`, `ENG`, `PROP` or `OTHER`; `?signed=true` or `false`) |
|
||||
| `GET /aircraft/:id/logbook_entries` | Logbook entries, with their signatures (`?log=AC`, `ENG`, `PROP`, `AVIONICS` or `OTHER`; `?signed=true` or `false`) |
|
||||
| `GET /aircraft/:id/squawks` | Squawks (`?status=open`, the default, or `resolved` or `all`) |
|
||||
| `POST /aircraft/:id/squawks` | Report a squawk |
|
||||
| `GET /squawks?external_ref=…` | Find squawks by your id for them |
|
||||
@@ -120,7 +120,7 @@ POST /api/v1/aircraft/12/draft_batches
|
||||
} }
|
||||
```
|
||||
|
||||
- **One entry per logbook.** Items are grouped by `log` (`AC`, `ENG`, `PROP` or `OTHER`) into one unsigned entry each, their texts in order, so a visit that touched the engine and the airframe makes two entries, signed one after the other.
|
||||
- **One entry per logbook.** Items are grouped by `log` (`AC`, `ENG`, `PROP`, `AVIONICS` or `OTHER`) into one unsigned entry each, their texts in order, so a visit that touched the engine and the airframe makes two entries, signed one after the other.
|
||||
- **Inspections** (`completes_inspections`): each needs its `result`, `approved` (airworthy) or `discrepancies` (a list was given to the owner), and the draft needs `aircraft_hours`. The entry recording it is an inspection entry, in the logbook named by `log`, else the airframe log if an item is for it.
|
||||
- **Nothing is resolved until it's signed.** The squawks the items resolve and the inspections they complete are held until **every** entry of the draft is signed; then they're resolved and recorded, attributed to the person who signed last, and linked to the entry that described the work. A draft never clears a squawk on its own. The signer sees what signing will do before they sign.
|
||||
- **The signer.** Anyone with access to the aircraft and a certificate in their profile can sign, from each entry's `sign_url`. Give `signer.email` for someone else (a mechanic who isn't on the aircraft): each entry then gets an `invitation_url`, a link that lets that person sign that entry with their account for that address, for 14 days. When the integration acts for an Owner of the aircraft, the link also lets them create that account; otherwise they need one first. Pass the link on yourself (for example inside Redmine), or set `send_email: true` to have SAM email it.
|
||||
|
||||
@@ -7,7 +7,7 @@ The **Logbook** tab holds the maintenance record entries. Owners and Mechanics w
|
||||
**+ New Entry**:
|
||||
|
||||
1. Choose a **Template** to start the wording if one fits, and fill in its blanks (`__`). The built-in ones are for a pilot doing preventive maintenance on an aircraft they own or operate (14 CFR 43.3(g)); admins can add their own.
|
||||
2. Fill in the date, the **logbook** (aircraft, engine, propeller or other), the **entry type** (usually maintenance or inspection) and the **airframe total time**.
|
||||
2. Fill in the date, the **logbook** (aircraft, engine, propeller, avionics or other), the **entry type** (usually maintenance or inspection) and the **airframe total time**.
|
||||
3. For an engine or propeller entry, pick the component: its total time and time since overhaul at the entry fill in from the airframe time. Tick any **sub-components** included in the work (an oil filter on the engine) to record their times as well. On a new entry, set a sub-component to **Serviced** or **Replaced** to record that on the Components tab at the same time (an oil and filter change resets their time since service), dated to the entry.
|
||||
Its time since service then counts from the airframe time on the entry.
|
||||
Under **Inspections completed**, tick any inspection the work completes (an Oil Change): it's recorded as done on the Inspections tab at the entry's date and airframe time, linked to the entry.
|
||||
|
||||
@@ -4,7 +4,7 @@ These are the instructions for everyone who keeps or signs maintenance records h
|
||||
|
||||
## Writing an entry
|
||||
|
||||
On the aircraft's **Logbook** tab, choose **+ New Entry** (Owners and Mechanics: the **Write logbook entries** permission). Give the date, the logbook (aircraft, engine, propeller), the airframe total time and what was done. For an engine or propeller entry, pick the component (its times fill in) and tick any sub-components. A template can start the wording. An entry isn't a signed record until it's signed. See [The logbook](logbook.md).
|
||||
On the aircraft's **Logbook** tab, choose **+ New Entry** (Owners and Mechanics: the **Write logbook entries** permission). Give the date, the logbook (aircraft, engine, propeller, avionics or other), the airframe total time and what was done. For an engine or propeller entry, pick the component (its times fill in) and tick any sub-components. A template can start the wording. An entry isn't a signed record until it's signed. See [The logbook](logbook.md).
|
||||
|
||||
## Signing
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
require "test_helper"
|
||||
|
||||
# Aircraft with a separate avionics logbook file their radio, transponder
|
||||
# and autopilot work under it.
|
||||
class AvionicsLogbookTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@owner = create_user("owner@example.com")
|
||||
@a = create_aircraft(owner: @owner, tail_number: "N12345")
|
||||
sign_in @owner
|
||||
end
|
||||
|
||||
test "an entry can be written to the avionics logbook and the list filtered to it" do
|
||||
post aircraft_logbook_entries_path(@a), params: { logbook_entry: { date: "2026-10-01", log_type: "AVIONICS", entry_type: "MAINTENANCE",
|
||||
text: "Replaced Comm 2 radio; operational check normal." } }
|
||||
entry = @a.logbook_entries.sole
|
||||
assert_equal "AVIONICS", entry.log_type
|
||||
@a.logbook_entries.create!(date: Date.new(2026, 10, 2), log_type: "AC", entry_type: "MAINTENANCE", text: "Lubricated door hinges.")
|
||||
|
||||
get aircraft_logbook_entries_path(@a, log_type: "AVIONICS")
|
||||
assert_response :success
|
||||
assert_includes response.body, "Replaced Comm 2 radio"
|
||||
assert_not_includes response.body, "Lubricated door hinges"
|
||||
assert_includes response.body, ">Avionics<"
|
||||
end
|
||||
|
||||
test "logbook transcription and the drafts API know the avionics logbook" do
|
||||
assert LogbookEntry::LOG_TYPES.key?("AVIONICS")
|
||||
assert_includes JSON.parse(Rails.root.join("app/services/logbook_transcriber/schema.json").read).to_s, "AVIONICS"
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,31 @@
|
||||
require "test_helper"
|
||||
|
||||
class LogbookTemplateTest < ActiveSupport::TestCase
|
||||
test "every built-in template is valid and cites an existing Appendix A paragraph" do
|
||||
LogbookTemplate.defaults.each do |d|
|
||||
template = LogbookTemplate.new(d)
|
||||
assert template.valid?, "#{d['name']}: #{template.errors.full_messages.to_sentence}"
|
||||
# Part 43 Appendix A paragraph (c) runs from (1) to (31).
|
||||
d.values_at("reference", "text").join(" ").scan(/\(c\)\((\d+)\)/).flatten.each do |n|
|
||||
assert_includes 1..31, n.to_i, "#{d['name']} cites Appendix A (c)(#{n})"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
test "the tray-mounted nav/com swap cites (c)(31)" do
|
||||
LogbookTemplate.restore_defaults!
|
||||
swap = LogbookTemplate.find_by!(name: "Swapping a tray-mounted nav/com unit")
|
||||
assert_equal "Part 43 App. A (c)(31)", swap.reference
|
||||
assert_includes swap.text, "paragraph (c)(31)"
|
||||
assert_equal "PILOT", swap.certificate_type
|
||||
end
|
||||
|
||||
test "a navigation database update is recorded as a note, not preventive maintenance" do
|
||||
LogbookTemplate.restore_defaults!
|
||||
update = LogbookTemplate.find_by!(name: "Updating the navigation database")
|
||||
assert_equal "14 CFR 43.3(k)", update.reference
|
||||
assert_equal "OTHER", update.entry_type
|
||||
assert_nil update.certificate_type
|
||||
assert_not_includes update.text, "Preventive maintenance"
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user