Files
simple-aircraft-manager-rails/app/controllers/admin/about_controller.rb
T
rickyandClaude Opus 5.5 89ed0a76f9 Move all user-facing text into config/locales/en.yml for localization
- Views use lazy t(".key") lookups; sentences with values or links stay
  whole (interpolation, _html keys); counts use one/other plurals
- Stored-value labels (statuses, types, priorities...) are LabelSets read
  from labels: in the current locale; field names and validation messages
  under activerecord:; flash and activity text under flash:
- Services, models, helpers, mailer subjects, the logbook PDF, procedures
  templates, records package README and transcription warnings localized;
  the PDF reuses LogbookEntry#certification_statement instead of a copy
- Scripts read js: strings from a JSON tag via app/javascript/i18n.js
- Dates through I18n.l (app, weekday, month_year, long formats); html lang
  follows the locale
- APP_LOCALE picks the language (falls back to English); missing
  translations raise in development and tests
- README: Translating section and APP_LOCALE

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 22:08:20 -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: t("flash.admin_about.try_again_in_a") }
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: t("flash.admin_about.backed_up_and_checked")
else
redirect_to admin_about_path(anchor: "records"), alert: t("flash.admin_about.the_records_check_found")
end
end
# This week's reminder for the current admin, now.
def test_reminder
return redirect_to(admin_about_path, alert: t("flash.admin_about.email_isn_t_set")) unless MailSettings.configured?
unless ReminderMailer.anything_for?(current_user)
return redirect_to admin_about_path, notice: t("flash.admin_about.nothing_needs_attention_on")
end
ReminderMailer.weekly(current_user).deliver_now
redirect_to admin_about_path, notice: t("flash.admin_about.reminder_sent_to", email_address: current_user.email_address)
rescue StandardError => e
redirect_to admin_about_path, alert: t("flash.admin_about.sending_failed", error: e.class.name.demodulize, message: 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: t("flash.admin_about.email_isn_t_set_2")
end
AdminMailer.test_email(current_user).deliver_now
redirect_to admin_about_path, notice: t("flash.admin_about.test_email_sent_to", email_address: current_user.email_address)
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: t("flash.admin_about.sending_failed_2", error: e.class.name.demodulize, message: e.message.to_s.squish.truncate(240))
end
end