mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
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:
1 parent
5584ad59c5
commit
aa262065b2
21 files changed
+253
-22
No files matched your search
@@ -6,11 +6,17 @@ class ReminderMailer < ApplicationMailer
|
||||
.map { [ _1, _1.airworthiness.issues, _1.ad_alerts.pending.to_a ] }.reject { _2.empty? && _3.empty? }
|
||||
end
|
||||
|
||||
def self.expiring_certificates_for(user) = user.certificates.expiring.to_a
|
||||
|
||||
def self.anything_for?(user) = items_for(user).any? || expiring_certificates_for(user).any?
|
||||
|
||||
def weekly(user)
|
||||
@user = user
|
||||
@items = self.class.items_for(user)
|
||||
@certificates = self.class.expiring_certificates_for(user)
|
||||
overdue = @items.sum { |_, issues, _| issues.count { _1.severity.in?(%w[RED LIMITED]) } }
|
||||
subject = overdue.positive? ? "#{overdue} #{'item'.pluralize(overdue)} overdue" : "Maintenance coming due"
|
||||
mail subject: "#{subject}: #{@items.map { _1.first.tail_number }.to_sentence}", to: user.email_address
|
||||
subject = "Certificate expiring" if @items.empty?
|
||||
mail subject: [ subject, @items.map { _1.first.tail_number }.to_sentence.presence ].compact.join(": "), to: user.email_address
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user