Files
simple-aircraft-manager-rails/app/controllers/admin/about_controller.rb
T
rickyandClaude Opus 5.5 68a1719db2 Records integrity: history, nightly backup and check, records package
AC 120-78B chapter 3:
- Every change to logbook entries, sub-components, signatures, inspection
  records, AD compliance, major records, W&B, components, squawks and
  documents is kept as a RecordVersion (who, IP, when, field changes),
  hash-chained per aircraft; versions can't be edited or deleted. Shown on
  each logbook entry and in Activity -> Record history
- Nightly job: SQLite online-backup copy to storage/backups, verified
  (integrity_check + record counts), pruned to the configured number; then
  an integrity check of the history chains and every signature's seal and
  fingerprint. Results on Admin -> About ("Back up and check now"); admins
  are emailed on failure
- Software versions recorded (first/last seen) on Admin -> About
- Records package (Access & Sharing): logbook entries PDF with signatures,
  signatures.csv, record-history.csv, self-contained status report HTML,
  the .sam.zip, and a README, for the FAA/NTSB or a buyer
- Legacy (paper) records: documents can be marked as legacy records;
  aircraft have an "electronic records since" date (status report, package)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 13:21:26 -05:00

44 lines
2.1 KiB
Ruby

class Admin::AboutController < ApplicationController
before_action :require_admin!
rate_limit to: 5, within: 1.minute, only: %i[test_email test_reminder check_records], with: -> { redirect_to admin_about_path, alert: "Try again in a minute." }
def show
@info = SystemInfo.new
end
# Back up and verify the records now (normally nightly).
def check_records
backup = DatabaseBackup.run!
check = RecordsIntegrity.check!
if backup.ok && check.ok
redirect_to admin_about_path(anchor: "records"), notice: "Backed up and checked: no problems found."
else
redirect_to admin_about_path(anchor: "records"), alert: "The records check found problems; see Records below."
end
end
# This week's reminder for the current admin, now.
def test_reminder
return redirect_to(admin_about_path, alert: "Email isn't set up yet.") unless MailSettings.configured?
unless ReminderMailer.anything_for?(current_user)
return redirect_to admin_about_path, notice: "Nothing needs attention on the aircraft you own or your certificates, so there's no reminder to send."
end
ReminderMailer.weekly(current_user).deliver_now
redirect_to admin_about_path, notice: "Reminder sent to #{current_user.email_address}."
rescue StandardError => e
redirect_to admin_about_path, alert: "Sending failed: #{e.class.name.demodulize}: #{e.message.to_s.squish.truncate(240)}"
end
# Sends right away (not via the job queue) so problems show up here.
def test_email
unless MailSettings.configured?
return redirect_to admin_about_path, alert: "Email isn't set up yet: set SMTP_ADDRESS (and SMTP_PORT, SMTP_USERNAME, SMTP_PASSWORD, MAIL_FROM)."
end
AdminMailer.test_email(current_user).deliver_now
redirect_to admin_about_path, notice: "Test email sent to #{current_user.email_address}. If it doesn't arrive, check the spam folder."
rescue StandardError => e # SMTP, DNS, TLS and timeout errors alike
Rails.logger.warn("[test email] #{e.class}: #{e.message}")
redirect_to admin_about_path, alert: "Sending failed: #{e.class.name.demodulize}: #{e.message.to_s.squish.truncate(240)}"
end
end