Certificates on user profiles, with "Sign as"

- Users add their FAA certificates (kind, number, optional expiry) on
  their profile; admins see them on the Users list
- "Sign as" on new/edited logbook entries and the squawk Resolve page
  fills the signer's name, kind of certificate and number (expired
  certificates aren't offered); deferrals default to mechanic for users
  with a mechanic certificate
- Weekly reminder lists certificates expiring within 60 days (or lapsed
  in the last 30), even when nothing else is due
- Preventive maintenance templates keep a certificate already chosen

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-07 11:08:21 -05:00
1 parent 5584ad59c5
commit aa262065b2
21 files changed
+253 -22

No files matched your search

+2 -2
View File
@@ -9,8 +9,8 @@ class Admin::AboutController < ApplicationController
# 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?
if ReminderMailer.items_for(current_user).empty?
return redirect_to admin_about_path, notice: "Nothing needs attention on the aircraft you own, so there's no reminder to send."
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}."
+1 -1
View File
@@ -3,7 +3,7 @@ class Admin::UsersController < ApplicationController
before_action :set_user, only: %i[edit update destroy]
def index
@users = User.order(:email_address).includes(aircraft_roles: :aircraft)
@users = User.order(:email_address).includes(:certificates, aircraft_roles: :aircraft)
end
def new
@@ -0,0 +1,32 @@
# The signed-in user's own certificates (Profile → Certificates).
class UserCertificatesController < ApplicationController
before_action :set_certificate, only: %i[update destroy]
def create
certificate = current_user.certificates.new(certificate_params)
if certificate.save
redirect_to edit_profile_path(anchor: "certificates"), notice: "#{certificate.kind_label} certificate added."
else
redirect_to edit_profile_path(anchor: "certificates"), alert: "Certificate not added: #{certificate.errors.full_messages.to_sentence}."
end
end
def update
if @certificate.update(certificate_params)
redirect_to edit_profile_path(anchor: "certificates"), notice: "Certificate updated."
else
redirect_to edit_profile_path(anchor: "certificates"), alert: "Certificate not updated: #{@certificate.errors.full_messages.to_sentence}."
end
end
def destroy
@certificate.destroy!
redirect_to edit_profile_path(anchor: "certificates"), notice: "Certificate removed."
end
private
def set_certificate = @certificate = current_user.certificates.find(params[:id])
def certificate_params = params.require(:user_certificate).permit(:kind, :number, :expires_on)
end