mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 15:50:36 -05:00
- 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>
60 lines
2.6 KiB
Ruby
60 lines
2.6 KiB
Ruby
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.current_hours,
|
|
compliance_method: params[:not_applicable] == "1" ? "not_applicable" : "inspection")
|
|
@compliance.apply_method
|
|
@compliance.compliance_notes = t("flash.ad_compliances.not_applicable_prefix") if @compliance.not_applicable?
|
|
@compliance.fill_next_due
|
|
end
|
|
|
|
def create
|
|
@compliance = AdCompliance.new(compliance_params.merge(aircraft: @aircraft))
|
|
if @compliance.save
|
|
log_event("ad", "#{@compliance.not_applicable? ? "Marked N/A" : "Compliance recorded"}: #{@compliance.airworthiness_directive.name}")
|
|
redirect_to aircraft_airworthiness_directives_path(@aircraft), notice: t("flash.ad_compliances.compliance_recorded")
|
|
else
|
|
render :new, status: :unprocessable_entity
|
|
end
|
|
end
|
|
|
|
def edit; end
|
|
|
|
def update
|
|
if @compliance.update(compliance_params)
|
|
log_event("ad", t("flash.ad_compliances.compliance_updated_2", name: @compliance.airworthiness_directive.name))
|
|
redirect_to aircraft_airworthiness_directives_path(@aircraft), notice: t("flash.ad_compliances.compliance_updated")
|
|
else
|
|
render :edit, status: :unprocessable_entity
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
@compliance.destroy!
|
|
log_event("ad", t("flash.ad_compliances.compliance_deleted", name: @compliance.airworthiness_directive.name))
|
|
redirect_to aircraft_airworthiness_directives_path(@aircraft), notice: t("flash.ad_compliances.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,
|
|
:compliance_method, :ad_revision
|
|
)
|
|
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
|