Initial commit: Rails port of Simple Aircraft Manager

Rails 8.1 + SQLite rewrite of marbindrakon/simple-aircraft-manager,
designed to self-host as a single container (Solid Queue/Cache/Cable,
Active Storage on disk, Hotwire + importmap, Tailwind).

- Airworthiness engine ported from health/services.py (ADs, grounding
  squawks, inspection recurrency, component replacement)
- Hours updates and flight logs cascading to in-service components,
  optional airworthiness enforcement
- Components, squawks, ADs, inspections, logbook, documents, major
  records, oil/fuel consumption stats and charts, activity log
- Admin/owner/pilot RBAC and public share links (status/maintenance)
- Docker Compose and Kamal deployment, env-driven production config
- Service and integration tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-04 17:59:08 -05:00
commit 38df19c331
264 files changed
+8365

No files matched your search

@@ -0,0 +1,54 @@
# Owner-only: manage who can access the aircraft, and its public share links.
class AircraftRolesController < ApplicationController
include AircraftScoped
before_action :require_owner!
def index
@roles = @aircraft.roles.includes(:user).order(:role, :created_at)
@share_tokens = @aircraft.share_tokens.order(created_at: :desc).includes(:created_by)
end
def create
user = User.find_by(email_address: params[:email_address].to_s.strip.downcase)
unless user
return redirect_to aircraft_aircraft_roles_path(@aircraft),
alert: "No user with that email. Ask an administrator to create their account first."
end
role = @aircraft.roles.new(user: user, role: params[:role])
if role.save
log_event("role", "#{user.display_name} added as #{role.role}")
redirect_to aircraft_aircraft_roles_path(@aircraft), notice: "#{user.display_name} added."
else
redirect_to aircraft_aircraft_roles_path(@aircraft), alert: role.errors.full_messages.to_sentence
end
end
def update
role = @aircraft.roles.find(params[:id])
if demoting_last_owner?(role, params[:role])
return redirect_to aircraft_aircraft_roles_path(@aircraft), alert: "An aircraft must keep at least one owner."
end
role.update!(role: params[:role])
log_event("role", "#{role.user.display_name} changed to #{role.role}")
redirect_to aircraft_aircraft_roles_path(@aircraft), notice: "Role updated."
end
def destroy
role = @aircraft.roles.find(params[:id])
if role.user == current_user
return redirect_to aircraft_aircraft_roles_path(@aircraft), alert: "You can't remove yourself."
end
if demoting_last_owner?(role, nil)
return redirect_to aircraft_aircraft_roles_path(@aircraft), alert: "An aircraft must keep at least one owner."
end
role.destroy!
log_event("role", "#{role.user.display_name} removed")
redirect_to aircraft_aircraft_roles_path(@aircraft), notice: "Access removed."
end
private
def demoting_last_owner?(role, new_role)
role.role == "owner" && new_role != "owner" && @aircraft.roles.owners.count <= 1
end
end