Files
rickyandClaude Opus 5.5 d8cd462194 Configurable roles: Owner, Mechanic, Pilot, Viewer and custom roles
What people can do on an aircraft now comes from their role there, and
administrators set what each role allows (Admin → Roles).

- Roles are installation-wide sets of permissions (31, grouped as flying,
  squawks and notes, maintenance records, imports and exports, the
  aircraft, notifications). Seeing an aircraft's records needs none.
- Built in: Owner (always every permission, so an aircraft can always be
  managed), Mechanic (shop maintenance: logbook, signing, components,
  inspections, ADs, squawks, reminders), Pilot (what pilots could do
  before) and Viewer (view only). Administrators can change all but
  Owner's, and add their own; a role can be deleted once nobody has it.
- Existing owners and pilots keep exactly what they could do.
- Admin → Users → a user lists their role on every aircraft, to change,
  remove or add. On the aircraft's Access page, anyone who manages people
  hands out roles, but only an Owner can give or take away Owner, nobody
  changes their own (except administrators), and an aircraft always
  keeps an Owner (AircraftAccess).
- Controllers declare the permission each action needs; a request that
  changes something with none declared is refused (and raises in
  development and tests), and a test walks every route to check.
- Weekly reminders and overdue alerts go to roles that get reminders;
  the DRS reminder also needs Manage ADs. The API follows the person's
  role; its owners_only error is now not_permitted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 17:43:38 -05:00

118 lines
8.7 KiB
ERB

