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

+51
View File
@@ -0,0 +1,51 @@
# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files.
# Ignore git directory.
/.git/
/.gitignore
# Ignore bundler config.
/.bundle
# Ignore all environment files.
/.env*
# Ignore all default key files.
/config/master.key
/config/credentials/*.key
# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep
# Ignore pidfiles, but keep the directory.
/tmp/pids/*
!/tmp/pids/.keep
# Ignore storage (uploaded files in development and any SQLite databases).
/storage/*
!/storage/.keep
/tmp/storage/*
!/tmp/storage/.keep
# Ignore assets.
/node_modules/
/app/assets/builds/*
!/app/assets/builds/.keep
/public/assets
# Ignore CI service files.
/.github
# Ignore Kamal files.
/config/deploy*.yml
/.kamal
# Ignore development files
/.devcontainer
# Ignore Docker-related files
/.dockerignore
/Dockerfile*
+12
View File
@@ -0,0 +1,12 @@
# Generate with: bin/rails secret
SECRET_KEY_BASE=change-me
# Public hostname, used in password-reset email links
APP_HOST=localhost:3000
# "true" when behind HTTPS (reverse proxy / Kamal). "false" for plain HTTP on a LAN.
FORCE_SSL=false
# Optional: enable password-reset emails
# SMTP_ADDRESS=smtp.example.com
# SMTP_PORT=587
# SMTP_USERNAME=
# SMTP_PASSWORD=
# MAIL_FROM=aircraft@example.com
+9
View File
@@ -0,0 +1,9 @@
# See https://git-scm.com/docs/gitattributes for more about git attribute files.
# Mark the database schema as having been generated.
db/schema.rb linguist-generated
# Mark any vendored files as having been vendored.
vendor/* linguist-vendored
config/credentials/*.yml.enc diff=rails_credentials
config/credentials.yml.enc diff=rails_credentials
+12
View File
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: bundler
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
+90
View File
@@ -0,0 +1,90 @@
name: CI
on:
pull_request:
push:
branches: [ main ]
jobs:
scan_ruby:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: true
- name: Scan for common Rails security vulnerabilities using static analysis
run: bin/brakeman --no-pager
scan_js:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: true
- name: Scan for security vulnerabilities in JavaScript dependencies
run: bin/importmap audit
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: true
- name: Lint code for consistent style
run: bin/rubocop -f github
test:
runs-on: ubuntu-latest
# services:
# redis:
# image: redis
# ports:
# - 6379:6379
# options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Install packages
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y build-essential git libyaml-dev pkg-config google-chrome-stable
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: true
- name: Run tests
env:
RAILS_ENV: test
# REDIS_URL: redis://localhost:6379/0
run: bin/rails db:test:prepare test test:system
- name: Keep screenshots from failed system tests
uses: actions/upload-artifact@v4
if: failure()
with:
name: screenshots
path: ${{ github.workspace }}/tmp/screenshots
if-no-files-found: ignore
+41
View File
@@ -0,0 +1,41 @@
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# Temporary files generated by your text editor or operating system
# belong in git's global ignore instead:
# `$XDG_CONFIG_HOME/git/ignore` or `~/.config/git/ignore`
# Ignore bundler config.
/.bundle
# Ignore all environment files.
/.env*
# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep
# Ignore pidfiles, but keep the directory.
/tmp/pids/*
!/tmp/pids/
!/tmp/pids/.keep
# Ignore storage (uploaded files in development and any SQLite databases).
/storage/*
!/storage/.keep
/tmp/storage/*
!/tmp/storage/
!/tmp/storage/.keep
/public/assets
# Ignore master key for decrypting credentials and more.
/config/master.key
/app/assets/builds/*
!/app/assets/builds/.keep
# Local env for docker compose
.env
!/.env.example
+3
View File
@@ -0,0 +1,3 @@
#!/usr/bin/env sh
echo "Docker set up on $KAMAL_HOSTS..."
+3
View File
@@ -0,0 +1,3 @@
#!/usr/bin/env sh
echo "Booted app version $KAMAL_VERSION on $KAMAL_HOSTS..."
+14
View File
@@ -0,0 +1,14 @@
#!/usr/bin/env sh
# A sample post-deploy hook
#
# These environment variables are available:
# KAMAL_RECORDED_AT
# KAMAL_PERFORMER
# KAMAL_VERSION
# KAMAL_HOSTS
# KAMAL_ROLES (if set)
# KAMAL_DESTINATION (if set)
# KAMAL_RUNTIME
echo "$KAMAL_PERFORMER deployed $KAMAL_VERSION to $KAMAL_DESTINATION in $KAMAL_RUNTIME seconds"
+3
View File
@@ -0,0 +1,3 @@
#!/usr/bin/env sh
echo "Rebooted kamal-proxy on $KAMAL_HOSTS"
+3
View File
@@ -0,0 +1,3 @@
#!/usr/bin/env sh
echo "Booting app version $KAMAL_VERSION on $KAMAL_HOSTS..."
+51
View File
@@ -0,0 +1,51 @@
#!/usr/bin/env sh
# A sample pre-build hook
#
# Checks:
# 1. We have a clean checkout
# 2. A remote is configured
# 3. The branch has been pushed to the remote
# 4. The version we are deploying matches the remote
#
# These environment variables are available:
# KAMAL_RECORDED_AT
# KAMAL_PERFORMER
# KAMAL_VERSION
# KAMAL_HOSTS
# KAMAL_ROLES (if set)
# KAMAL_DESTINATION (if set)
if [ -n "$(git status --porcelain)" ]; then
echo "Git checkout is not clean, aborting..." >&2
git status --porcelain >&2
exit 1
fi
first_remote=$(git remote)
if [ -z "$first_remote" ]; then
echo "No git remote set, aborting..." >&2
exit 1
fi
current_branch=$(git branch --show-current)
if [ -z "$current_branch" ]; then
echo "Not on a git branch, aborting..." >&2
exit 1
fi
remote_head=$(git ls-remote $first_remote --tags $current_branch | cut -f1)
if [ -z "$remote_head" ]; then
echo "Branch not pushed to remote, aborting..." >&2
exit 1
fi
if [ "$KAMAL_VERSION" != "$remote_head" ]; then
echo "Version ($KAMAL_VERSION) does not match remote HEAD ($remote_head), aborting..." >&2
exit 1
fi
exit 0
+47
View File
@@ -0,0 +1,47 @@
#!/usr/bin/env ruby
# A sample pre-connect check
#
# Warms DNS before connecting to hosts in parallel
#
# These environment variables are available:
# KAMAL_RECORDED_AT
# KAMAL_PERFORMER
# KAMAL_VERSION
# KAMAL_HOSTS
# KAMAL_ROLES (if set)
# KAMAL_DESTINATION (if set)
# KAMAL_RUNTIME
hosts = ENV["KAMAL_HOSTS"].split(",")
results = nil
max = 3
elapsed = Benchmark.realtime do
results = hosts.map do |host|
Thread.new do
tries = 1
begin
Socket.getaddrinfo(host, 0, Socket::AF_UNSPEC, Socket::SOCK_STREAM, nil, Socket::AI_CANONNAME)
rescue SocketError
if tries < max
puts "Retrying DNS warmup: #{host}"
tries += 1
sleep rand
retry
else
puts "DNS warmup failed: #{host}"
host
end
end
tries
end
end.map(&:value)
end
retries = results.sum - hosts.size
nopes = results.count { |r| r == max }
puts "Prewarmed %d DNS lookups in %.2f sec: %d retries, %d failures" % [ hosts.size, elapsed, retries, nopes ]
+122
View File
@@ -0,0 +1,122 @@
#!/usr/bin/env ruby
# A sample pre-deploy hook
#
# Checks the Github status of the build, waiting for a pending build to complete for up to 720 seconds.
#
# Fails unless the combined status is "success"
#
# These environment variables are available:
# KAMAL_RECORDED_AT
# KAMAL_PERFORMER
# KAMAL_VERSION
# KAMAL_HOSTS
# KAMAL_COMMAND
# KAMAL_SUBCOMMAND
# KAMAL_ROLES (if set)
# KAMAL_DESTINATION (if set)
# Only check the build status for production deployments
if ENV["KAMAL_COMMAND"] == "rollback" || ENV["KAMAL_DESTINATION"] != "production"
exit 0
end
require "bundler/inline"
# true = install gems so this is fast on repeat invocations
gemfile(true, quiet: true) do
source "https://rubygems.org"
gem "octokit"
gem "faraday-retry"
end
MAX_ATTEMPTS = 72
ATTEMPTS_GAP = 10
def exit_with_error(message)
$stderr.puts message
exit 1
end
class GithubStatusChecks
attr_reader :remote_url, :git_sha, :github_client, :combined_status
def initialize
@remote_url = github_repo_from_remote_url
@git_sha = `git rev-parse HEAD`.strip
@github_client = Octokit::Client.new(access_token: ENV["GITHUB_TOKEN"])
refresh!
end
def refresh!
@combined_status = github_client.combined_status(remote_url, git_sha)
end
def state
combined_status[:state]
end
def first_status_url
first_status = combined_status[:statuses].find { |status| status[:state] == state }
first_status && first_status[:target_url]
end
def complete_count
combined_status[:statuses].count { |status| status[:state] != "pending"}
end
def total_count
combined_status[:statuses].count
end
def current_status
if total_count > 0
"Completed #{complete_count}/#{total_count} checks, see #{first_status_url} ..."
else
"Build not started..."
end
end
private
def github_repo_from_remote_url
url = `git config --get remote.origin.url`.strip.delete_suffix(".git")
if url.start_with?("https://github.com/")
url.delete_prefix("https://github.com/")
elsif url.start_with?("git@github.com:")
url.delete_prefix("git@github.com:")
else
url
end
end
end
$stdout.sync = true
begin
puts "Checking build status..."
attempts = 0
checks = GithubStatusChecks.new
loop do
case checks.state
when "success"
puts "Checks passed, see #{checks.first_status_url}"
exit 0
when "failure"
exit_with_error "Checks failed, see #{checks.first_status_url}"
when "pending"
attempts += 1
end
exit_with_error "Checks are still pending, gave up after #{MAX_ATTEMPTS * ATTEMPTS_GAP} seconds" if attempts == MAX_ATTEMPTS
puts checks.current_status
sleep(ATTEMPTS_GAP)
checks.refresh!
end
rescue Octokit::NotFound
exit_with_error "Build status could not be found"
end
+3
View File
@@ -0,0 +1,3 @@
#!/usr/bin/env sh
echo "Rebooting kamal-proxy on $KAMAL_HOSTS..."
+17
View File
@@ -0,0 +1,17 @@
# Secrets defined here are available for reference under registry/password, env/secret, builder/secrets,
# and accessories/*/env/secret in config/deploy.yml. All secrets should be pulled from either
# password manager, ENV, or a file. DO NOT ENTER RAW CREDENTIALS HERE! This file needs to be safe for git.
# Example of extracting secrets from 1password (or another compatible pw manager)
# SECRETS=$(kamal secrets fetch --adapter 1password --account your-account --from Vault/Item KAMAL_REGISTRY_PASSWORD RAILS_MASTER_KEY)
# KAMAL_REGISTRY_PASSWORD=$(kamal secrets extract KAMAL_REGISTRY_PASSWORD ${SECRETS})
# RAILS_MASTER_KEY=$(kamal secrets extract RAILS_MASTER_KEY ${SECRETS})
# Use a GITHUB_TOKEN if private repositories are needed for the image
# GITHUB_TOKEN=$(gh config get -h github.com oauth_token)
# Grab the registry password from ENV
KAMAL_REGISTRY_PASSWORD=$KAMAL_REGISTRY_PASSWORD
# Improve security by using a password manager. Never check config/master.key into git!
RAILS_MASTER_KEY=$(cat config/master.key)
+8
View File
@@ -0,0 +1,8 @@
# Omakase Ruby styling for Rails
inherit_gem: { rubocop-rails-omakase: rubocop.yml }
# Overwrite or add rules to create your own house style
#
# # Use `[a, [b, c]]` not `[ a, [ b, c ] ]`
# Layout/SpaceInsideArrayLiteralBrackets:
# Enabled: false
+1
View File
@@ -0,0 +1 @@
ruby-3.2.3
+73
View File
@@ -0,0 +1,73 @@
# syntax=docker/dockerfile:1
# check=error=true
# This Dockerfile is designed for production, not development. Use with Kamal or build'n'run by hand:
# docker build -t simple_aircraft_manager .
# docker run -d -p 80:80 -e RAILS_MASTER_KEY=<value from config/master.key> --name simple_aircraft_manager simple_aircraft_manager
# For a containerized dev environment, see Dev Containers: https://guides.rubyonrails.org/getting_started_with_devcontainer.html
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version
ARG RUBY_VERSION=3.2.3
FROM docker.io/library/ruby:$RUBY_VERSION-slim AS base
# Rails app lives here
WORKDIR /rails
# Install base packages
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y curl libjemalloc2 libvips sqlite3 && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives
# Set production environment
ENV RAILS_ENV="production" \
BUNDLE_DEPLOYMENT="1" \
BUNDLE_PATH="/usr/local/bundle" \
BUNDLE_WITHOUT="development"
# Throw-away build stage to reduce size of final image
FROM base AS build
# Install packages needed to build gems
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential git libyaml-dev pkg-config && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives
# Install application gems
COPY vendor/* ./vendor/
COPY Gemfile Gemfile.lock ./
RUN bundle install && \
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
bundle exec bootsnap precompile --gemfile
# Copy application code
COPY . .
# Precompile bootsnap code for faster boot times
RUN bundle exec bootsnap precompile app/ lib/
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile
# Final stage for app image
FROM base
# Copy built artifacts: gems, application
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
COPY --from=build /rails /rails
# Run and own only the runtime files as a non-root user for security
RUN groupadd --system --gid 1000 rails && \
useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \
chown -R rails:rails db log storage tmp
USER 1000:1000
# Entrypoint prepares the database.
ENTRYPOINT ["/rails/bin/docker-entrypoint"]
# Start server via Thruster by default, this can be overwritten at runtime
EXPOSE 80
CMD ["./bin/thrust", "./bin/rails", "server"]
+67
View File
@@ -0,0 +1,67 @@
source "https://rubygems.org"
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 8.1.0"
# The modern asset pipeline for Rails [https://github.com/rails/propshaft]
gem "propshaft"
# Use sqlite3 as the database for Active Record
gem "sqlite3", ">= 2.1"
# Use the Puma web server [https://github.com/puma/puma]
gem "puma", ">= 5.0"
# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
gem "importmap-rails"
# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
gem "turbo-rails"
# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
gem "stimulus-rails"
# Use Tailwind CSS [https://github.com/rails/tailwindcss-rails]
gem "tailwindcss-rails"
# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
gem "bcrypt", "~> 3.1.7"
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ windows jruby ]
# Use the database-backed adapters for Rails.cache, Active Job, and Action Cable
gem "solid_cache"
gem "solid_queue"
gem "solid_cable"
# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false
# Deploy this application anywhere as a Docker container [https://kamal-deploy.org]
gem "kamal", require: false
# Add HTTP asset caching/compression and X-Sendfile acceleration to Puma [https://github.com/basecamp/thruster/]
gem "thruster", require: false
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"
group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri windows ], require: "debug/prelude"
# Static analysis for security vulnerabilities [https://brakemanscanner.org/]
gem "brakeman", require: false
# Omakase Ruby styling [https://github.com/rails/rubocop-rails-omakase/]
gem "rubocop-rails-omakase", require: false
end
group :development do
# Use console on exceptions pages [https://github.com/rails/web-console]
gem "web-console"
end
group :test do
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
gem "capybara"
gem "selenium-webdriver"
end
gem "chartkick", "~> 5.2"
gem "json", "~> 2.10"
+566
View File
@@ -0,0 +1,566 @@
GEM
remote: https://rubygems.org/
specs:
action_text-trix (2.1.19)
railties
actioncable (8.1.4.1)
actionpack (= 8.1.4.1)
activesupport (= 8.1.4.1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6)
actionmailbox (8.1.4.1)
actionpack (= 8.1.4.1)
activejob (= 8.1.4.1)
activerecord (= 8.1.4.1)
activestorage (= 8.1.4.1)
activesupport (= 8.1.4.1)
mail (>= 2.8.0)
actionmailer (8.1.4.1)
actionpack (= 8.1.4.1)
actionview (= 8.1.4.1)
activejob (= 8.1.4.1)
activesupport (= 8.1.4.1)
mail (>= 2.8.0)
rails-dom-testing (~> 2.2)
actionpack (8.1.4.1)
actionview (= 8.1.4.1)
activesupport (= 8.1.4.1)
nokogiri (>= 1.8.5)
rack (>= 2.2.4)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
useragent (~> 0.16)
actiontext (8.1.4.1)
action_text-trix (~> 2.1.15)
actionpack (= 8.1.4.1)
activerecord (= 8.1.4.1)
activestorage (= 8.1.4.1)
activesupport (= 8.1.4.1)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (8.1.4.1)
activesupport (= 8.1.4.1)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6, >= 1.7.2)
activejob (8.1.4.1)
activesupport (= 8.1.4.1)
globalid (>= 0.3.6)
activemodel (8.1.4.1)
activesupport (= 8.1.4.1)
activerecord (8.1.4.1)
activemodel (= 8.1.4.1)
activesupport (= 8.1.4.1)
timeout (>= 0.4.0)
activestorage (8.1.4.1)
actionpack (= 8.1.4.1)
activejob (= 8.1.4.1)
activerecord (= 8.1.4.1)
activesupport (= 8.1.4.1)
marcel (~> 1.0)
activesupport (8.1.4.1)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
json
logger (>= 1.4.2)
minitest (>= 5.1)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
uri (>= 0.13.1)
addressable (2.9.2)
public_suffix (>= 2.0.2, < 8.0)
ast (2.4.3)
base64 (0.3.0)
bcrypt (3.1.22)
bcrypt_pbkdf (1.1.2)
bcrypt_pbkdf (1.1.2-arm64-darwin)
bcrypt_pbkdf (1.1.2-x86_64-darwin)
bigdecimal (4.1.3)
bindex (0.8.1)
bootsnap (1.26.1)
msgpack (~> 1.5)
brakeman (8.1.0)
racc
builder (3.3.0)
capybara (3.40.0)
addressable
matrix
mini_mime (>= 0.1.3)
nokogiri (~> 1.11)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
chartkick (5.2.1)
concurrent-ruby (1.3.8)
connection_pool (3.0.2)
crass (1.0.8)
date (3.6.0)
debug (1.11.1)
irb (~> 1.10)
reline (>= 0.3.8)
dotenv (3.2.0)
drb (2.2.3)
ed25519 (1.4.0)
erb (6.0.7)
erubi (1.13.1)
et-orbi (1.4.2)
tzinfo
fugit (1.14.0)
et-orbi (~> 1.4)
raabro (~> 1.4)
globalid (1.4.0)
activesupport (>= 6.1)
i18n (1.15.2)
concurrent-ruby (~> 1.0)
importmap-rails (2.2.3)
actionpack (>= 6.0.0)
activesupport (>= 6.0.0)
railties (>= 6.0.0)
io-console (0.9.5)
irb (1.18.0)
pp (>= 0.6.0)
prism (>= 1.3.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
json (2.21.2)
kamal (2.12.0)
activesupport (>= 7.0)
base64 (~> 0.2)
bcrypt_pbkdf (~> 1.0)
concurrent-ruby (~> 1.2)
dotenv (~> 3.1)
ed25519 (~> 1.4)
net-ssh (~> 7.3)
sshkit (>= 1.23.0, < 2.0)
thor (~> 1.3)
zeitwerk (>= 2.6.18, < 3.0)
language_server-protocol (3.17.0.6)
lint_roller (1.1.0)
logger (1.7.0)
loofah (2.25.3)
crass (~> 1.0.2)
nokogiri (>= 1.19.5)
mail (2.9.1)
logger
mini_mime (>= 0.1.1)
net-imap
net-pop
net-smtp
marcel (1.2.1)
matrix (0.4.3)
mini_mime (1.1.5)
minitest (6.0.6)
drb (~> 2.0)
prism (~> 1.5)
msgpack (1.8.7)
net-imap (0.6.8)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.4.0)
timeout
net-scp (4.2.1)
net-ssh (>= 2.6.5, < 9.0.0)
net-sftp (4.1.1)
net-ssh (>= 5.0.0, < 9.0.0)
net-smtp (0.5.2)
net-protocol
net-ssh (7.3.8)
logger
nio4r (2.7.5)
nokogiri (1.19.7-aarch64-linux-gnu)
racc (~> 1.4)
nokogiri (1.19.7-aarch64-linux-musl)
racc (~> 1.4)
nokogiri (1.19.7-arm-linux-gnu)
racc (~> 1.4)
nokogiri (1.19.7-arm-linux-musl)
racc (~> 1.4)
nokogiri (1.19.7-arm64-darwin)
racc (~> 1.4)
nokogiri (1.19.7-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.19.7-x86_64-linux-gnu)
racc (~> 1.4)
nokogiri (1.19.7-x86_64-linux-musl)
racc (~> 1.4)
ostruct (0.6.3)
parallel (1.28.0)
parser (3.3.13.0)
ast (~> 2.4.1)
racc
pp (0.6.4)
prettyprint
prettyprint (0.2.1)
prism (1.9.0)
propshaft (1.3.2)
actionpack (>= 7.0.0)
activesupport (>= 7.0.0)
rack
public_suffix (7.0.5)
puma (8.0.2)
nio4r (~> 2.0)
raabro (1.5.0)
racc (1.8.1)
rack (3.2.8)
rack-session (2.1.2)
base64 (>= 0.1.0)
rack (>= 3.0.0)
rack-test (2.3.0)
rack (>= 1.3)
rackup (2.3.1)
rack (>= 3)
rails (8.1.4.1)
actioncable (= 8.1.4.1)
actionmailbox (= 8.1.4.1)
actionmailer (= 8.1.4.1)
actionpack (= 8.1.4.1)
actiontext (= 8.1.4.1)
actionview (= 8.1.4.1)
activejob (= 8.1.4.1)
activemodel (= 8.1.4.1)
activerecord (= 8.1.4.1)
activestorage (= 8.1.4.1)
activesupport (= 8.1.4.1)
bundler (>= 1.15.0)
railties (= 8.1.4.1)
rails-dom-testing (2.3.0)
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.7.2)
loofah (~> 2.25, >= 2.25.3)
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
railties (8.1.4.1)
actionpack (= 8.1.4.1)
activesupport (= 8.1.4.1)
irb (~> 1.13)
rackup (>= 1.0.0)
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
tsort (>= 0.2)
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.4.2)
rbs (4.1.3)
logger
prism (>= 1.6.0)
tsort
rdoc (8.1.0)
erb
prism (>= 1.6.0)
rbs (>= 4.0.0)
tsort
regexp_parser (2.13.1)
reline (0.7.0)
io-console (~> 0.5)
rexml (3.4.4)
rubocop (1.92.2)
json (>= 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
parallel (>= 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.11.3, < 3.0)
rubocop-ast (>= 1.49.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.50.0)
parser (>= 3.3.7.2)
prism (~> 1.7)
rubocop-performance (1.27.0)
lint_roller (~> 1.1)
rubocop (>= 1.89.0, < 2.0)
rubocop-ast (>= 1.47.1, < 2.0)
rubocop-rails (2.38.0)
activesupport (>= 4.2.0)
lint_roller (~> 1.1)
rack (>= 1.1)
rubocop (>= 1.89.0, < 2.0)
rubocop-ast (>= 1.44.0, < 2.0)
rubocop-rails-omakase (1.1.0)
rubocop (>= 1.72)
rubocop-performance (>= 1.24)
rubocop-rails (>= 2.30)
ruby-progressbar (1.13.0)
rubyzip (3.7.0)
securerandom (0.4.1)
selenium-webdriver (4.44.0)
base64 (~> 0.2)
logger (~> 1.4)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 4.0)
websocket (~> 1.0)
solid_cable (3.0.12)
actioncable (>= 7.2)
activejob (>= 7.2)
activerecord (>= 7.2)
railties (>= 7.2)
solid_cache (1.0.10)
activejob (>= 7.2)
activerecord (>= 7.2)
railties (>= 7.2)
solid_queue (1.7.2)
activejob (>= 7.1)
activerecord (>= 7.1)
concurrent-ruby (>= 1.3.1)
fugit (~> 1.11)
railties (>= 7.1)
thor (>= 1.3.1)
sqlite3 (2.10.2-aarch64-linux-gnu)
sqlite3 (2.10.2-aarch64-linux-musl)
sqlite3 (2.10.2-arm-linux-gnu)
sqlite3 (2.10.2-arm-linux-musl)
sqlite3 (2.10.2-arm64-darwin)
sqlite3 (2.10.2-x86_64-darwin)
sqlite3 (2.10.2-x86_64-linux-gnu)
sqlite3 (2.10.2-x86_64-linux-musl)
sshkit (1.25.1)
base64
logger
net-scp (>= 1.1.2)
net-sftp (>= 2.1.2)
net-ssh (>= 2.8.0)
ostruct
stimulus-rails (1.3.4)
railties (>= 6.0.0)
tailwindcss-rails (4.7.0)
railties (>= 7.0.0)
tailwindcss-ruby (~> 4.0)
tailwindcss-ruby (4.3.3)
tailwindcss-ruby (4.3.3-aarch64-linux-gnu)
tailwindcss-ruby (4.3.3-aarch64-linux-musl)
tailwindcss-ruby (4.3.3-arm64-darwin)
tailwindcss-ruby (4.3.3-x86_64-darwin)
tailwindcss-ruby (4.3.3-x86_64-linux-gnu)
tailwindcss-ruby (4.3.3-x86_64-linux-musl)
thor (1.5.0)
thruster (0.1.27)
thruster (0.1.27-aarch64-linux)
thruster (0.1.27-arm64-darwin)
thruster (0.1.27-x86_64-darwin)
thruster (0.1.27-x86_64-linux)
timeout (0.6.1)
tsort (0.2.0)
turbo-rails (2.0.23)
actionpack (>= 7.1.0)
railties (>= 7.1.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (3.3.0)
unicode-emoji (~> 4.3)
unicode-emoji (4.3.0)
uri (1.1.2)
useragent (0.16.11)
web-console (4.3.0)
actionview (>= 8.0.0)
bindex (>= 0.4.0)
railties (>= 8.0.0)
websocket (1.2.11)
websocket-driver (0.8.2)
base64
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.8.3)
PLATFORMS
aarch64-linux
aarch64-linux-gnu
aarch64-linux-musl
arm-linux-gnu
arm-linux-musl
arm64-darwin
x86_64-darwin
x86_64-linux
x86_64-linux-musl
DEPENDENCIES
bcrypt (~> 3.1.7)
bootsnap
brakeman
capybara
chartkick (~> 5.2)
debug
importmap-rails
json (~> 2.10)
kamal
propshaft
puma (>= 5.0)
rails (~> 8.1.0)
rubocop-rails-omakase
selenium-webdriver
solid_cable
solid_cache
solid_queue
sqlite3 (>= 2.1)
stimulus-rails
tailwindcss-rails
thruster
turbo-rails
tzinfo-data
web-console
CHECKSUMS
action_text-trix (2.1.19) sha256=7012f59421009cf284aa651294896414d653a61a2417c9b8714c8476d2f74009
actioncable (8.1.4.1) sha256=007670f7297973e94809e9f32a56624a7aa60b6e9d6696cd078064ce86d1c7fc
actionmailbox (8.1.4.1) sha256=18b43dd842bf3a3e31b8e38b7917c21e48c128fc8b263c893481cc66ee1a8f78
actionmailer (8.1.4.1) sha256=a7b71dedf744e48dd6751e97350634edce9a2f7beeceac332dcccb91729ad066
actionpack (8.1.4.1) sha256=8c6f2e7cbd2653ef0539bde1ff20eb3e2e264e366affe56f0ba7f06d3670cb4b
actiontext (8.1.4.1) sha256=fb59611dc16e2b6bbfcec66793acfae6cdd64b1e35ef3f9175424f31e62c38da
actionview (8.1.4.1) sha256=d25b4d9cf8d0c0195ffcfe8b2cf3fcbe6fea54fd7c17f1a9cb8182881463f12b
activejob (8.1.4.1) sha256=82c4c9311ea1016d5f7f134a0c5f9b6527cad5a6237f5f3f60aa17984ef36229
activemodel (8.1.4.1) sha256=063caf105372fbc98b2d789e4be23de63ac5c043f7d9330f04e2caddb7012805
activerecord (8.1.4.1) sha256=bd65599ca0b5d210937f835d42c7aff69d271741c75aab022730be6cbce67e87
activestorage (8.1.4.1) sha256=0f4e2f114f3584723a80a2c089aacc6170e765a0b2c385c9782e26ed78f05c66
activesupport (8.1.4.1) sha256=16ac4f341ca65c85a1fcdb8ac73f68891aae9e3c4a6f9c3a27daed8b00017ed7
addressable (2.9.2) sha256=9117c7e7d6ee07230e75ce41fb9401ae55354dc654fcd0e862ba41d539e9a610
ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383
base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
bcrypt (3.1.22) sha256=1f0072e88c2d705d94aff7f2c5cb02eb3f1ec4b8368671e19112527489f29032
bcrypt_pbkdf (1.1.2) sha256=c2414c23ce66869b3eb9f643d6a3374d8322dfb5078125c82792304c10b94cf6
bcrypt_pbkdf (1.1.2-arm64-darwin) sha256=afdd6feb6ed5a97b8e44caacb3f2d641b98af78e6a516d4a3520b69af5cf9fea
bcrypt_pbkdf (1.1.2-x86_64-darwin) sha256=35f5639d0058e6c2cc2f856f9c0b14080543268d3047abe6bc81c513093caa0e
bigdecimal (4.1.3) sha256=61ebe1e5e559bdc3cc6f2c0ee7f427321fc838f59611c294356eb04d6e21cf66
bindex (0.8.1) sha256=7b1ecc9dc539ed8bccfc8cb4d2732046227b09d6f37582ff12e50a5047ceb17e
bootsnap (1.26.1) sha256=5b5bd90f8f13ea338627c1d56ffbe2ea25e743ac48c2afec1a9bea3a06a264e2
brakeman (8.1.0) sha256=cfa9e5214e4925842f4bc849a64f8a7e6c5d0425fe98eac8d7b7bc60fdc17e07
builder (3.3.0) sha256=497918d2f9dca528fdca4b88d84e4ef4387256d984b8154e9d5d3fe5a9c8835f
capybara (3.40.0) sha256=42dba720578ea1ca65fd7a41d163dd368502c191804558f6e0f71b391054aeef
chartkick (5.2.1) sha256=2848d7de87189f30f28d077eb0bbdebc8a1f0f6f81de1ded95008fe564369949
concurrent-ruby (1.3.8) sha256=b2f1be836e968ccc78ccfce277ea79c72a88633f22306782c16ff23fb415d1e1
connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a
crass (1.0.8) sha256=7a0145c7a2c59f8e7923b3a69ce819c444823a00a5127d805298fea13be24efe
date (3.6.0) sha256=18ac945c4e24ebd93534f8eab8c2fd8c5604b3e977105b3798d62a1e8d27b580
debug (1.11.1) sha256=2e0b0ac6119f2207a6f8ac7d4a73ca8eb4e440f64da0a3136c30343146e952b6
dotenv (3.2.0) sha256=e375b83121ea7ca4ce20f214740076129ab8514cd81378161f11c03853fe619d
drb (2.2.3) sha256=0b00d6fdb50995fe4a45dea13663493c841112e4068656854646f418fda13373
ed25519 (1.4.0) sha256=16e97f5198689a154247169f3453ef4cfd3f7a47481fde0ae33206cdfdcac506
erb (6.0.7) sha256=c5ca6dc25b0ef974a44dc8f59fe847577122483b1968a38dec305c60bf91ee92
erubi (1.13.1) sha256=a082103b0885dbc5ecf1172fede897f9ebdb745a4b97a5e8dc63953db1ee4ad9
et-orbi (1.4.2) sha256=bb555dae668419cb24caa2a293a170e58be6d4df1e017c51f5030bdc133cd20c
fugit (1.14.0) sha256=e311a9cc85a54bb67649df45060e721282a1e2c8ebad40e41874a3a7d576f37e
globalid (1.4.0) sha256=037f12fbf1d9d7a014d501c2d5c77356fd4ddd96d7a7991d6700bba96706f427
i18n (1.15.2) sha256=00f9eb62412fe593b2a65a97daa75300d37abb8f7202ec748e94b6d46a9dd1b5
importmap-rails (2.2.3) sha256=7101be2a4dc97cf1558fb8f573a718404c5f6bcfe94f304bf1f39e444feeb16a
io-console (0.9.5) sha256=83dd9bbf4c4680416629245b39cd4212eb5f4d9a4ea91804870c1f6b846414d5
irb (1.18.0) sha256=de9454a0703a54704b9811a5ef31a60c86949fbf4013fcf244fabc7c775248e3
json (2.21.2) sha256=1f1d3b7cf2b3ba1a69beca0bb6db13d5438b80bff3cd54cdaaa620b9b07c1c6a
kamal (2.12.0) sha256=c51d1ab085e515470f98d0c0f043637122b5ebf76e8b610cb1fbbed0b7f9b8fa
language_server-protocol (3.17.0.6) sha256=5ef2c0c138f8267e1bc631d3328347d354f96724b0af22f2c79516120443b7f0
lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
loofah (2.25.3) sha256=545f14eef0cc2a7de80df560530d593232b7c07e515c5c4e37532d9cb5b0185c
mail (2.9.1) sha256=06574eca475253d6c18145dd70af80d0eb970182d55053497c5f4d797ea160e8
marcel (1.2.1) sha256=1678e9360e32f9eafa917c80029e2f6d10b2715c66a4b87b6d0da9b9cd1f859f
matrix (0.4.3) sha256=a0d5ab7ddcc1973ff690ab361b67f359acbb16958d1dc072b8b956a286564c5b
mini_mime (1.1.5) sha256=8681b7e2e4215f2a159f9400b5816d85e9d8c6c6b491e96a12797e798f8bccef
minitest (6.0.6) sha256=153ea36d1d987a62942382b61075745042a2b3123b1cd48f4c3675af9cc7d6f1
msgpack (1.8.7) sha256=dfefec761b5f9047e6e8d95d2c7f8af4b3725d984a01942adc533aa819a2df33
net-imap (0.6.8) sha256=eb30bb62227b64a3af6b518b04b2375113d69f68f15de59b0193b07d98acf6d9
net-pop (0.1.2) sha256=848b4e982013c15b2f0382792268763b748cce91c9e91e36b0f27ed26420dff3
net-protocol (0.4.0) sha256=f9f90c8c6f64794a45160bf422177a336db12809de3beeeaa26b88fcd2e8c853
net-scp (4.2.1) sha256=5c9ff6743da37eef6746f248043d97d2bbf3910a4694ec8e372326ec588c2394
net-sftp (4.1.1) sha256=dc2019e59e3e3552943b576f14cb0201ec55823935b967e10dcda169b04e4573
net-smtp (0.5.2) sha256=35103cc04d6b2d94632f9928ede07483c24b70b9c0db1f231fea43909b678f3c
net-ssh (7.3.8) sha256=16bb1fccc4d9a580decdeea8ddb98e8544df29b7e6ac8cb94d4b379cfe4bee9f
nio4r (2.7.5) sha256=6c90168e48fb5f8e768419c93abb94ba2b892a1d0602cb06eef16d8b7df1dca1
nokogiri (1.19.7-aarch64-linux-gnu) sha256=8f5e15d299602456406e1f03a9f3456cceb33a0722811e818d2ee2214eb4c84a
nokogiri (1.19.7-aarch64-linux-musl) sha256=efe0c3602e6e54521bc21c681930ce5568e2d11203de17400710b2b3ca2e4cb4
nokogiri (1.19.7-arm-linux-gnu) sha256=7fd1907125691aa89e838cc91161761c758b4e17bb32f0dd9b5515a82cc759af
nokogiri (1.19.7-arm-linux-musl) sha256=28d0ff0c87b6bb2e56580323a6fb049d5d4a02b94f0958fdd47e9ac146991c77
nokogiri (1.19.7-arm64-darwin) sha256=f27d7f25f4873fbc3aa35a2cc2fb680c98555fec1925348da439d0869d541142
nokogiri (1.19.7-x86_64-darwin) sha256=508e81e8c5f84aaa240dce981bf1c43faae60808726f0ce7024ee92effc5cafe
nokogiri (1.19.7-x86_64-linux-gnu) sha256=25865ccb462f714e712fdf8906fde07849cb6704a808e3d629d75baa5af5dd3b
nokogiri (1.19.7-x86_64-linux-musl) sha256=464d1f3dfb0d53cf54c0c6a7e23e8e91cf68ec3cafc2b27dc4a7682f2d9bf546
ostruct (0.6.3) sha256=95a2ed4a4bd1d190784e666b47b2d3f078e4a9efda2fccf18f84ddc6538ed912
parallel (1.28.0) sha256=33e6de1484baf2524792d178b0913fc8eb94c628d6cfe45599ad4458c638c970
parser (3.3.13.0) sha256=e02f9b63c2fe05b0c68f692ba4df89b3cb113b663964f75d988fbebfd6c3deca
pp (0.6.4) sha256=dfcb0fce700c41456265922884f9fe195d7fbb0674a3578e6c0f69588e82b570
prettyprint (0.2.1) sha256=d555d57ea6d7cf001d4774b693546a6bd88bec1e778ddffb5c60b68ceec4b7d4
prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85
propshaft (1.3.2) sha256=1d56a3e56a92c21bfc29caf07406b5386b00d4c47ddf357cf989a5a234b1389e
public_suffix (7.0.5) sha256=1a8bb08f1bbea19228d3bed6e5ed908d1cb4f7c2726d18bd9cadf60bc676f623
puma (8.0.2) sha256=c8ed871dfbbe66448ea9ffd46692342d9804d4071522b52b5331b7b6e7b686fb
raabro (1.5.0) sha256=3f998a7bc84f9c84df3ab580634d2e0a5bda4f0841168d56035f529c9877440a
racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
rack (3.2.8) sha256=1fecc85e463ebc7a2a945fff829ffcd549babeb1556384796fad946c28dc4ec7
rack-session (2.1.2) sha256=595434f8c0c3473ae7d7ac56ecda6cc6dfd9d37c0b2b5255330aa1576967ffe8
rack-test (2.3.0) sha256=b118d177cc002c572fc1b6fd8d19c9ed5881a36e8d6f689f9e618f9f861241e8
rackup (2.3.1) sha256=6c79c26753778e90983761d677a48937ee3192b3ffef6bc963c0950f94688868
rails (8.1.4.1) sha256=365c3a0ad2713bd6e60628e5e826622d4ca8dee60b5a7e560e9b20844e9650bc
rails-dom-testing (2.3.0) sha256=8acc7953a7b911ca44588bf08737bc16719f431a1cc3091a292bca7317925c1d
rails-html-sanitizer (1.7.2) sha256=a21ef45b7a6639fc8e2282473c547514cb86ae271616162a946bf89148fa2424
railties (8.1.4.1) sha256=ff2ef4b5a62cbc89811f88be11c776e2ed71b14dd012eae6a494d37994aa9782
rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701
rbs (4.1.3) sha256=0c4474a9751cdc14364bfad0b3e53678323bbdc2c31683b0445932867dbab8c4
rdoc (8.1.0) sha256=befc37880a5cfd36dcb176c748b5fd5ee39dd3536a75e81824e4972ce230f60a
regexp_parser (2.13.1) sha256=5aedb6b7c35688f51e86eef17a15374dfd287c83f4ca644b2c5f3ec50a33b44b
reline (0.7.0) sha256=5b012d8e55dbf9d450f12bde2cf7d15ff546ae80b3f8f3b30e570d431815583d
rexml (3.4.4) sha256=19e0a2c3425dfbf2d4fc1189747bdb2f849b6c5e74180401b15734bc97b5d142
rubocop (1.92.2) sha256=14fb31eed143a0dc6f78186c550c1715e81cd38f59d05d1165050e445c1f5382
rubocop-ast (1.50.0) sha256=b9ca88300da0803ee222ad20cdb30494c0a784eed06fdc35d254b06d662788db
rubocop-performance (1.27.0) sha256=eeeb1374d062a368ee1c787b70eb0b0cc4b184cb1f8565f424760946146d61ce
rubocop-rails (2.38.0) sha256=6e2b7c532efa95e3050371bec20b8f5b025662acead8bc70ee31f0e3e6fa2f06
rubocop-rails-omakase (1.1.0) sha256=2af73ac8ee5852de2919abbd2618af9c15c19b512c4cfc1f9a5d3b6ef009109d
ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
rubyzip (3.7.0) sha256=65c19294da75297a939006f3516deacc33185fbd721ff1954f7a231db6d3e121
securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1
selenium-webdriver (4.44.0) sha256=6f1df072529af369589c46f0e01132952aabb250cfd683c274d74dc1eb5d8477
solid_cable (3.0.12) sha256=a168a54731a455d5627af48d8441ea3b554b8c1f6e6cd6074109de493e6b0460
solid_cache (1.0.10) sha256=bc05a2fb3ac78a6f43cbb5946679cf9db67dd30d22939ededc385cb93e120d41
solid_queue (1.7.2) sha256=a22685e1d2ee14ce7b4e5d4592c9d8e837951884c51555609dee58679ed03325
sqlite3 (2.10.2-aarch64-linux-gnu) sha256=e9aea2c2b3476fc875dd8a89313a9a2862818519c0186bfb5b56d6f57bb08d98
sqlite3 (2.10.2-aarch64-linux-musl) sha256=4986fc40cdf21342362b72a941df28e95cfe0e644f3ad2532d948b157c39dbee
sqlite3 (2.10.2-arm-linux-gnu) sha256=762f609ef891463226b472d3df66aea84d5466ff4376d3ccf4a059718c4ce9c9
sqlite3 (2.10.2-arm-linux-musl) sha256=833623eaf1157b1b85d1c0830e3e8f9beb3bb95a9bec3d252f20557a50e9803a
sqlite3 (2.10.2-arm64-darwin) sha256=5b0d235ea037e6dcd1b8387a19d73be571917db9f93044d35741cf933a21a37d
sqlite3 (2.10.2-x86_64-darwin) sha256=fd2c67b49d313031af112e172c83ab321681a2b4996bf882eefac50be7bea08f
sqlite3 (2.10.2-x86_64-linux-gnu) sha256=ca92731ab464df9cae503fa1a439a549e2724f6953c8c05a7769b59366e38f15
sqlite3 (2.10.2-x86_64-linux-musl) sha256=b9f8fc62f3e0eb8966b41de251b492b4c8e9d1b23559beb6e150ad7f8d590941
sshkit (1.25.1) sha256=be3f10b9d6eb0b44d5eaba3f7cbe41bc6bb894bce4339688ac20124391455b78
stimulus-rails (1.3.4) sha256=765676ffa1f33af64ce026d26b48e8ffb2e0b94e0f50e9119e11d6107d67cb06
tailwindcss-rails (4.7.0) sha256=9b09bd677d7cd226fc8ff3f7d2d91c6dc6c3da75dd74dc4cab5f94711f69ba41
tailwindcss-ruby (4.3.3) sha256=ee0a64030749862deb501acab4c4aaf5adbee13865746a33299d46d7b5d0952a
tailwindcss-ruby (4.3.3-aarch64-linux-gnu) sha256=c86d6dd3eccc85fe0d792a832b06f2bf3c0a7a83b399308aeb9d8f5725f42a6a
tailwindcss-ruby (4.3.3-aarch64-linux-musl) sha256=72b77ca9edea82383dd09510ab520a122e3cb9f9864ca5b38e27698098d2b899
tailwindcss-ruby (4.3.3-arm64-darwin) sha256=776c51fc734aac64bde0c253eadd2ed2e610b2ba0d8e760501fe7cbec55fd6cf
tailwindcss-ruby (4.3.3-x86_64-darwin) sha256=483011e5d3792cf5ef4afdfb04c1d95daccf42c30cdb6fe53b77520954e7b922
tailwindcss-ruby (4.3.3-x86_64-linux-gnu) sha256=2337017ff8b02698480eae1e9637cf01faa0e4824db89d067a13c5a5ee38c9b2
tailwindcss-ruby (4.3.3-x86_64-linux-musl) sha256=27d478c417bcf73828e5b544744c5bdfd5b5cb54f1a266fc4f185281c32efe6c
thor (1.5.0) sha256=e3a9e55fe857e44859ce104a84675ab6e8cd59c650a49106a05f55f136425e73
thruster (0.1.27) sha256=5fd3855192bb4e8d13db69ae5f70d39f2dfd88fe0394fa372104996edf0bb599
thruster (0.1.27-aarch64-linux) sha256=c50789f2dcd4dfa072c4719f99c38dea5d47ebb60ad0cc1fd1996b2266ecfd22
thruster (0.1.27-arm64-darwin) sha256=ece0ff0f2ec195008030fbca97067e5e867f4e1f66501fa8b8a3ec3f829bf2bf
thruster (0.1.27-x86_64-darwin) sha256=f389bdfccf332dabff8053194e64cd65d4ae247f1afd386624233a1dfaa41485
thruster (0.1.27-x86_64-linux) sha256=7e0e6381011401810b047ff25506e0e38755b2430499ff5586f1a110086981c6
timeout (0.6.1) sha256=78f57368a7e7bbadec56971f78a3f5ecbcfb59b7fcbb0a3ed6ddc08a5094accb
tsort (0.2.0) sha256=9650a793f6859a43b6641671278f79cfead60ac714148aabe4e3f0060480089f
turbo-rails (2.0.23) sha256=ee0d90733aafff056cf51ff11e803d65e43cae258cc55f6492020ec1f9f9315f
tzinfo (2.0.6) sha256=8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b
unicode-display_width (3.3.0) sha256=4b7aa66a4b11db50f6f7e98411215cd0dd10eaecb665d36eec5bcacb3fa0b613
unicode-emoji (4.3.0) sha256=11c02fa73290378c066bb0562cd4c87d8e1b706fbbe0059ca12746a4244de8ce
uri (1.1.2) sha256=89292e98eabbef6248b0a0ed5e7e398e152f83f17560023a6d94a7f492b169fb
useragent (0.16.11) sha256=700e6413ad4bb954bb63547fa098dddf7b0ebe75b40cc6f93b8d54255b173844
web-console (4.3.0) sha256=e13b71301cdfc2093f155b5aa3a622db80b4672d1f2f713119cc7ec7ac6a6da4
websocket (1.2.11) sha256=b7e7a74e2410b5e85c25858b26b3322f29161e300935f70a0e0d3c35e0462737
websocket-driver (0.8.2) sha256=97c556b019bf3410b4961002ac501621e9322d3f8a7bc02161a09301cc4c4146
websocket-extensions (0.1.5) sha256=1c6ba63092cda343eb53fc657110c71c754c56484aad42578495227d717a8241
xpath (3.2.0) sha256=6dfda79d91bb3b949b947ecc5919f042ef2f399b904013eb3ef6d20dd3a4082e
zeitwerk (2.8.3) sha256=2c85125a8467ce069e20123d1e709a08955c9d29c118c25b46b7b7fafdbb92e5
BUNDLED WITH
4.0.8
+2
View File
@@ -0,0 +1,2 @@
web: bin/rails server
css: bin/rails tailwindcss:watch
+129
View File
@@ -0,0 +1,129 @@
# Simple Aircraft Manager (Rails)
A Ruby on Rails port of [Simple Aircraft Manager](https://github.com/marbindrakon/simple-aircraft-manager), a self-hosted app for tracking records and status for small fleets of aircraft: components and TBO, squawks, ADs, inspections, logbook, documents, oil and fuel trends, and read-only share links for mechanics and buyers.
The port aims to be **easy to host**. It runs as one process with one SQLite database directory. It needs no Postgres, no Redis, no nginx, and no Kubernetes.
## Stack
- Rails 8.1, SQLite. Solid Queue, Solid Cache, and Solid Cable all use SQLite, so there are no extra services.
- Hotwire (Turbo and Stimulus) with importmap, so there is no Node build step. Tailwind CSS 4 runs through `tailwindcss-rails`.
- Active Storage on local disk handles pictures, document pages, squawk attachments, and track logs.
- Chartkick and Chart.js draw the oil and fuel charts.
- Authentication uses the Rails 8 built-in generator (sessions plus password reset).
## Quick start (development)
```bash
bundle install
bin/rails db:prepare
DEMO=1 bin/rails db:seed # optional: demo aircraft N12345
bin/dev # http://localhost:3000
```
With demo data, sign in as `admin@example.com` / `password123` (owner) or `pilot@example.com` / `password123` (pilot).
Without demo data, the first visit asks you to create the admin account.
Run the tests: `bin/rails test`
## Hosting
Everything persistent lives in `storage/`: the SQLite databases and the uploaded files. Back up that one directory.
### Option A: Docker Compose (simplest)
```bash
cp .env.example .env # set SECRET_KEY_BASE (bin/rails secret), APP_HOST, FORCE_SSL
docker compose up -d --build # http://<host>:3000
```
Data lives in the `sam_storage` volume. Set `FORCE_SSL=false` if you serve plain HTTP on a LAN. Set it to `true` when a TLS reverse proxy such as Caddy, Traefik, or Cloudflare Tunnel sits in front.
### Option B: Kamal (any VPS, automatic TLS)
Edit `config/deploy.yml` with your server IP, registry, and domain, then run `bin/kamal setup`. Kamal Proxy handles Let's Encrypt certificates. Background jobs run inside Puma (`SOLID_QUEUE_IN_PUMA`).
### Option C: Plain server / PaaS
The app is a standard Rails app. Run `bin/rails db:prepare && bin/thrust bin/rails server` with `RAILS_ENV=production`, `SECRET_KEY_BASE`, and `SOLID_QUEUE_IN_PUMA=true`. Mount `storage/` on persistent disk.
### Environment variables
| Variable | Purpose |
|---|---|
| `SECRET_KEY_BASE` | Required in production (`bin/rails secret`). Alternatively provide `RAILS_MASTER_KEY`. |
| `FORCE_SSL` | `true` (default) redirects to HTTPS and sets secure cookies. Use `false` for plain HTTP. |
| `APP_HOST` | Host used in password-reset email links. |
| `SMTP_ADDRESS`, `SMTP_PORT`, `SMTP_USERNAME`, `SMTP_PASSWORD`, `MAIL_FROM` | Optional. They enable password-reset emails. Without them an admin resets passwords from **Users**. |
### Backups
SQLite runs in WAL mode, so a plain file copy taken while the app is running can be inconsistent. Use the SQLite backup command instead:
```bash
mkdir -p backup
for db in storage/production*.sqlite3; do sqlite3 "$db" ".backup 'backup/$(basename "$db")'"; done
rsync -a --exclude '*.sqlite3*' storage/ backup/ # uploaded files
```
Alternatively, stop the container and copy the volume.
## Features
| Area | Notes |
|---|---|
| Fleet dashboard | Every aircraft you can access, with airworthiness status and its top issues. |
| Airworthiness | RED/ORANGE/GREEN from AD compliance, grounding squawks, inspection recurrency, and replacement-critical components. Warnings start 10 hours or 30 days ahead. Logic: `app/services/airworthiness.rb`, `app/services/compliance.rb`. |
| Hours | Absolute tach/hobbs updates or per-flight logs. Both apply the delta to every in-service component. Downward corrections are clamped at 0. |
| Airworthiness enforcement | Optional per aircraft. It blocks flight logs and hours updates while the aircraft is RED. |
| Components | Tree of parent and child parts, TBO and replacement limits, and service/replace reset. Owners can create new component types inline. |
| Squawks | Four priorities. "Ground Aircraft" makes the aircraft RED. Supports attachments, resolve, and reopen. |
| ADs and bulletins | Shared across aircraft and applicable to the airframe or to specific components. Hour- and month-based recurrence (due at end of month), conditional and non-mandatory types, and compliance history. |
| Inspections | Shared inspection types with hour, month, and day recurrence, plus history. |
| Logbook | Maintenance entries with search and a link to a scanned document page. |
| Documents | Collections, multi-file documents with a page viewer, and per-document share visibility. |
| Major repairs and alterations | Form 337, STC, and ICA tracking. |
| Oil and fuel | Records, trend charts, and averages (last 20 intervals, IQR outlier filtering, manual exclusion). |
| Activity log | Every write is recorded as an `AircraftEvent`. |
| Access | Admin, owner, and pilot roles, plus share links (Status or Maintenance privilege, optional expiry, at most 10 per aircraft). |
### Roles
| Action | Admin | Owner | Pilot |
|---|:-:|:-:|:-:|
| View everything on the aircraft | ✓ | ✓ | ✓ |
| Update hours, log flights, add squawks/notes/oil/fuel | ✓ | ✓ | ✓ |
| Edit or delete squawks and notes, resolve squawks | ✓ | ✓ | |
| Components, logbook, ADs, inspections, documents, major records | ✓ | ✓ | |
| Edit or delete aircraft, manage people and share links | ✓ | ✓ | |
| Create aircraft (creator becomes owner) | ✓ | ✓ | ✓ |
| Manage users and component types | ✓ | | |
Users who aren't on an aircraft get a 404 for it, identical to a missing record.
## Mapping from the Django original
| Django | Rails |
|---|---|
| `health/services.py` | `app/services/airworthiness.rb`, `compliance.rb`, `hours_service.rb`, `consumption_stats.rb` |
| `AircraftScopedMixin` / `core/permissions.py` | `app/controllers/concerns/aircraft_scoped.rb` |
| `EventLoggingMixin` / `log_event` | `Aircraft#log_event!`, called from controllers |
| DRF viewsets + Alpine.js mixins | Server-rendered controllers and ERB views with Turbo |
| `AD` | `AirworthinessDirective` |
| `MajorRepairAlteration` | `MajorRecord` |
| `DocumentImage` | `Document has_many_attached :pages` |
| `AircraftShareToken` | `ShareToken` (`has_secure_token`) |
| `views_public.py` | `SharedController` → `/shared/:token` |
Differences from the original:
- Integer primary keys instead of UUIDs. Share tokens are 32-character random strings.
- Logbook entries and inspection records don't keep many-to-many links to components. An inspection record or AD compliance can reference one component.
- Accounts are created by an admin, or by the first-run setup. The original's invitation codes aren't implemented yet.
### Not yet ported
AI logbook transcription, oil-analysis PDF import, the MCP server for AI agents, OIDC single sign-on, invitation codes, aircraft import/export, the plugin system, and the desktop builds.
## License
The original project is released under [The Unlicense](https://unlicense.org). This port follows the same spirit.
+6
View File
@@ -0,0 +1,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require_relative "config/application"
Rails.application.load_tasks
View File
Whitespace-only changes.
View File
Whitespace-only changes.
+10
View File
@@ -0,0 +1,10 @@
/*
* This is a manifest file that'll be compiled into application.css.
*
* With Propshaft, assets are served efficiently without preprocessing steps. You can still include
* application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
* cascading order, meaning styles declared later in the document or manifest will override earlier ones,
* depending on specificity.
*
* Consider organizing styles into separate files for maintainability.
*/
+36
View File
@@ -0,0 +1,36 @@
@import "tailwindcss";
@utility btn { @apply inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium shadow-sm transition cursor-pointer disabled:opacity-50; }
@utility btn-primary { @apply btn bg-sky-700 text-white hover:bg-sky-800; }
@utility btn-secondary { @apply btn bg-white text-slate-700 ring-1 ring-slate-300 ring-inset hover:bg-slate-50; }
@utility btn-danger { @apply btn bg-white text-red-700 ring-1 ring-red-300 ring-inset hover:bg-red-50; }
@utility btn-sm { @apply px-2 py-1 text-xs; }
@utility link { @apply text-sky-700 hover:underline; }
@utility card { @apply rounded-lg bg-white shadow-sm ring-1 ring-slate-200; }
@utility card-header { @apply flex flex-wrap items-center justify-between gap-3 border-b border-slate-200 px-4 py-3; }
@utility card-title { @apply text-base font-semibold text-slate-900; }
@utility card-body { @apply p-4; }
@utility label { @apply block text-sm font-medium text-slate-700 mb-1; }
@utility input { @apply block w-full rounded-md border-0 px-2.5 py-1.5 text-sm text-slate-900 shadow-sm ring-1 ring-slate-300 ring-inset placeholder:text-slate-400 focus:ring-2 focus:ring-sky-600 focus:outline-none bg-white; }
@utility hint { @apply mt-1 text-xs text-slate-500; }
@utility field-error { @apply mt-1 text-xs text-red-600; }
@utility table {
@apply min-w-full text-sm;
& th { @apply px-3 py-2 text-left text-xs font-semibold uppercase tracking-wide text-slate-500 bg-slate-50; }
& td { @apply px-3 py-2 align-top text-slate-700; }
& tbody tr { @apply border-t border-slate-100; }
& tbody tr:hover { @apply bg-slate-50; }
}
@utility badge { @apply inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ring-1 ring-inset whitespace-nowrap; }
@utility badge-red { @apply badge bg-red-50 text-red-700 ring-red-600/20; }
@utility badge-orange { @apply badge bg-amber-50 text-amber-800 ring-amber-600/30; }
@utility badge-green { @apply badge bg-emerald-50 text-emerald-700 ring-emerald-600/20; }
@utility badge-blue { @apply badge bg-sky-50 text-sky-700 ring-sky-600/20; }
@utility badge-gray { @apply badge bg-slate-100 text-slate-600 ring-slate-500/20; }
@utility tab { @apply whitespace-nowrap border-b-2 border-transparent px-3 py-2 text-sm font-medium text-slate-500 hover:border-slate-300 hover:text-slate-700; }
@utility tab-active { @apply border-sky-700 text-sky-700; }
@@ -0,0 +1,16 @@
module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :current_user
def connect
set_current_user || reject_unauthorized_connection
end
private
def set_current_user
if session = Session.find_by(id: cookies.signed[:session_id])
self.current_user = session.user
end
end
end
end
@@ -0,0 +1,57 @@
class AdCompliancesController < ApplicationController
include AircraftScoped
before_action :require_owner!
before_action :set_compliance, only: %i[edit update destroy]
def new
ad = @aircraft.applicable_ads.find_by(id: params[:ad_id])
@compliance = AdCompliance.new(aircraft: @aircraft, airworthiness_directive: ad, date_complied: Date.current,
aircraft_hours_at_compliance: @aircraft.tach_time)
if ad&.recurring? && ad.recurring_hours.to_d > 0
@compliance.next_due_at_time = @aircraft.current_hours + ad.recurring_hours
end
end
def create
@compliance = AdCompliance.new(compliance_params.merge(aircraft: @aircraft))
if @compliance.save
log_event("ad", "Compliance recorded: #{@compliance.airworthiness_directive.name}")
redirect_to aircraft_airworthiness_directives_path(@aircraft), notice: "Compliance recorded."
else
render :new, status: :unprocessable_entity
end
end
def edit; end
def update
if @compliance.update(compliance_params)
log_event("ad", "Compliance updated: #{@compliance.airworthiness_directive.name}")
redirect_to aircraft_airworthiness_directives_path(@aircraft), notice: "Compliance updated."
else
render :edit, status: :unprocessable_entity
end
end
def destroy
@compliance.destroy!
log_event("ad", "Compliance deleted: #{@compliance.airworthiness_directive.name}")
redirect_to aircraft_airworthiness_directives_path(@aircraft), notice: "Compliance record deleted."
end
private
def set_compliance = @compliance = AdCompliance.for_aircraft(@aircraft).find(params[:id])
def compliance_params
p = params.require(:ad_compliance).permit(
:airworthiness_directive_id, :date_complied, :compliance_notes, :permanent, :next_due_at_time,
:aircraft_hours_at_compliance, :logbook_entry_id, :inspection_record_id, :component_id
)
p[:airworthiness_directive_id] = scoped_id(@aircraft.applicable_ads, p[:airworthiness_directive_id])
p[:logbook_entry_id] = scoped_id(@aircraft.logbook_entries, p[:logbook_entry_id])
p[:inspection_record_id] = scoped_id(InspectionRecord.for_aircraft(@aircraft), p[:inspection_record_id])
p[:component_id] = scoped_id(@aircraft.components, p[:component_id])
p
end
end
@@ -0,0 +1,44 @@
class Admin::ComponentTypesController < ApplicationController
before_action :require_admin!
before_action :set_type, only: %i[edit update destroy]
def index
@component_types = ComponentType.ordered
end
def new
@component_type = ComponentType.new
end
def create
@component_type = ComponentType.new(type_params)
if @component_type.save
redirect_to admin_component_types_path, notice: "Component type created."
else
render :new, status: :unprocessable_entity
end
end
def edit; end
def update
if @component_type.update(type_params)
redirect_to admin_component_types_path, notice: "Component type updated."
else
render :edit, status: :unprocessable_entity
end
end
def destroy
if @component_type.destroy
redirect_to admin_component_types_path, notice: "Component type deleted."
else
redirect_to admin_component_types_path, alert: @component_type.errors.full_messages.to_sentence
end
end
private
def set_type = @component_type = ComponentType.find(params[:id])
def type_params = params.require(:component_type).permit(:name, :consumable)
end
+50
View File
@@ -0,0 +1,50 @@
class Admin::UsersController < ApplicationController
before_action :require_admin!
before_action :set_user, only: %i[edit update destroy]
def index
@users = User.order(:email_address).includes(aircraft_roles: :aircraft)
end
def new
@user = User.new
end
def create
@user = User.new(user_params)
@user.admin = admin_flag
if @user.save
redirect_to admin_users_path, notice: "User #{@user.email_address} created."
else
render :new, status: :unprocessable_entity
end
end
def edit; end
def update
attrs = user_params
attrs = attrs.except(:password, :password_confirmation) if attrs[:password].blank?
if @user == current_user && !admin_flag
return redirect_to admin_users_path, alert: "You can't remove your own admin rights."
end
@user.admin = admin_flag
if @user.update(attrs)
redirect_to admin_users_path, notice: "User updated."
else
render :edit, status: :unprocessable_entity
end
end
def destroy
return redirect_to admin_users_path, alert: "You can't delete yourself." if @user == current_user
@user.destroy!
redirect_to admin_users_path, notice: "User deleted."
end
private
def set_user = @user = User.find(params[:id])
def user_params = params.require(:user).permit(:name, :email_address, :password, :password_confirmation)
def admin_flag = params.dig(:user, :admin) == "1"
end
+74
View File
@@ -0,0 +1,74 @@
class AircraftController < ApplicationController
include AircraftScoped
skip_before_action :set_aircraft, only: %i[index new create]
before_action :require_owner!, only: %i[edit update destroy]
def index
@aircraft_list = current_user.accessible_aircraft.ordered.with_attached_picture
end
def show
@airworthiness = @aircraft.airworthiness
@active_squawks = @aircraft.squawks.active.by_priority.includes(:component, :reported_by)
@recent_events = @aircraft.events.includes(:user).limit(8)
@notes = @aircraft.notes.recent_first.includes(:user).limit(5)
@oil = ConsumptionStats.new(@aircraft, "oil")
@fuel = ConsumptionStats.new(@aircraft, "fuel")
end
def new
@aircraft = Aircraft.new
end
def create
@aircraft = Aircraft.new(aircraft_params)
Aircraft.transaction do
@aircraft.save!
@aircraft.roles.create!(user: current_user, role: "owner")
@aircraft.log_event!("aircraft", "Aircraft created")
end
redirect_to @aircraft, notice: "#{@aircraft.tail_number} added."
rescue ActiveRecord::RecordInvalid
render :new, status: :unprocessable_entity
end
def edit; end
def update
if @aircraft.update(aircraft_params)
log_event("aircraft", "Aircraft details updated")
redirect_to @aircraft, notice: "Aircraft updated."
else
render :edit, status: :unprocessable_entity
end
end
def destroy
@aircraft.destroy!
redirect_to root_path, notice: "#{@aircraft.tail_number} deleted."
end
# Pilots and above: set absolute tach/hobbs readings.
def update_hours
delta = HoursService.new(@aircraft).update_hours!(
tach_time: params.require(:tach_time), hobbs_time: params[:hobbs_time]
)
redirect_to @aircraft, notice: "Hours updated (#{delta >= 0 ? '+' : ''}#{delta})."
rescue AircraftGroundedError => e
redirect_to @aircraft, alert: e.message
rescue ArgumentError
redirect_to @aircraft, alert: "Enter a valid tach reading."
end
private
def aircraft_param = params[:id]
def aircraft_params
params.require(:aircraft).permit(
:tail_number, :make, :model, :serial_number, :description, :purchased, :status,
:tach_time, :tach_time_offset, :hobbs_time, :hobbs_time_offset,
:airworthiness_enforcement, :picture
)
end
end
@@ -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
@@ -0,0 +1,74 @@
class AirworthinessDirectivesController < ApplicationController
include AircraftScoped
include Applicability
before_action :require_owner!, except: :index
before_action :set_ad, only: %i[edit update destroy]
def index
@rows = Compliance.ad_rows(@aircraft)
@history = AdCompliance.for_aircraft(@aircraft).recent_first.includes(:airworthiness_directive, :component)
@attachable = AirworthinessDirective.where.not(id: @aircraft.applicable_ads.select(:id)).ordered if owner?
end
def new
@ad = AirworthinessDirective.new
@applies_to_airframe = true
end
def create
@ad = AirworthinessDirective.new(ad_params)
AirworthinessDirective.transaction do
@ad.save!
apply_applicability(@ad, to_airframe: applies_to_airframe?, component_ids: applicable_component_ids)
end
log_event("ad", "#{@ad.bulletin_label} added: #{@ad.name}")
redirect_to aircraft_airworthiness_directives_path(@aircraft), notice: "#{@ad.bulletin_label} added."
rescue ActiveRecord::RecordInvalid
@applies_to_airframe = applies_to_airframe?
render :new, status: :unprocessable_entity
end
# Link an AD that already exists (e.g. tracked on another aircraft).
def attach
ad = AirworthinessDirective.find(params[:airworthiness_directive_id])
ad.aircraft << @aircraft unless ad.aircraft.include?(@aircraft)
log_event("ad", "#{ad.bulletin_label} linked: #{ad.name}")
redirect_to aircraft_airworthiness_directives_path(@aircraft), notice: "#{ad.name} linked."
end
def edit
@applies_to_airframe = @ad.aircraft.include?(@aircraft)
end
def update
AirworthinessDirective.transaction do
@ad.update!(ad_params)
apply_applicability(@ad, to_airframe: applies_to_airframe?, component_ids: applicable_component_ids)
end
log_event("ad", "#{@ad.bulletin_label} updated: #{@ad.name}")
redirect_to aircraft_airworthiness_directives_path(@aircraft), notice: "#{@ad.bulletin_label} updated."
rescue ActiveRecord::RecordInvalid
@applies_to_airframe = applies_to_airframe?
render :edit, status: :unprocessable_entity
end
# Removes the AD from this aircraft (the shared AD record survives if other aircraft use it).
def destroy
detach_from_aircraft(@ad)
log_event("ad", "#{@ad.bulletin_label} removed: #{@ad.name}")
redirect_to aircraft_airworthiness_directives_path(@aircraft), notice: "#{@ad.name} removed from #{@aircraft.tail_number}."
end
private
def set_ad = @ad = @aircraft.applicable_ads.find(params[:id])
def ad_params
p = params.require(:airworthiness_directive).permit(
:name, :short_description, :required_action, :compliance_type, :trigger_condition, :recurring,
:recurring_hours, :recurring_months, :recurring_days, :bulletin_type, :mandatory, :document_id
)
p[:document_id] = scoped_id(@aircraft.documents, p[:document_id])
p
end
end
+28
View File
@@ -0,0 +1,28 @@
class ApplicationController < ActionController::Base
default_form_builder AppFormBuilder
include Authentication
allow_browser versions: :modern
prepend_before_action :redirect_to_setup
helper_method :current_user
rescue_from ActiveRecord::RecordNotFound do
respond_to do |format|
format.html { render "errors/not_found", status: :not_found, layout: (authenticated? ? "application" : "public") }
format.any { head :not_found }
end
end
private
def current_user = Current.user
# First run: no users yet → create the initial admin.
def redirect_to_setup
redirect_to new_setup_path if !User.exists? && !is_a?(SetupController)
end
def require_admin!
redirect_to root_path, alert: "Admins only." unless current_user&.admin?
end
end
+90
View File
@@ -0,0 +1,90 @@
class ComponentsController < ApplicationController
include AircraftScoped
before_action :require_owner!, except: %i[index show]
before_action :set_component, only: %i[show edit update destroy reset_service]
def index
all = @aircraft.components.includes(:component_type, :parent_component).order(:install_location)
@show_disposed = params[:disposed].present?
all = all.where.not(status: "DISPOSED") unless @show_disposed
# Depth-first tree order: parents followed by their children.
by_parent = all.group_by(&:parent_component_id)
@rows = []
walk = ->(parent_id, depth) do
(by_parent[parent_id] || []).sort_by { [ _1.component_type.name, _1.install_location.to_s ] }.each do |c|
@rows << [ c, depth ]
walk.(c.id, depth + 1)
end
end
walk.(nil, 0)
orphans = all.to_a - @rows.map(&:first) # children whose parent is filtered out
orphans.each { @rows << [ _1, 0 ] }
end
def show
@squawks = @component.squawks.by_priority
end
def new
@component = @aircraft.components.new(date_in_service: Date.current, status: "IN-USE",
parent_component_id: params[:parent_id])
end
def create
@component = @aircraft.components.new(component_params)
if @component.save
log_event("component", "Component added: #{@component}")
redirect_to aircraft_components_path(@aircraft), notice: "Component added."
else
render :new, status: :unprocessable_entity
end
end
def edit; end
def update
if @component.update(component_params)
log_event("component", "Component updated: #{@component}")
redirect_to aircraft_components_path(@aircraft), notice: "Component updated."
else
render :edit, status: :unprocessable_entity
end
end
def destroy
@component.destroy!
log_event("component", "Component deleted: #{@component}")
redirect_to aircraft_components_path(@aircraft), notice: "Component deleted."
end
# Always zeroes hours since overhaul; reset_in_service=1 also zeroes the
# in-service clock (use when the part was physically replaced).
def reset_service
replaced = params[:reset_in_service] == "1"
@component.reset_service!(reset_in_service: replaced)
log_event("component", "#{replaced ? 'Replaced' : 'Serviced'}: #{@component}")
redirect_to aircraft_components_path(@aircraft), notice: "#{@component} #{replaced ? 'replaced' : 'serviced'}."
end
private
def set_component
@component = @aircraft.components.find(params[:id])
end
def component_params
params.require(:component).permit(
:component_type_id, :parent_component_id, :manufacturer, :model, :serial_number,
:install_location, :notes, :status, :date_in_service, :hours_in_service,
:hours_since_overhaul, :overhaul_date, :tbo_hours, :tbo_days, :inspection_hours,
:inspection_days, :replacement_hours, :replacement_days, :tbo_critical, :on_condition,
:inspection_critical, :replacement_critical
).tap do |p|
# Owners can create a component type inline instead of asking an admin.
if (name = params[:new_component_type].to_s.strip).present?
type = ComponentType.where("lower(name) = ?", name.downcase).first || ComponentType.create!(name: name)
p[:component_type_id] = type.id
end
end
end
end
View File
Whitespace-only changes.
@@ -0,0 +1,46 @@
# Scopes a controller to one aircraft the current user can access and exposes
# role helpers. Unknown and inaccessible aircraft both 404 (enumeration-safe).
#
# Access matrix (mirrors the original):
# admin – everything
# owner – everything on their aircraft
# pilot – view all; update hours; create squawks, notes, oil/fuel, flight logs
module AircraftScoped
extend ActiveSupport::Concern
included do
before_action :set_aircraft
helper_method :current_role, :owner?, :can_write?
end
private
def aircraft_param = params[:aircraft_id]
def set_aircraft
@aircraft = current_user.accessible_aircraft.find(aircraft_param)
end
def current_role
@current_role ||= current_user.role_for(@aircraft)
end
# Owner-level write access (admins included).
def owner? = current_role.in?(%w[admin owner])
alias_method :can_write?, :owner?
def require_owner!
return if owner?
redirect_back fallback_location: aircraft_path(@aircraft),
alert: "Only owners can do that."
end
# Returns id only if it belongs to the given (aircraft-scoped) relation; else nil.
def scoped_id(scope, id)
id.present? && scope.where(id: id).exists? ? id : nil
end
def log_event(category, name, notes: nil)
@aircraft.log_event!(category, name, notes: notes)
end
end
+38
View File
@@ -0,0 +1,38 @@
# ADs and inspection types are shared reference data that can apply to many
# aircraft. From an aircraft's page we only ever touch *this* aircraft's links:
# the airframe itself and/or some of its components.
module Applicability
extend ActiveSupport::Concern
private
def apply_applicability(record, to_airframe:, component_ids:)
mine = @aircraft.components.where(id: Array(component_ids).compact_blank).to_a
others = record.components.where.not(aircraft_id: @aircraft.id).to_a
record.components = others + mine
if to_airframe
record.aircraft << @aircraft unless record.aircraft.include?(@aircraft)
else
record.aircraft.delete(@aircraft)
end
# Never let a record silently drop off this aircraft entirely.
record.aircraft << @aircraft if mine.empty? && !to_airframe
end
def detach_from_aircraft(record)
record.aircraft.delete(@aircraft)
record.components.delete(*record.components.where(aircraft_id: @aircraft.id))
record.destroy if record.aircraft.empty? && record.components.empty? && orphan_deletable?(record)
end
def orphan_deletable?(record)
case record
when AirworthinessDirective then record.ad_compliances.none?
when InspectionType then record.inspection_records.none?
else false
end
end
def applies_to_airframe? = params[:applies_to_airframe] == "1"
def applicable_component_ids = params[:component_ids]
end
@@ -0,0 +1,52 @@
module Authentication
extend ActiveSupport::Concern
included do
before_action :require_authentication
helper_method :authenticated?
end
class_methods do
def allow_unauthenticated_access(**options)
skip_before_action :require_authentication, **options
end
end
private
def authenticated?
resume_session
end
def require_authentication
resume_session || request_authentication
end
def resume_session
Current.session ||= find_session_by_cookie
end
def find_session_by_cookie
Session.find_by(id: cookies.signed[:session_id]) if cookies.signed[:session_id]
end
def request_authentication
session[:return_to_after_authenticating] = request.url
redirect_to new_session_path
end
def after_authentication_url
session.delete(:return_to_after_authenticating) || root_url
end
def start_new_session_for(user)
user.sessions.create!(user_agent: request.user_agent, ip_address: request.remote_ip).tap do |session|
Current.session = session
cookies.signed.permanent[:session_id] = { value: session.id, httponly: true, same_site: :lax }
end
end
def terminate_session
Current.session.destroy
cookies.delete(:session_id)
end
end
@@ -0,0 +1,53 @@
class ConsumableRecordsController < ApplicationController
include AircraftScoped
before_action :require_owner!, only: %i[edit update destroy]
before_action :set_record, only: %i[edit update destroy]
def index
@oil = ConsumptionStats.new(@aircraft, "oil")
@fuel = ConsumptionStats.new(@aircraft, "fuel")
@records = @aircraft.consumable_records.recent_first.limit(200)
end
def new
type = params[:type].in?(ConsumableRecord::TYPES.keys) ? params[:type] : "oil"
@record = @aircraft.consumable_records.new(record_type: type, date: Date.current,
flight_hours: @aircraft.tach_time)
end
def create
@record = @aircraft.consumable_records.new(record_params)
if @record.save
log_event(@record.record_type, "#{@record.record_type.capitalize} added: #{@record.quantity_added} #{@record.unit}")
redirect_to aircraft_consumable_records_path(@aircraft), notice: "Record added."
else
render :new, status: :unprocessable_entity
end
end
def edit; end
def update
if @record.update(record_params)
log_event(@record.record_type, "#{@record.record_type.capitalize} record updated")
redirect_to aircraft_consumable_records_path(@aircraft), notice: "Record updated."
else
render :edit, status: :unprocessable_entity
end
end
def destroy
@record.destroy!
log_event(@record.record_type, "#{@record.record_type.capitalize} record deleted")
redirect_to aircraft_consumable_records_path(@aircraft), notice: "Record deleted."
end
private
def set_record = @record = @aircraft.consumable_records.find(params[:id])
def record_params
params.require(:consumable_record).permit(:record_type, :date, :quantity_added, :level_after,
:consumable_type, :flight_hours, :notes, :excluded_from_averages)
end
end
@@ -0,0 +1,41 @@
class DocumentCollectionsController < ApplicationController
include AircraftScoped
before_action :require_owner!
before_action :set_collection, only: %i[edit update destroy]
def new
@collection = @aircraft.document_collections.new
end
def create
@collection = @aircraft.document_collections.new(collection_params)
if @collection.save
log_event("document", "Collection created: #{@collection.name}")
redirect_to aircraft_documents_path(@aircraft), notice: "Collection created."
else
render :new, status: :unprocessable_entity
end
end
def edit; end
def update
if @collection.update(collection_params)
log_event("document", "Collection updated: #{@collection.name}")
redirect_to aircraft_documents_path(@aircraft), notice: "Collection updated."
else
render :edit, status: :unprocessable_entity
end
end
def destroy
@collection.destroy!
log_event("document", "Collection deleted: #{@collection.name}")
redirect_to aircraft_documents_path(@aircraft), notice: "Collection and its documents deleted."
end
private
def set_collection = @collection = @aircraft.document_collections.find(params[:id])
def collection_params = params.require(:document_collection).permit(:name, :description, :visibility, :starred)
end
+62
View File
@@ -0,0 +1,62 @@
class DocumentsController < ApplicationController
include AircraftScoped
before_action :require_owner!, except: %i[index show]
before_action :set_document, only: %i[show edit update destroy]
def index
@collections = @aircraft.document_collections.ordered.includes(documents: { pages_attachments: :blob })
@uncollected = @aircraft.documents.where(document_collection_id: nil).ordered.includes(pages_attachments: :blob)
end
def show
@page = (params[:page] || 1).to_i.clamp(1, [ @document.pages.size, 1 ].max)
end
def new
@document = @aircraft.documents.new(document_collection_id: params[:collection_id])
end
def create
@document = @aircraft.documents.new(document_params)
if @document.save
log_event("document", "Document added: #{@document.name}")
redirect_to aircraft_document_path(@aircraft, @document), notice: "Document added."
else
render :new, status: :unprocessable_entity
end
end
def edit; end
def update
attrs = document_params
new_pages = attrs.delete(:pages)
@document.assign_attributes(attrs)
@document.pages.attach(new_pages) if new_pages.present?
Array(params[:remove_page_ids]).each { |id| @document.pages.find_by(id: id)&.purge_later }
if @document.save
log_event("document", "Document updated: #{@document.name}")
redirect_to aircraft_document_path(@aircraft, @document), notice: "Document updated."
else
render :edit, status: :unprocessable_entity
end
end
def destroy
@document.destroy!
log_event("document", "Document deleted: #{@document.name}")
redirect_to aircraft_documents_path(@aircraft), notice: "Document deleted."
end
private
def set_document = @document = @aircraft.documents.find(params[:id])
def document_params
p = params.require(:document).permit(:name, :description, :doc_type, :visibility, :document_collection_id, pages: [])
p[:pages]&.compact_blank!
p.delete(:pages) if p[:pages].blank?
p[:document_collection_id] = scoped_id(@aircraft.document_collections, p[:document_collection_id])
p
end
end
+10
View File
@@ -0,0 +1,10 @@
class EventsController < ApplicationController
include AircraftScoped
def index
@category = params[:category].presence_in(AircraftEvent::CATEGORIES.keys)
scope = @aircraft.events.includes(:user)
scope = scope.where(category: @category) if @category
@events = scope.limit(200)
end
end
+47
View File
@@ -0,0 +1,47 @@
class FlightLogsController < ApplicationController
include AircraftScoped
before_action :require_owner!, only: :destroy
def index
@flight_logs = @aircraft.flight_logs.recent_first.includes(:user)
end
def show
@flight_log = @aircraft.flight_logs.find(params[:id])
end
def new
@flight_log = @aircraft.flight_logs.new(date: Date.current, tach_out: @aircraft.tach_time,
hobbs_out: @aircraft.hobbs_time)
end
def create
@flight_log = @aircraft.flight_logs.new(flight_log_params)
if @flight_log.valid?
HoursService.new(@aircraft).log_flight!(@flight_log)
redirect_to aircraft_flight_logs_path(@aircraft), notice: "Flight logged (#{@flight_log.tach_time} hrs)."
else
render :new, status: :unprocessable_entity
end
rescue AircraftGroundedError => e
flash.now[:alert] = e.message
render :new, status: :conflict
end
# Deleting a flight does not roll back hours; correct those with an hours update.
def destroy
@aircraft.flight_logs.find(params[:id]).destroy!
log_event("flight", "Flight log deleted")
redirect_to aircraft_flight_logs_path(@aircraft), notice: "Flight log deleted. Aircraft hours were not changed."
end
private
def flight_log_params
params.require(:flight_log).permit(
:date, :tach_time, :tach_out, :tach_in, :hobbs_time, :hobbs_out, :hobbs_in,
:departure_location, :destination_location, :route, :oil_added, :oil_added_type,
:oil_level_after, :fuel_added, :fuel_added_type, :fuel_level_after, :notes, :track_log
)
end
end
@@ -0,0 +1,51 @@
class InspectionRecordsController < ApplicationController
include AircraftScoped
before_action :require_owner!
before_action :set_record, only: %i[edit update destroy]
def new
@record = InspectionRecord.new(aircraft: @aircraft, date: Date.current,
aircraft_hours: @aircraft.tach_time,
inspection_type_id: params[:inspection_type_id])
end
def create
@record = InspectionRecord.new(record_params.merge(aircraft: @aircraft))
if @record.save
log_event("inspection", "Inspection completed: #{@record.inspection_type.name}")
redirect_to aircraft_inspections_path(@aircraft), notice: "Inspection recorded."
else
render :new, status: :unprocessable_entity
end
end
def edit; end
def update
if @record.update(record_params)
log_event("inspection", "Inspection record updated: #{@record.inspection_type.name}")
redirect_to aircraft_inspections_path(@aircraft), notice: "Inspection record updated."
else
render :edit, status: :unprocessable_entity
end
end
def destroy
@record.destroy!
log_event("inspection", "Inspection record deleted: #{@record.inspection_type.name}")
redirect_to aircraft_inspections_path(@aircraft), notice: "Inspection record deleted."
end
private
def set_record = @record = InspectionRecord.for_aircraft(@aircraft).find(params[:id])
def record_params
p = params.require(:inspection_record).permit(:inspection_type_id, :date, :aircraft_hours, :notes,
:logbook_entry_id, :component_id)
p[:inspection_type_id] = scoped_id(@aircraft.applicable_inspection_types, p[:inspection_type_id])
p[:logbook_entry_id] = scoped_id(@aircraft.logbook_entries, p[:logbook_entry_id])
p[:component_id] = scoped_id(@aircraft.components, p[:component_id])
p
end
end
@@ -0,0 +1,56 @@
class InspectionTypesController < ApplicationController
include AircraftScoped
include Applicability
before_action :require_owner!
before_action :set_type, only: %i[edit update destroy]
def new
@inspection_type = InspectionType.new(required: true, recurring: true)
@applies_to_airframe = true
end
def create
@inspection_type = InspectionType.new(type_params)
InspectionType.transaction do
@inspection_type.save!
apply_applicability(@inspection_type, to_airframe: applies_to_airframe?, component_ids: applicable_component_ids)
end
log_event("inspection", "Inspection type added: #{@inspection_type.name}")
redirect_to aircraft_inspections_path(@aircraft), notice: "Inspection type added."
rescue ActiveRecord::RecordInvalid
@applies_to_airframe = applies_to_airframe?
render :new, status: :unprocessable_entity
end
def edit
@applies_to_airframe = @inspection_type.aircraft.include?(@aircraft)
end
def update
InspectionType.transaction do
@inspection_type.update!(type_params)
apply_applicability(@inspection_type, to_airframe: applies_to_airframe?, component_ids: applicable_component_ids)
end
log_event("inspection", "Inspection type updated: #{@inspection_type.name}")
redirect_to aircraft_inspections_path(@aircraft), notice: "Inspection type updated."
rescue ActiveRecord::RecordInvalid
@applies_to_airframe = applies_to_airframe?
render :edit, status: :unprocessable_entity
end
def destroy
detach_from_aircraft(@inspection_type)
log_event("inspection", "Inspection type removed: #{@inspection_type.name}")
redirect_to aircraft_inspections_path(@aircraft), notice: "Inspection removed from #{@aircraft.tail_number}."
end
private
def set_type
@inspection_type = @aircraft.applicable_inspection_types.find(params[:id])
end
def type_params
params.require(:inspection_type).permit(:name, :recurring, :required, :recurring_hours, :recurring_days, :recurring_months)
end
end
@@ -0,0 +1,8 @@
class InspectionsController < ApplicationController
include AircraftScoped
def index
@rows = Compliance.inspection_rows(@aircraft)
@history = InspectionRecord.for_aircraft(@aircraft).recent_first.includes(:inspection_type, :component, :logbook_entry)
end
end
@@ -0,0 +1,57 @@
class LogbookEntriesController < ApplicationController
include AircraftScoped
before_action :require_owner!, except: %i[index show]
before_action :set_entry, only: %i[show edit update destroy]
def index
@query = params[:q]
@log_type = params[:log_type].presence
scope = @aircraft.logbook_entries.search(@query).recent_first.includes(:document)
scope = scope.where(log_type: @log_type) if @log_type
@entries = scope.limit(500)
end
def show; end
def new
@entry = @aircraft.logbook_entries.new(date: Date.current, aircraft_hours_at_entry: @aircraft.tach_time)
end
def create
@entry = @aircraft.logbook_entries.new(entry_params)
if @entry.save
log_event("logbook", "Logbook entry added (#{@entry.date})")
redirect_to aircraft_logbook_entries_path(@aircraft), notice: "Logbook entry added."
else
render :new, status: :unprocessable_entity
end
end
def edit; end
def update
if @entry.update(entry_params)
log_event("logbook", "Logbook entry updated (#{@entry.date})")
redirect_to aircraft_logbook_entry_path(@aircraft, @entry), notice: "Logbook entry updated."
else
render :edit, status: :unprocessable_entity
end
end
def destroy
@entry.destroy!
log_event("logbook", "Logbook entry deleted (#{@entry.date})")
redirect_to aircraft_logbook_entries_path(@aircraft), notice: "Logbook entry deleted."
end
private
def set_entry = @entry = @aircraft.logbook_entries.find(params[:id])
def entry_params
p = params.require(:logbook_entry).permit(:log_type, :entry_type, :date, :text, :signoff_person,
:signoff_location, :aircraft_hours_at_entry, :document_id, :page_number)
p[:document_id] = scoped_id(@aircraft.documents, p[:document_id])
p
end
end
@@ -0,0 +1,59 @@
class MajorRecordsController < ApplicationController
include AircraftScoped
before_action :require_owner!, except: %i[index show]
before_action :set_record, only: %i[show edit update destroy]
def index
@records = @aircraft.major_records.recent_first.includes(:component)
end
def show; end
def new
@record = @aircraft.major_records.new(record_type: params[:type] || "repair", date_performed: Date.current,
aircraft_hours: @aircraft.tach_time)
end
def create
@record = @aircraft.major_records.new(record_params)
if @record.save
log_event("major_record", "#{@record.type_label} added: #{@record.title}")
redirect_to aircraft_major_records_path(@aircraft), notice: "Record added."
else
render :new, status: :unprocessable_entity
end
end
def edit; end
def update
if @record.update(record_params)
log_event("major_record", "#{@record.type_label} updated: #{@record.title}")
redirect_to aircraft_major_record_path(@aircraft, @record), notice: "Record updated."
else
render :edit, status: :unprocessable_entity
end
end
def destroy
@record.destroy!
log_event("major_record", "#{@record.type_label} deleted: #{@record.title}")
redirect_to aircraft_major_records_path(@aircraft), notice: "Record deleted."
end
private
def set_record = @record = @aircraft.major_records.find(params[:id])
def record_params
p = params.require(:major_record).permit(
:record_type, :title, :description, :date_performed, :performed_by, :component_id,
:form_337_document_id, :stc_number, :stc_holder, :stc_document_id, :logbook_entry_id,
:aircraft_hours, :has_ica, :ica_notes, :notes
)
p[:component_id] = scoped_id(@aircraft.components, p[:component_id])
p[:logbook_entry_id] = scoped_id(@aircraft.logbook_entries, p[:logbook_entry_id])
%i[form_337_document_id stc_document_id].each { |k| p[k] = scoped_id(@aircraft.documents, p[k]) }
p
end
end
+45
View File
@@ -0,0 +1,45 @@
class NotesController < ApplicationController
include AircraftScoped
before_action :require_owner!, only: %i[edit update destroy]
before_action :set_note, only: %i[edit update destroy]
def index
@notes = @aircraft.notes.recent_first.includes(:user)
end
def new
@note = @aircraft.notes.new
end
def create
@note = @aircraft.notes.new(note_params.merge(user: current_user))
if @note.save
log_event("note", "Note added")
redirect_to aircraft_notes_path(@aircraft), notice: "Note added."
else
render :new, status: :unprocessable_entity
end
end
def edit; end
def update
if @note.update(note_params.merge(edited_at: Time.current))
log_event("note", "Note updated")
redirect_to aircraft_notes_path(@aircraft), notice: "Note updated."
else
render :edit, status: :unprocessable_entity
end
end
def destroy
@note.destroy!
log_event("note", "Note deleted")
redirect_to aircraft_notes_path(@aircraft), notice: "Note deleted."
end
private
def set_note = @note = @aircraft.notes.find(params[:id])
def note_params = params.require(:aircraft_note).permit(:text, :public)
end
+33
View File
@@ -0,0 +1,33 @@
class PasswordsController < ApplicationController
allow_unauthenticated_access
before_action :set_user_by_token, only: %i[ edit update ]
def new
end
def create
if user = User.find_by(email_address: params[:email_address])
PasswordsMailer.reset(user).deliver_later
end
redirect_to new_session_path, notice: "Password reset instructions sent (if user with that email address exists)."
end
def edit
end
def update
if @user.update(params.permit(:password, :password_confirmation))
redirect_to new_session_path, notice: "Password has been reset."
else
redirect_to edit_password_path(params[:token]), alert: "Passwords did not match."
end
end
private
def set_user_by_token
@user = User.find_by_password_reset_token!(params[:token])
rescue ActiveSupport::MessageVerifier::InvalidSignature
redirect_to new_password_path, alert: "Password reset link is invalid or has expired."
end
end
+16
View File
@@ -0,0 +1,16 @@
class ProfilesController < ApplicationController
def edit
@user = current_user
end
def update
@user = current_user
attrs = params.require(:user).permit(:name, :email_address, :password, :password_confirmation)
attrs = attrs.except(:password, :password_confirmation) if attrs[:password].blank?
if @user.update(attrs)
redirect_to root_path, notice: "Profile updated."
else
render :edit, status: :unprocessable_entity
end
end
end
+21
View File
@@ -0,0 +1,21 @@
class SessionsController < ApplicationController
allow_unauthenticated_access only: %i[ new create ]
rate_limit to: 10, within: 3.minutes, only: :create, with: -> { redirect_to new_session_url, alert: "Try again later." }
def new
end
def create
if user = User.authenticate_by(params.permit(:email_address, :password))
start_new_session_for user
redirect_to after_authentication_url
else
redirect_to new_session_path, alert: "Try another email address or password."
end
end
def destroy
terminate_session
redirect_to new_session_path
end
end
+20
View File
@@ -0,0 +1,20 @@
class SetupController < ApplicationController
allow_unauthenticated_access
before_action { redirect_to root_path if User.exists? }
layout "public"
def new
@user = User.new
end
def create
@user = User.new(params.require(:user).permit(:name, :email_address, :password, :password_confirmation))
@user.admin = true
if @user.save
start_new_session_for @user
redirect_to root_path, notice: "Welcome! You're the administrator. Add your first aircraft."
else
render :new, status: :unprocessable_entity
end
end
end
@@ -0,0 +1,22 @@
class ShareTokensController < ApplicationController
include AircraftScoped
before_action :require_owner!
def create
token = @aircraft.share_tokens.new(params.require(:share_token).permit(:label, :privilege, :expires_at))
token.created_by = current_user
if token.save
log_event("aircraft", "Share link created (#{token.privilege})", notes: token.label)
redirect_to aircraft_aircraft_roles_path(@aircraft), notice: "Share link created."
else
redirect_to aircraft_aircraft_roles_path(@aircraft), alert: token.errors.full_messages.to_sentence
end
end
def destroy
token = @aircraft.share_tokens.find(params[:id])
token.destroy!
log_event("aircraft", "Share link revoked", notes: token.label)
redirect_to aircraft_aircraft_roles_path(@aircraft), notice: "Share link revoked."
end
end
+30
View File
@@ -0,0 +1,30 @@
# Read-only public view of an aircraft via a share link — no login required.
# 'status' links see current state; 'maintenance' links also see full history.
class SharedController < ApplicationController
allow_unauthenticated_access
skip_before_action :redirect_to_setup
layout "public"
def show
@share = ShareToken.find_active(params[:token]) or raise ActiveRecord::RecordNotFound
@aircraft = @share.aircraft
@airworthiness = @aircraft.airworthiness
@components = @aircraft.components.where.not(status: "DISPOSED").includes(:component_type).order(:install_location)
@active_squawks = @aircraft.squawks.active.by_priority
@notes = @aircraft.notes.visible_publicly.recent_first
@ad_rows = Compliance.ad_rows(@aircraft)
@inspection_rows = Compliance.inspection_rows(@aircraft)
@oil = ConsumptionStats.new(@aircraft, "oil")
@fuel = ConsumptionStats.new(@aircraft, "fuel")
@documents = @aircraft.documents.includes(:document_collection, pages_attachments: :blob)
.select { |d| d.visible_to_share?(@share) }
if @share.maintenance?
@logbook = @aircraft.logbook_entries.recent_first
@resolved_squawks = @aircraft.squawks.resolved.order(resolved_at: :desc)
@major_records = @aircraft.major_records.recent_first
@inspection_history = InspectionRecord.for_aircraft(@aircraft).recent_first.includes(:inspection_type)
@ad_history = AdCompliance.for_aircraft(@aircraft).recent_first.includes(:airworthiness_directive)
end
end
end
+62
View File
@@ -0,0 +1,62 @@
class SquawksController < ApplicationController
include AircraftScoped
# Pilots may create squawks; editing/resolving needs an owner.
before_action :require_owner!, except: %i[index new create]
before_action :set_squawk, only: %i[edit update destroy resolve reopen]
def index
@active = @aircraft.squawks.active.by_priority.includes(:component, :reported_by)
@resolved = @aircraft.squawks.resolved.order(resolved_at: :desc).includes(:component).limit(100)
end
def new
@squawk = @aircraft.squawks.new(priority: 1)
end
def create
@squawk = @aircraft.squawks.new(squawk_params.merge(reported_by: current_user))
if @squawk.save
log_event("squawk", "Squawk reported: #{@squawk.priority_label}", notes: @squawk.issue_reported.truncate(200))
redirect_to aircraft_squawks_path(@aircraft), notice: "Squawk reported."
else
render :new, status: :unprocessable_entity
end
end
def edit; end
def update
if @squawk.update(squawk_params)
log_event("squawk", "Squawk updated")
redirect_to aircraft_squawks_path(@aircraft), notice: "Squawk updated."
else
render :edit, status: :unprocessable_entity
end
end
def resolve
@squawk.resolve!(notes: params[:resolution_notes])
log_event("squawk", "Squawk resolved", notes: @squawk.issue_reported.truncate(200))
redirect_back fallback_location: aircraft_squawks_path(@aircraft), notice: "Squawk resolved."
end
def reopen
@squawk.update!(resolved: false, resolved_at: nil)
log_event("squawk", "Squawk reopened")
redirect_to aircraft_squawks_path(@aircraft), notice: "Squawk reopened."
end
def destroy
@squawk.destroy!
log_event("squawk", "Squawk deleted")
redirect_to aircraft_squawks_path(@aircraft), notice: "Squawk deleted."
end
private
def set_squawk = @squawk = @aircraft.squawks.find(params[:id])
def squawk_params
params.require(:squawk).permit(:priority, :issue_reported, :component_id, :notes, :attachment)
end
end
+54
View File
@@ -0,0 +1,54 @@
# Wraps fields with a label, hint, and inline errors using the app's Tailwind classes.
# <%= f.field :tail_number %>
# <%= f.field :tach_time, as: :number, step: 0.1 %>
# <%= f.field :status, as: :select, collection: Aircraft::STATUSES.invert %>
# <%= f.field :public, as: :checkbox, label: "Show on share links" %>
class AppFormBuilder < ActionView::Helpers::FormBuilder
def field(method, as: :text, label: nil, hint: nil, collection: nil, include_blank: false, wrapper: {}, **opts)
label_text = label || method.to_s.humanize
errors = object.respond_to?(:errors) ? object.errors[method] : []
if as == :checkbox
return @template.content_tag(:div, class: [ "flex items-start gap-2", wrapper[:class] ]) do
check_box(method, { class: "mt-0.5 h-4 w-4 rounded border-slate-300 text-sky-700" }.merge(opts)) +
@template.content_tag(:div) do
label(method, label_text, class: "text-sm text-slate-700") +
(hint ? @template.content_tag(:p, hint, class: "hint") : "".html_safe)
end
end
end
input_opts = { class: "input" }.merge(opts)
input =
case as
when :textarea then text_area(method, { rows: 4 }.merge(input_opts))
when :number then number_field(method, input_opts)
when :date then date_field(method, input_opts)
when :datetime then datetime_field(method, input_opts)
when :email then email_field(method, input_opts)
when :password then password_field(method, input_opts)
when :file then file_field(method, opts.merge(class: "block text-sm text-slate-600 file:mr-3 file:rounded-md file:border-0 file:bg-slate-100 file:px-3 file:py-1.5 file:text-sm file:font-medium hover:file:bg-slate-200"))
when :select then select(method, collection, { include_blank: include_blank }, input_opts)
else text_field(method, input_opts)
end
@template.content_tag(:div, class: wrapper[:class]) do
label(method, label_text, class: "label") + input +
(hint ? @template.content_tag(:p, hint, class: "hint") : "".html_safe) +
errors.map { |e| @template.content_tag(:p, "#{label_text} #{e}", class: "field-error") }.join.html_safe
end
end
def errors_summary
return "".html_safe unless object&.errors&.any?
@template.content_tag(:div, class: "rounded-md bg-red-50 p-3 text-sm text-red-700 ring-1 ring-red-200") do
@template.content_tag(:ul, class: "list-disc pl-5") do
object.errors.full_messages.map { |m| @template.content_tag(:li, m) }.join.html_safe
end
end
end
def submit(value = nil, **opts)
super(value, { class: "btn-primary" }.merge(opts))
end
end
+33
View File
@@ -0,0 +1,33 @@
module AircraftHelper
# Tabs on the aircraft pages: [label, path, controller names that highlight it, owner_only]
def aircraft_tabs(aircraft)
[
[ "Overview", aircraft_path(aircraft), %w[aircraft] ],
[ "Components", aircraft_components_path(aircraft), %w[components] ],
[ "Squawks", aircraft_squawks_path(aircraft), %w[squawks] ],
[ "Flights", aircraft_flight_logs_path(aircraft), %w[flight_logs] ],
[ "Oil & Fuel", aircraft_consumable_records_path(aircraft), %w[consumable_records] ],
[ "Logbook", aircraft_logbook_entries_path(aircraft), %w[logbook_entries] ],
[ "Inspections", aircraft_inspections_path(aircraft), %w[inspections inspection_types inspection_records] ],
[ "ADs", aircraft_airworthiness_directives_path(aircraft), %w[airworthiness_directives ad_compliances] ],
[ "Documents", aircraft_documents_path(aircraft), %w[documents document_collections] ],
[ "Major Records", aircraft_major_records_path(aircraft), %w[major_records] ],
[ "Notes", aircraft_notes_path(aircraft), %w[notes] ],
[ "Activity", aircraft_events_path(aircraft), %w[events] ],
([ "Access & Sharing", aircraft_aircraft_roles_path(aircraft), %w[aircraft_roles share_tokens] ] if owner?)
].compact
end
def component_options(aircraft, include_blank: true)
opts = aircraft.components.where.not(status: "DISPOSED").includes(:component_type).map { [ _1.to_s, _1.id ] }
include_blank ? [ [ "— None —", nil ] ] + opts : opts
end
def document_options(aircraft)
[ [ "— None —", nil ] ] + aircraft.documents.ordered.map { [ _1.name, _1.id ] }
end
def logbook_options(aircraft)
[ [ "— None —", nil ] ] + aircraft.logbook_entries.recent_first.limit(300).map { [ "#{_1.date} – #{_1.text.truncate(60)}", _1.id ] }
end
end
+64
View File
@@ -0,0 +1,64 @@
module ApplicationHelper
def hours(value)
return "—" if value.nil?
number_with_precision(value, precision: 1, delimiter: ",")
end
def fmt_date(value)
value ? l(value.to_date, format: :long) : "—"
end
def airworthiness_badge(status, large: false)
color = { "RED" => "red", "ORANGE" => "orange", "GREEN" => "green" }[status.status]
tag.span(status.label, class: [ "badge-#{color}", ("text-sm px-3 py-1" if large) ])
end
def airworthiness_dot(status)
color = { "RED" => "bg-red-500", "ORANGE" => "bg-amber-400", "GREEN" => "bg-emerald-500" }[status.status]
tag.span(class: "inline-block h-3 w-3 rounded-full #{color}", title: status.label)
end
COMPLIANCE_BADGES = {
"compliant" => [ "green", "Compliant" ], "due_soon" => [ "orange", "Due Soon" ],
"overdue" => [ "red", "Overdue" ], "no_compliance" => [ "red", "No Record" ],
"never_completed" => [ "red", "Never Completed" ], "conditional" => [ "gray", "Conditional" ]
}.freeze
def compliance_badge(status)
color, text = COMPLIANCE_BADGES.fetch(status, [ "gray", status.to_s.humanize ])
tag.span(text, class: "badge-#{color}")
end
def life_badge(status)
return "" unless status
color, text = { overdue: [ "red", "Overdue" ], due_soon: [ "orange", "Due Soon" ], ok: [ "green", "OK" ] }[status]
tag.span(text, class: "badge-#{color}")
end
def squawk_priority_badge(squawk)
tag.span(squawk.priority_label, class: "badge-#{squawk.priority_color}")
end
def aircraft_status_badge(aircraft)
color = { "AVAILABLE" => "green", "MX" => "orange", "GROUND" => "red", "UNAVAILABLE" => "gray" }[aircraft.status]
tag.span(aircraft.status_label, class: "badge-#{color}")
end
def visibility_badge(visibility)
color = { "private" => "gray", "status" => "green", "maintenance" => "blue" }[visibility]
tag.span(DocumentCollection::VISIBILITIES[visibility], class: "badge-#{color}")
end
def delete_button(label, path, confirm: "Are you sure?", **opts)
button_to label, path, method: :delete, form: { data: { turbo_confirm: confirm }, class: "inline" },
class: opts[:class] || "btn-danger btn-sm"
end
def empty_state(text)
tag.p(text, class: "py-6 text-center text-sm text-slate-500")
end
def nav_tab(label, path, active)
link_to label, path, class: [ "tab", ("tab-active" if active) ]
end
end
+5
View File
@@ -0,0 +1,5 @@
// Configure your import map in config/importmap.rb.
import "@hotwired/turbo-rails"
import "controllers"
import "chartkick"
import "Chart.bundle"
@@ -0,0 +1,9 @@
import { Application } from "@hotwired/stimulus"
const application = Application.start()
// Configure Stimulus development experience
application.debug = false
window.Stimulus = application
export { application }
@@ -0,0 +1,7 @@
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
connect() {
this.element.textContent = "Hello World!"
}
}
+4
View File
@@ -0,0 +1,4 @@
// Import and register all your controllers from the importmap via controllers/**/*_controller
import { application } from "controllers/application"
import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
eagerLoadControllersFrom("controllers", application)
+7
View File
@@ -0,0 +1,7 @@
class ApplicationJob < ActiveJob::Base
# Automatically retry jobs that encountered a deadlock
# retry_on ActiveRecord::Deadlocked
# Most jobs are safe to ignore if the underlying records are no longer available
# discard_on ActiveJob::DeserializationError
end
+4
View File
@@ -0,0 +1,4 @@
class ApplicationMailer < ActionMailer::Base
default from: ENV.fetch("MAIL_FROM", "aircraft-manager@localhost")
layout "mailer"
end
+6
View File
@@ -0,0 +1,6 @@
class PasswordsMailer < ApplicationMailer
def reset(user)
@user = user
mail subject: "Reset your password", to: user.email_address
end
end
+16
View File
@@ -0,0 +1,16 @@
class AdCompliance < ApplicationRecord
belongs_to :airworthiness_directive
belongs_to :aircraft, optional: true
belongs_to :component, optional: true
belongs_to :logbook_entry, optional: true
belongs_to :inspection_record, optional: true
validates :date_complied, :compliance_notes, presence: true
validate { errors.add(:base, "Must belong to an aircraft or component") unless aircraft_id || component_id }
scope :recent_first, -> { order(date_complied: :desc, created_at: :desc) }
def self.for_aircraft(aircraft)
where(aircraft_id: aircraft.id).or(where(component_id: aircraft.components.select(:id)))
end
end
+73
View File
@@ -0,0 +1,73 @@
class Aircraft < ApplicationRecord
STATUSES = {
"AVAILABLE" => "Available",
"MX" => "In Maintenance",
"GROUND" => "Grounded",
"UNAVAILABLE" => "Unavailable"
}.freeze
has_one_attached :picture
has_many :roles, class_name: "AircraftRole", dependent: :destroy
has_many :users, through: :roles
has_many :notes, class_name: "AircraftNote", dependent: :destroy
has_many :events, class_name: "AircraftEvent", dependent: :delete_all
has_many :share_tokens, dependent: :destroy
has_many :components, dependent: :destroy
has_many :squawks, dependent: :destroy
has_many :logbook_entries, dependent: :destroy
has_many :document_collections, dependent: :destroy
has_many :documents, dependent: :destroy
has_many :inspection_records, dependent: :destroy
has_many :ad_compliances, dependent: :destroy
has_many :major_records, dependent: :destroy
has_many :flight_logs, dependent: :destroy
has_many :consumable_records, dependent: :destroy
has_and_belongs_to_many :inspection_types
has_and_belongs_to_many :airworthiness_directives
validates :tail_number, presence: true
validates :status, inclusion: { in: STATUSES.keys }
validate :picture_is_image
scope :ordered, -> { order(:tail_number) }
def to_s = tail_number
def status_label = STATUSES[status]
# Hours used for compliance calculations (tach minus offset, as in the original).
def current_hours
tach_time - tach_time_offset
end
def airworthiness
@airworthiness ||= Airworthiness.new(self).call
end
def reload(*)
@airworthiness = nil
super
end
# ADs that apply directly or via any installed component.
def applicable_ads
AirworthinessDirective.applicable_to(self)
end
def applicable_inspection_types
InspectionType.applicable_to(self)
end
def log_event!(category, event_name, user: Current.user, notes: nil)
events.create!(category: category, event_name: event_name, user: user, notes: notes)
end
private
def picture_is_image
if picture.attached? && !picture.content_type.to_s.start_with?("image/")
errors.add(:picture, "must be an image")
end
end
end
+15
View File
@@ -0,0 +1,15 @@
class AircraftEvent < ApplicationRecord
CATEGORIES = {
"hours" => "Hours Update", "flight" => "Flight", "component" => "Component",
"squawk" => "Squawk", "note" => "Note", "oil" => "Oil", "fuel" => "Fuel",
"logbook" => "Logbook", "ad" => "Airworthiness Directive", "inspection" => "Inspection",
"document" => "Document", "aircraft" => "Aircraft", "role" => "Role",
"major_record" => "Major Repair/Alteration"
}.freeze
belongs_to :aircraft
belongs_to :user, optional: true
validates :category, inclusion: { in: CATEGORIES.keys }
default_scope { order(created_at: :desc) }
end
+8
View File
@@ -0,0 +1,8 @@
class AircraftNote < ApplicationRecord
belongs_to :aircraft
belongs_to :user, optional: true
validates :text, presence: true
scope :visible_publicly, -> { where(public: true) }
scope :recent_first, -> { order(created_at: :desc) }
end
+11
View File
@@ -0,0 +1,11 @@
class AircraftRole < ApplicationRecord
ROLES = { "owner" => "Owner", "pilot" => "Pilot" }.freeze
belongs_to :aircraft
belongs_to :user
validates :role, inclusion: { in: ROLES.keys }
validates :user_id, uniqueness: { scope: :aircraft_id, message: "already has a role on this aircraft" }
scope :owners, -> { where(role: "owner") }
end
+33
View File
@@ -0,0 +1,33 @@
class AirworthinessDirective < ApplicationRecord
COMPLIANCE_TYPES = { "standard" => "Standard", "conditional" => "Conditional" }.freeze
BULLETIN_TYPES = {
"ad" => "Airworthiness Directive", "saib" => "Special Airworthiness Information Bulletin",
"sb" => "Service Bulletin", "alert" => "Airworthiness Alert", "other" => "Other"
}.freeze
BULLETIN_LABELS = { "ad" => "AD", "saib" => "SAIB", "sb" => "SB", "alert" => "Alert", "other" => "Bulletin" }.freeze
belongs_to :document, optional: true
has_and_belongs_to_many :aircraft
has_and_belongs_to_many :components
has_many :ad_compliances, dependent: :destroy
validates :name, :short_description, presence: true
validates :compliance_type, inclusion: { in: COMPLIANCE_TYPES.keys }
validates :bulletin_type, inclusion: { in: BULLETIN_TYPES.keys }
scope :ordered, -> { order(:name) }
def self.applicable_to(aircraft)
direct = joins(:aircraft).where(aircraft: { id: aircraft.id }).select(:id)
via_component = joins(:components).where(components: { aircraft_id: aircraft.id }).select(:id)
where(id: direct).or(where(id: via_component))
end
def to_s = name
def conditional? = compliance_type == "conditional"
def bulletin_label = BULLETIN_LABELS[bulletin_type]
def latest_compliance_for(aircraft)
ad_compliances.for_aircraft(aircraft).order(date_complied: :desc, created_at: :desc).first
end
end
+3
View File
@@ -0,0 +1,3 @@
class ApplicationRecord < ActiveRecord::Base
primary_abstract_class
end
+73
View File
@@ -0,0 +1,73 @@
class Component < ApplicationRecord
STATUSES = { "SPARE" => "Spare Part", "IN-USE" => "In Service", "DISPOSED" => "Disposed" }.freeze
belongs_to :aircraft, optional: true
belongs_to :parent_component, class_name: "Component", optional: true
belongs_to :component_type
has_many :child_components, class_name: "Component", foreign_key: :parent_component_id, dependent: :destroy
has_many :squawks, dependent: :nullify
has_and_belongs_to_many :inspection_types
has_and_belongs_to_many :airworthiness_directives
validates :manufacturer, :model, :date_in_service, presence: true
validates :status, inclusion: { in: STATUSES.keys }
validate :parent_on_same_aircraft
scope :in_use, -> { where(status: "IN-USE") }
def to_s
[ component_type&.name, install_location.presence && "(#{install_location})" ].compact.join(" ")
end
def status_label = STATUSES[status]
def hours_to_tbo
tbo_hours - hours_since_overhaul if tbo_hours
end
def hours_to_replacement
replacement_hours - hours_since_overhaul if replacement_hours
end
def next_replacement_date
overhaul_date + replacement_days.days if replacement_days && overhaul_date
end
# :overdue / :due_soon / :ok / nil (not tracked) for display on the components tab.
def life_status
statuses = []
if replacement_critical?
if replacement_hours
statuses << rank(hours_to_replacement <= 0, hours_to_replacement <= Airworthiness::HOURS_WARNING)
end
if (d = next_replacement_date)
statuses << rank(Date.current >= d, Date.current + Airworthiness::DAYS_WARNING >= d)
end
end
if tbo_critical? && tbo_hours && !on_condition?
statuses << rank(hours_to_tbo <= 0, hours_to_tbo <= Airworthiness::HOURS_WARNING * 5)
end
return nil if statuses.empty?
%i[overdue due_soon ok].find { |s| statuses.include?(s) }
end
# Service reset: always zeroes time since overhaul; optionally the whole
# in-service clock when the part was physically replaced.
def reset_service!(reset_in_service: false)
attrs = { hours_since_overhaul: 0, overhaul_date: Date.current }
attrs.merge!(hours_in_service: 0, date_in_service: Date.current) if reset_in_service
update!(attrs)
end
private
def rank(overdue, soon)
overdue ? :overdue : (soon ? :due_soon : :ok)
end
def parent_on_same_aircraft
return unless parent_component
errors.add(:parent_component, "can't be itself") if parent_component_id == id && id
errors.add(:parent_component, "must be on the same aircraft") if parent_component.aircraft_id != aircraft_id
end
end
+6
View File
@@ -0,0 +1,6 @@
class ComponentType < ApplicationRecord
has_many :components, dependent: :restrict_with_error
validates :name, presence: true, uniqueness: { case_sensitive: false }
scope :ordered, -> { order(:name) }
def to_s = name
end
View File
Whitespace-only changes.
+27
View File
@@ -0,0 +1,27 @@
# Mirrors the original's ALLOWED_UPLOAD_EXTENSIONS / content-type checks.
module UploadValidation
extend ActiveSupport::Concern
ALLOWED_CONTENT_TYPES = %w[
image/jpeg image/png image/gif image/webp image/bmp image/tiff
application/pdf text/plain application/gpx+xml application/xml text/xml
text/csv application/vnd.google-earth.kml+xml application/octet-stream
].freeze
MAX_SIZE = 50.megabytes
class_methods do
def validates_uploads(*names)
validate do
names.each do |name|
Array(public_send(name).attachments).each do |att|
next unless att.blob
unless ALLOWED_CONTENT_TYPES.include?(att.blob.content_type)
errors.add(name, "#{att.filename} is not an allowed file type")
end
errors.add(name, "#{att.filename} is too large") if att.blob.byte_size > MAX_SIZE
end
end
end
end
end
end
+17
View File
@@ -0,0 +1,17 @@
class ConsumableRecord < ApplicationRecord
TYPES = { "oil" => "Oil", "fuel" => "Fuel" }.freeze
UNITS = { "oil" => "qt", "fuel" => "gal" }.freeze
belongs_to :aircraft
belongs_to :flight_log, optional: true
validates :record_type, inclusion: { in: TYPES.keys }
validates :date, :flight_hours, presence: true
validates :quantity_added, presence: true, numericality: { greater_than_or_equal_to: 0 }
scope :oil, -> { where(record_type: "oil") }
scope :fuel, -> { where(record_type: "fuel") }
scope :recent_first, -> { order(date: :desc, created_at: :desc) }
def unit = UNITS[record_type]
end
+4
View File
@@ -0,0 +1,4 @@
class Current < ActiveSupport::CurrentAttributes
attribute :session
delegate :user, to: :session, allow_nil: true
end
+38
View File
@@ -0,0 +1,38 @@
class Document < ApplicationRecord
include UploadValidation
TYPES = {
"LOG" => "Logbook", "ALTER" => "Alteration Record", "REPORT" => "Report",
"ESTIMATE" => "Estimate", "DISC" => "Discrepancy List", "INVOICE" => "Receipt / Invoice",
"AIRCRAFT" => "Aircraft Record", "OTHER" => "Other"
}.freeze
belongs_to :aircraft
belongs_to :document_collection, optional: true
has_many_attached :pages
has_many :logbook_entries, dependent: :nullify
validates :name, presence: true
validates :doc_type, inclusion: { in: TYPES.keys }
validates :visibility, inclusion: { in: DocumentCollection::VISIBILITIES.keys }, allow_nil: true
validates_uploads :pages
normalizes :visibility, with: ->(v) { v.presence }
scope :ordered, -> { order(:name) }
def to_s = name
def type_label = TYPES[doc_type]
# nil visibility inherits from the collection; uncollected docs default to private.
def effective_visibility
visibility || document_collection&.visibility || "private"
end
def visible_to_share?(share)
case effective_visibility
when "status" then true
when "maintenance" then share.maintenance?
else false
end
end
end
+12
View File
@@ -0,0 +1,12 @@
class DocumentCollection < ApplicationRecord
VISIBILITIES = { "private" => "Private", "status" => "All share links", "maintenance" => "Maintenance only" }.freeze
belongs_to :aircraft
has_many :documents, dependent: :destroy
validates :name, presence: true
validates :visibility, inclusion: { in: VISIBILITIES.keys }
scope :ordered, -> { order(starred: :desc, name: :asc) }
def to_s = name
end
+28
View File
@@ -0,0 +1,28 @@
class FlightLog < ApplicationRecord
include UploadValidation
belongs_to :aircraft
belongs_to :user, optional: true
has_many :consumable_records, dependent: :nullify
has_one_attached :track_log
validates :date, presence: true
validates :tach_time, presence: true, numericality: { greater_than: 0 }
validates :hobbs_time, numericality: { greater_than_or_equal_to: 0 }, allow_nil: true
validates_uploads :track_log
before_validation :derive_times
scope :recent_first, -> { order(date: :desc, created_at: :desc) }
def route_summary
[ departure_location, destination_location ].compact_blank.join(" → ")
end
private
# Let the pilot enter out/in readings instead of the delta.
def derive_times
self.tach_time = tach_in - tach_out if tach_time.blank? && tach_in && tach_out
self.hobbs_time = hobbs_in - hobbs_out if hobbs_time.blank? && hobbs_in && hobbs_out
end
end
+22
View File
@@ -0,0 +1,22 @@
class InspectionRecord < ApplicationRecord
belongs_to :inspection_type
belongs_to :aircraft, optional: true
belongs_to :component, optional: true
belongs_to :logbook_entry, optional: true
has_many :ad_compliances, dependent: :nullify
validates :date, presence: true
validate { errors.add(:base, "Must belong to an aircraft or component") unless aircraft_id || component_id }
scope :recent_first, -> { order(date: :desc, created_at: :desc) }
# Records belonging to the aircraft, or to any of its components.
def self.for_aircraft(aircraft)
where(aircraft_id: aircraft.id).or(where(component_id: aircraft.components.select(:id)))
end
# Hours at inspection, falling back to the linked logbook entry.
def hours_at_inspection
aircraft_hours || logbook_entry&.aircraft_hours_at_entry
end
end
+27
View File
@@ -0,0 +1,27 @@
class InspectionType < ApplicationRecord
has_and_belongs_to_many :aircraft
has_and_belongs_to_many :components
has_many :inspection_records, dependent: :destroy
validates :name, presence: true
scope :ordered, -> { order(:name) }
# Applies to the aircraft directly, or to one of its components.
def self.applicable_to(aircraft)
direct = joins(:aircraft).where(aircraft: { id: aircraft.id }).select(:id)
via_component = joins(:components).where(components: { aircraft_id: aircraft.id }).select(:id)
where(id: direct).or(where(id: via_component))
end
def to_s = name
def interval_description
return "One-time" unless recurring?
parts = []
parts << "#{recurring_hours.to_s.sub(/\.0\z/, '')} hrs" if recurring_hours.to_f > 0
parts << "#{recurring_months} months" if recurring_months > 0
parts << "#{recurring_days} days" if recurring_days > 0
parts.any? ? "Every #{parts.join(' / ')}" : "Recurring"
end
end
+26
View File
@@ -0,0 +1,26 @@
class LogbookEntry < ApplicationRecord
LOG_TYPES = { "AC" => "Aircraft", "ENG" => "Engine", "PROP" => "Propeller", "OTHER" => "Other" }.freeze
ENTRY_TYPES = {
"MAINTENANCE" => "Maintenance", "INSPECTION" => "Inspection", "FLIGHT" => "Flight",
"HOURS_UPDATE" => "Hours Update", "OTHER" => "Other"
}.freeze
belongs_to :aircraft
belongs_to :document, optional: true
has_many :inspection_records, dependent: :nullify
has_many :ad_compliances, dependent: :nullify
validates :date, :text, presence: true
validates :log_type, inclusion: { in: LOG_TYPES.keys }
validates :entry_type, inclusion: { in: ENTRY_TYPES.keys }
scope :recent_first, -> { order(date: :desc, created_at: :desc) }
def self.search(q)
return all if q.blank?
term = "%#{sanitize_sql_like(q)}%"
where("text LIKE :t OR signoff_person LIKE :t OR signoff_location LIKE :t", t: term)
end
def to_s = "#{date} — #{LOG_TYPES[log_type]}"
end
+16
View File
@@ -0,0 +1,16 @@
class MajorRecord < ApplicationRecord
RECORD_TYPES = { "repair" => "Major Repair", "alteration" => "Major Alteration" }.freeze
belongs_to :aircraft
belongs_to :component, optional: true
belongs_to :form_337_document, class_name: "Document", optional: true
belongs_to :stc_document, class_name: "Document", optional: true
belongs_to :logbook_entry, optional: true
validates :title, :date_performed, presence: true
validates :record_type, inclusion: { in: RECORD_TYPES.keys }
scope :recent_first, -> { order(date_performed: :desc, created_at: :desc) }
def type_label = RECORD_TYPES[record_type]
end
+3
View File
@@ -0,0 +1,3 @@
class Session < ApplicationRecord
belongs_to :user
end
+28
View File
@@ -0,0 +1,28 @@
class ShareToken < ApplicationRecord
PRIVILEGES = { "status" => "Current Status", "maintenance" => "Maintenance Detail" }.freeze
MAX_PER_AIRCRAFT = 10
belongs_to :aircraft
belongs_to :created_by, class_name: "User", optional: true
has_secure_token :token, length: 32
validates :privilege, inclusion: { in: PRIVILEGES.keys }
validate :within_limit, on: :create
scope :active, -> { where(expires_at: nil).or(where(expires_at: Time.current..)) }
def self.find_active(token)
active.find_by(token: token.to_s)
end
def maintenance? = privilege == "maintenance"
def expired? = expires_at.present? && expires_at < Time.current
private
def within_limit
if aircraft && aircraft.share_tokens.count >= MAX_PER_AIRCRAFT
errors.add(:base, "An aircraft can have at most #{MAX_PER_AIRCRAFT} share links")
end
end
end
+27
View File
@@ -0,0 +1,27 @@
class Squawk < ApplicationRecord
include UploadValidation
PRIORITIES = { 0 => "Ground Aircraft", 1 => "Fix Soon", 2 => "Fix at Next Inspection", 3 => "Fix Eventually" }.freeze
PRIORITY_COLORS = { 0 => "red", 1 => "orange", 2 => "blue", 3 => "gray" }.freeze
belongs_to :aircraft
belongs_to :component, optional: true
belongs_to :reported_by, class_name: "User", optional: true
has_one_attached :attachment
validates :priority, inclusion: { in: PRIORITIES.keys }
validates :issue_reported, presence: true
validates_uploads :attachment
scope :active, -> { where(resolved: false) }
scope :resolved, -> { where(resolved: true) }
scope :by_priority, -> { order(:priority, created_at: :desc) }
def priority_label = PRIORITIES[priority]
def priority_color = PRIORITY_COLORS[priority]
def grounding? = priority.zero? && !resolved?
def resolve!(notes: nil)
update!(resolved: true, resolved_at: Time.current, notes: [ self.notes, notes ].compact_blank.join("\n\n"))
end
end
+27
View File
@@ -0,0 +1,27 @@
class User < ApplicationRecord
has_secure_password
has_many :sessions, dependent: :destroy
has_many :aircraft_roles, dependent: :destroy
has_many :aircraft, through: :aircraft_roles
normalizes :email_address, with: ->(e) { e.strip.downcase }
validates :email_address, presence: true, uniqueness: true,
format: { with: URI::MailTo::EMAIL_REGEXP }
validates :password, length: { minimum: 8 }, allow_nil: true
# Aircraft visible to this user: admins see the whole fleet.
def accessible_aircraft
admin? ? Aircraft.all : aircraft
end
# 'admin' | 'owner' | 'pilot' | nil
def role_for(aircraft)
return "admin" if admin?
aircraft_roles.find_by(aircraft: aircraft)&.role
end
def display_name
name.presence || email_address
end
end
+11
View File
@@ -0,0 +1,11 @@
# Raised when a flight-activity write is attempted on a RED aircraft whose
# airworthiness enforcement is enabled.
class AircraftGroundedError < StandardError
attr_reader :airworthiness
def initialize(airworthiness)
@airworthiness = airworthiness
reasons = airworthiness.red_issues.map(&:title).join("; ")
super([ "Aircraft is grounded and airworthiness enforcement is enabled", reasons.presence ].compact.join(": "))
end
end
+120
View File
@@ -0,0 +1,120 @@
# Computes RED / ORANGE / GREEN airworthiness for an aircraft. Checks (in order):
# AD compliance, grounding squawks, inspection recurrency, component replacement.
class Airworthiness
HOURS_WARNING = BigDecimal("10")
DAYS_WARNING = 30
RED = "RED"
ORANGE = "ORANGE"
GREEN = "GREEN"
Issue = Struct.new(:category, :severity, :title, :description, :item, keyword_init: true)
Status = Struct.new(:status, :issues, keyword_init: true) do
def red? = status == RED
def orange? = status == ORANGE
def green? = status == GREEN
def can_fly? = green?
def red_issues = issues.select { |i| i.severity == RED }
def label = { RED => "Not Airworthy", ORANGE => "Attention Needed", GREEN => "Airworthy" }[status]
end
def initialize(aircraft, today: Date.current)
@aircraft = aircraft
@today = today
@hours = aircraft.current_hours
@issues = []
end
def call
check_ads
check_grounding_squawks
check_inspections
check_components
status =
if @issues.any? { _1.severity == RED } then RED
elsif @issues.any? { _1.severity == ORANGE } then ORANGE
else GREEN
end
Status.new(status: status, issues: @issues)
end
private
def add(category, severity, title, description, item)
@issues << Issue.new(category:, severity:, title:, description:, item:)
end
def check_ads
@aircraft.applicable_ads.where(mandatory: true, compliance_type: "standard").find_each do |ad|
compliance = ad.latest_compliance_for(@aircraft)
res = Compliance.ad_status(ad, compliance, @hours, @today)
label = ad.bulletin_label
case res.rank
when Compliance::OVERDUE
desc = compliance ? "#{ad.short_description}. Compliance overdue." : "#{ad.short_description}. No compliance record found."
add("AD", RED, "#{label} #{ad.name} - Overdue", desc, ad)
when Compliance::DUE_SOON
add("AD", ORANGE, "#{label} #{ad.name} - Due Soon", "#{ad.short_description}. Compliance due soon.", ad)
end
end
end
def check_grounding_squawks
@aircraft.squawks.active.where(priority: 0).find_each do |squawk|
add("SQUAWK", RED, "Grounding Squawk", squawk.issue_reported.to_s.truncate(100).presence || "No description", squawk)
end
end
def check_inspections
@aircraft.applicable_inspection_types.where(required: true).find_each do |type|
last = type.inspection_records.for_aircraft(@aircraft).recent_first.first
res = Compliance.inspection_status(type, last, @hours, @today)
case res.rank
when Compliance::OVERDUE
if last
add("INSPECTION", RED, "#{type.name} - Overdue", "Inspection overdue.", type)
else
add("INSPECTION", RED, "#{type.name} - Never Completed", "Required inspection has no completion record.", type)
end
when Compliance::DUE_SOON
add("INSPECTION", ORANGE, "#{type.name} - Due Soon", "Inspection due soon.", type)
end
end
end
def check_components
@aircraft.components.in_use.where(replacement_critical: true).includes(:component_type).find_each do |c|
overdue = false
approaching = false
desc = ""
if c.replacement_hours
if c.hours_since_overhaul >= c.replacement_hours
overdue = true
desc = "Replace every #{c.replacement_hours} hrs. Current: #{c.hours_since_overhaul} hrs."
elsif c.hours_since_overhaul + HOURS_WARNING >= c.replacement_hours
approaching = true
desc = "Replace in #{c.replacement_hours - c.hours_since_overhaul} hrs."
end
end
if (due = c.next_replacement_date)
if @today >= due
overdue = true
desc = "Replace every #{c.replacement_days} days. Last serviced #{c.overhaul_date}."
elsif @today + DAYS_WARNING >= due
approaching = true
desc = "Replace in #{(due - @today).to_i} days."
end
end
if overdue
add("COMPONENT", RED, "#{c} - Replacement Overdue", desc, c)
elsif approaching
add("COMPONENT", ORANGE, "#{c} - Replacement Due Soon", desc, c)
end
end
end
end
+119
View File
@@ -0,0 +1,119 @@
# Shared AD / inspection due-status math (port of ad_compliance_status /
# inspection_compliance_status from the original health/services.py).
module Compliance
COMPLIANT = 0
DUE_SOON = 1
OVERDUE = 2
LABELS = %w[compliant due_soon overdue].freeze
Result = Struct.new(:rank, :next_due_date, :next_due_hours, keyword_init: true) do
def label = LABELS[rank]
end
module_function
# Last day of the month `months` after `date` (FAA "end of month" convention).
def end_of_month_after(date, months)
(date >> months).end_of_month
end
def ad_status(ad, compliance, current_hours, today = Date.current)
return Result.new(rank: COMPLIANT) if ad.conditional?
return Result.new(rank: OVERDUE) unless compliance
return Result.new(rank: COMPLIANT) if compliance.permanent?
rank = COMPLIANT
result = Result.new
due_hours = compliance.next_due_at_time.to_d
if due_hours > 0
result.next_due_hours = due_hours
if current_hours >= due_hours
rank = OVERDUE
elsif current_hours + Airworthiness::HOURS_WARNING >= due_hours
rank = [ rank, DUE_SOON ].max
end
end
if ad.recurring? && ad.recurring_months.positive?
due = end_of_month_after(compliance.date_complied, ad.recurring_months)
result.next_due_date = due
if today > due
rank = OVERDUE
elsif today + Airworthiness::DAYS_WARNING >= due
rank = [ rank, DUE_SOON ].max
end
end
result.rank = rank
result
end
def inspection_status(type, last_record, current_hours, today = Date.current)
return Result.new(rank: OVERDUE) unless last_record
return Result.new(rank: COMPLIANT) unless type.recurring?
rank = COMPLIANT
result = Result.new
if type.recurring_months.positive? || type.recurring_days.positive?
due = last_record.date
due = end_of_month_after(due, type.recurring_months) if type.recurring_months.positive?
due += type.recurring_days.days if type.recurring_days.positive?
result.next_due_date = due
if today > due
rank = OVERDUE
elsif today + Airworthiness::DAYS_WARNING >= due
rank = [ rank, DUE_SOON ].max
end
end
interval = type.recurring_hours.to_d
if interval > 0 && (hours_at = last_record.hours_at_inspection)
since = current_hours - hours_at
result.next_due_hours = hours_at + interval
if since >= interval
rank = OVERDUE
elsif since + Airworthiness::HOURS_WARNING >= interval
rank = [ rank, DUE_SOON ].max
end
end
result.rank = rank
result
end
# Rows for the ADs tab: every applicable AD with its latest compliance and status.
AdRow = Struct.new(:ad, :latest, :status, :next_due_date, :next_due_hours, keyword_init: true)
def ad_rows(aircraft)
hours = aircraft.current_hours
aircraft.applicable_ads.ordered.map do |ad|
latest = ad.latest_compliance_for(aircraft)
status =
if ad.conditional? then latest ? "compliant" : "conditional"
elsif latest.nil? then "no_compliance"
elsif latest.permanent? then "compliant"
end
res = ad_status(ad, latest, hours) unless status
AdRow.new(ad: ad, latest: latest, status: status || res.label,
next_due_date: res&.next_due_date, next_due_hours: res&.next_due_hours)
end
end
InspectionRow = Struct.new(:type, :latest, :status, :next_due_date, :next_due_hours, keyword_init: true)
def inspection_rows(aircraft)
hours = aircraft.current_hours
aircraft.applicable_inspection_types.ordered.map do |type|
latest = type.inspection_records.for_aircraft(aircraft).recent_first.first
if latest.nil?
InspectionRow.new(type: type, latest: nil, status: "never_completed")
else
res = inspection_status(type, latest, hours)
InspectionRow.new(type: type, latest: latest, status: res.label,
next_due_date: res.next_due_date, next_due_hours: res.next_due_hours)
end
end
end
end
+58
View File
@@ -0,0 +1,58 @@
# Oil/fuel consumption: per-interval datapoints between consecutive records
# (sorted by flight hours), averaged over the last 20 with IQR outliers and
# excluded records left out. Oil → hours per quart; fuel → gallons per hour.
class ConsumptionStats
WINDOW = 20
Point = Struct.new(:record, :hours, :value, :excluded, :outlier, keyword_init: true)
attr_reader :record_type, :records
def initialize(aircraft, record_type)
@record_type = record_type
@records = aircraft.consumable_records.where(record_type: record_type).order(:flight_hours, :date).to_a
end
def oil? = record_type == "oil"
def metric_label = oil? ? "hrs/qt" : "gal/hr"
def points
@points ||= begin
pts = @records.each_cons(2).filter_map do |prev, cur|
dh = (cur.flight_hours - prev.flight_hours).to_f
qty = cur.quantity_added.to_f
next unless qty > 0 && dh > 0
Point.new(record: cur, hours: cur.flight_hours.to_f, value: oil? ? dh / qty : qty / dh,
excluded: cur.excluded_from_averages?)
end
bounds = iqr_bounds(pts.map(&:value))
pts.each { |p| p.outlier = bounds && !(bounds[0]..bounds[1]).cover?(p.value) }
end
end
def average
window = points.last(WINDOW)
return nil if window.empty?
included = window.reject { |p| p.excluded || p.outlier }
source = included.presence || window
(source.sum(&:value) / source.size).round(1)
end
def latest = points.last&.value&.round(1)
def chart_data
points.map { |p| [ p.hours.round(1), p.value.round(2) ] }
end
private
def iqr_bounds(values)
return nil if values.size < 5
nums = values.sort
n = nums.size
q1 = nums[n / 4]
q3 = nums[(3 * n) / 4]
iqr = q3 - q1
return nil if iqr.zero?
[ q1 - 1.5 * iqr, q3 + 1.5 * iqr ]
end
end
+75
View File
@@ -0,0 +1,75 @@
# Flight-activity writes: absolute hours updates and flight logs. Both cascade
# the tach delta to every IN-USE component.
class HoursService
def initialize(aircraft, user: Current.user)
@aircraft = aircraft
@user = user
end
def enforce_airworthiness!
return unless @aircraft.airworthiness_enforcement?
status = Airworthiness.new(@aircraft).call
raise AircraftGroundedError, status if status.red?
end
# Set absolute tach (and optional hobbs); component hours are clamped at 0
# so downward corrections can't go negative.
def update_hours!(tach_time:, hobbs_time: nil)
enforce_airworthiness!
tach = BigDecimal(tach_time.to_s)
delta = tach - @aircraft.tach_time
old = @aircraft.tach_time
Aircraft.transaction do
@aircraft.tach_time = tach
@aircraft.hobbs_time = BigDecimal(hobbs_time.to_s) if hobbs_time.present?
@aircraft.save!
cascade_to_components(delta, clamp: true)
@aircraft.log_event!("hours",
"Hours #{delta >= 0 ? 'updated' : 'corrected'} to #{tach}",
user: @user, notes: "Previous: #{old}, delta: #{delta >= 0 ? '+' : ''}#{delta}")
end
delta
end
# Persist a flight log and apply its side effects atomically.
def log_flight!(flight)
enforce_airworthiness!
Aircraft.transaction do
flight.aircraft = @aircraft
flight.user ||= @user
flight.save!
@aircraft.tach_time += flight.tach_time
@aircraft.hobbs_time += flight.hobbs_time if flight.hobbs_time
@aircraft.save!
cascade_to_components(flight.tach_time)
{ "oil" => [ flight.oil_added, flight.oil_level_after, flight.oil_added_type ],
"fuel" => [ flight.fuel_added, flight.fuel_level_after, flight.fuel_added_type ] }.each do |type, (qty, level, kind)|
next unless qty.to_f > 0
@aircraft.consumable_records.create!(
record_type: type, flight_log: flight, date: flight.date, quantity_added: qty,
level_after: level, consumable_type: kind, flight_hours: @aircraft.tach_time,
notes: "Auto-created from flight log")
@aircraft.log_event!(type, "#{type.capitalize} added: #{qty} #{ConsumableRecord::UNITS[type]}",
user: @user, notes: "From flight log")
end
route = flight.route_summary.presence
@aircraft.log_event!("flight", "Flight logged: #{flight.tach_time} hrs#{" (#{route})" if route}", user: @user)
end
flight
end
private
def cascade_to_components(delta, clamp: false)
@aircraft.components.in_use.find_each do |c|
his = c.hours_in_service + delta
hso = c.hours_since_overhaul + delta
his, hso = [ his, 0 ].max, [ hso, 0 ].max if clamp
c.update_columns(hours_in_service: his, hours_since_overhaul: hso, updated_at: Time.current)
end
end
end
+15
View File
@@ -0,0 +1,15 @@
<%= form_with model: compliance, url: compliance.new_record? ? aircraft_ad_compliances_path(aircraft) : aircraft_ad_compliance_path(aircraft, compliance), class: "card card-body space-y-4 max-w-2xl" do |f| %>
<%= f.errors_summary %>
<%= f.field :airworthiness_directive_id, as: :select, label: "AD", collection: aircraft.applicable_ads.ordered.map { ["#{_1.name} – #{_1.short_description.truncate(50)}", _1.id] } %>
<div class="grid gap-4 sm:grid-cols-2">
<%= f.field :date_complied, as: :date %>
<%= f.field :aircraft_hours_at_compliance, as: :number, step: 0.1, label: "Aircraft hours (tach)" %>
<%= f.field :next_due_at_time, as: :number, step: 0.1, label: "Next due at (tach hours)", hint: "0 = no hour-based recurrence." %>
<%= f.field :component_id, as: :select, label: "Component", collection: component_options(aircraft) %>
<%= f.field :logbook_entry_id, as: :select, label: "Logbook entry", collection: logbook_options(aircraft) %>
</div>
<%= f.field :permanent, as: :checkbox, label: "Permanently complied (terminating action)" %>
<%= f.field :compliance_notes, as: :textarea, label: "Method of compliance", rows: 3, required: true %>
<div class="flex gap-2"><%= f.submit "Save" %><%= link_to "Cancel", aircraft_airworthiness_directives_path(aircraft), class: "btn-secondary" %></div>
<% end %>
<% if compliance.persisted? %><div class="mt-4"><%= delete_button "Delete record", aircraft_ad_compliance_path(aircraft, compliance) %></div><% end %>
+2
View File
@@ -0,0 +1,2 @@
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= render "form", aircraft: @aircraft, compliance: @compliance %>
Loaded 100 of 264 files, more files were not shown because too many files have changed in this diff. Show more