<%# The procedures document (AC 120-78B 2.2.11, 3.2.8), generated from the system's setup.
Locals: policy, number, adopted_at, adopted_by, revisions, summary. %>
<% info = SystemInfo.new %>
<% aircraft = Aircraft.ordered.includes(:roles) %>
<% users = User.order(:email_address).includes(:certificates, aircraft_roles: %i[aircraft role]) %>
<% h2 = "mt-6 text-base font-semibold" %>
<% p_ = "mt-1 text-sm leading-relaxed" %>
<article class="text-slate-900">
<header class="border-b-2 border-slate-800 pb-3">
<p class="text-xs uppercase tracking-wide text-slate-500"><%= t(".standalone_procedures_document_ac_120") %></p>
<h1 class="text-2xl font-bold"><%= t(".electronic_signature_and_recordkeeping_procedure") %></h1>
<p class="text-sm text-slate-600"><%= t(".simple_aircraft_manager_html", operator: (policy.operator_name.presence || t(".operator"))) %></p>
<p class="mt-1 text-sm"><%= t(".revision_html", number: number, adopted: (adopted_at ? t(".adopted_by", date: adopted_at.to_date.iso8601, display_name: adopted_by&.display_name) : t(".not_yet_adopted"))) %></p>
</header>
<h2 class="<%= h2 %>"><%= t(".n1_purpose_and_scope") %></h2>
<p class="<%= p_ %>"><%= t(".these_procedures_describe_how_keeps_html", operator: (policy.operator_name.presence || t(".operator"))) %></p>
<table class="mt-2 w-full text-sm">
<thead><tr class="border-b border-slate-300 text-left text-xs uppercase text-slate-500"><th class="py-1"><%= t(".aircraft") %></th><th><%= t(".serial_number") %></th><th><%= t(".electronic_records_since") %></th><th><%= t(".earlier_records") %></th></tr></thead>
<tbody>
<% aircraft.each do |a| %>
<tr class="border-b border-slate-100"><td class="py-1"><%= a.tail_number %> <%= [ a.make, a.model ].compact_blank.join(" ") %></td><td><%= a.serial_number.presence || "—" %></td>
<td><%= a.electronic_records_since || t(".not_set") %></td><td><%= t(".paper_logbooks_html", legacy: (t(".scans_held_as_legacy_records") if a.documents.where(legacy_record: true).exists?)) %></td></tr>
<% end %>
</tbody>
</table>
<p class="<%= p_ %>"><%= t(".records_kept_electronically_logbook_entries") %></p>
<h2 class="<%= h2 %>"><%= t(".n2_regulatory_compliance") %></h2>
<p class="<%= p_ %>"><%= t(".each_logbook_entry_carries_what") %></p>
<h2 class="<%= h2 %>"><%= t(".n3_system_description") %></h2>
<ul class="<%= p_ %> list-disc pl-5">
<li><%= t(".software_simple_aircraft_manager_version_html", version_label: info.version_label, ruby: RUBY_VERSION, rails: Rails.version, sqlite: (SQLite3::SQLITE_VERSION)) %></li>
<li><%= t(".hosting_and_network_html") %>
<% if policy.hosting_description.present? %><div class="mt-1"><%= markdown(policy.hosting_description) %></div><% else %><%= t(".describe_the_server_location_and") %><% end %>
<p class="mt-1"><%= ProceduresTemplates.https? ? t(".connections_use_https_only_the") : t(".https_not_enforced") %> <%= ProceduresTemplates.sign_in_sentence %></p></li>
<li><%= t(".data_one_sqlite_database_plus_html") %></li>
<li><%= t(".backups_every_night_the_app_html", backups_kept: (Setting.integer("backups_kept"))) %> <% if OffsiteConnection.connected? %><%= t(".after_each_nightly_backup_the_html", account_email: OffsiteConnection.current.account_email, folder: (OffsiteConnection::ROOT_FOLDER), offsite_backups_kept: (Setting.integer("offsite_backups_kept")), present: (" #{policy.offsite_backup_description}" if policy.offsite_backup_description.present?)) %><% else %><%= policy.offsite_backup_description.presence || t(".describe_the_off_site_backup") %><% end %></li>
</ul>
<h2 class="<%= h2 %>"><%= t(".n4_responsible_personnel") %></h2>
<p class="<%= p_ %>"><%= t(".has_authority_and_overall_responsibility_html", name: (policy.responsible_name.presence || t(".name")), title: (", #{policy.responsible_title}" if policy.responsible_title.present?), admins: (users.select(&:admin?).reject(&:disabled?).map(&:display_name).to_sentence.presence || t(".none"))) %></p>
<h2 class="<%= h2 %>"><%= t(".n5_defined_users_and_roles") %></h2>
<p class="<%= p_ %>"><%= t(".owners_keep_an_aircraft_s_html") %></p>
<table class="mt-2 w-full text-sm">
<thead><tr class="border-b border-slate-300 text-left text-xs uppercase text-slate-500"><th class="py-1"><%= t(".user") %></th><th><%= t(".roles") %></th><th><%= t(".certificates") %></th><th><%= t(".may_sign") %></th></tr></thead>
<tbody>
<% users.each do |u| %>
<% current = u.certificates.reject(&:expired?) %>
<tr class="border-b border-slate-100 align-top"><td class="py-1"><%= u.display_name %><div class="text-xs text-slate-500"><%= u.email_address %></div></td>
<td class="text-xs"><%= [ (t(".administrator") if u.admin?), *u.aircraft_roles.map { "#{_1.role.name}, #{_1.aircraft.tail_number}" } ].compact.join("; ").presence || "—" %><%= t(".disabled") if u.disabled? %></td>
<td class="text-xs"><%= u.certificates.map { "#{_1.short_label} #{_1.number}#{" #{t('.expires_short', date: _1.expires_on)}" if _1.expires_on}" }.join("; ").presence || "—" %></td>
<td class="text-xs"><%= if u.disabled? || current.empty? then t(".no")
elsif current.any?(&:mechanic?) then t(".maintenance_and_inspection_entries")
else t(".preventive_maintenance_entries") end %></td></tr>
<% end %>
</tbody>
</table>
<p class="<%= p_ %>"><%= t(".people_outside_these_users_e") %></p>
<h2 class="<%= h2 %>"><%= t(".n6_electronic_signature_process") %></h2>
<ol class="<%= p_ %> list-decimal pl-5">
<li><%= t(".the_signer_opens_the_entry") %></li>
<li><%= t(".they_choose_one_of_their") %></li>
<li><%= t(".they_prove_who_they_are") %></li>
<li><%= t(".the_system_records_the_signer") %></li>
<li><%= t(".once_signed_the_entry_and") %></li>
<li><%= t(".when_someone_no_longer_needs") %></li>
</ol>
<p class="<%= p_ %>"><%= t(".signed_records_are_archived_in") %></p>
<h2 class="<%= h2 %>"><%= t(".n7_recordkeeping_system_controls") %></h2>
<ul class="<%= p_ %> list-disc pl-5">
<li><%= t(".controlled_access_3_2_1_html", password: (Sso.enabled? ? (Sso.password_login? ? t(".single_sign_on_with_or", so: Sso.label) : t(".single_sign_on_with_only", so: Sso.label)) : t(".email_and_password"))) %></li>
<li><%= t(".record_preservation_3_2_2_html") %></li>
<li><%= t(".confidential_information_3_2_3_html") %></li>
<li><%= t(".data_corruption_3_2_4_html") %></li>
<li><%= t(".outages_3_2_5_entries_html") %></li>
<li><%= t(".software_revision_control_3_2_html") %></li>
<li><%= t(".backups_3_2_7_see_html") %></li>
</ul>
<h2 class="<%= h2 %>"><%= t(".n8_quality_control_and_auditing") %></h2>
<p class="<%= p_ %>"><%= t(".every_months_the_responsible_person_html", audit_interval_months: policy.audit_interval_months, audit_sample_size: policy.audit_sample_size, latest: (t(".last_audit", to_date: AuditRun.latest.performed_at.to_date) if AuditRun.latest)) %></p>
<h2 class="<%= h2 %>"><%= t(".n9_making_records_available_to") %></h2>
<p class="<%= p_ %>"><%= t(".on_request_14_cfr_91") %></p>
<h2 class="<%= h2 %>"><%= t(".n10_transfer_of_records") %></h2>
<p class="<%= p_ %>"><%= t(".at_sale_91_419_3_html") %></p>
<h2 class="<%= h2 %>"><%= t(".n11_continuity") %></h2>
<p class="<%= p_ %>"><%= t(".legacy_records_3_2_8_html") %></p>
<h2 class="<%= h2 %>"><%= t(".n12_changes_to_the_system") %></h2>
<p class="<%= p_ %>"><%= t(".these_procedures_are_revised_when") %></p>
<h2 class="<%= h2 %>"><%= t(".n13_user_instructions_and_training") %></h2>
<p class="<%= p_ %>"><%= t(".every_user_who_keeps_or") %></p>
<div class="mt-2 rounded border border-slate-200 p-3"><%= guide_html(HelpGuide.find("records"), links: false, title: false) %></div>
<% if policy.additional_procedures.present? %>
<h2 class="<%= h2 %>"><%= t(".n14_additional_procedures") %></h2>
<div class="<%= p_ %>"><%= markdown(policy.additional_procedures) %></div>
<% end %>
<h2 class="<%= h2 %>"><%= t(".revision_history") %></h2>
<table class="mt-2 w-full text-sm">
<thead><tr class="border-b border-slate-300 text-left text-xs uppercase text-slate-500"><th class="py-1"><%= t(".revision_2") %></th><th><%= t(".adopted") %></th><th><%= t(".by") %></th><th><%= t(".summary") %></th></tr></thead>
<tbody>
<% revisions.each do |r| %><tr class="border-b border-slate-100"><td class="py-1"><%= r.number %></td><td><%= fmt_date(r.adopted_at.to_date) %></td><td><%= r.adopted_by&.display_name %></td><td><%= r.summary %></td></tr><% end %>
<tr><td class="py-1"><%= number %></td><td><%= adopted_at&.to_date || "—" %></td><td><%= adopted_by&.display_name %></td><td><%= summary.presence || t(".this_revision") %></td></tr>
</tbody>
</table>
</article>