Class: Admin::Translations::PackagesController

Inherits:
BaseController show all
Includes:
ElasticAPM::SpanHelpers
Defined in:
app/controllers/admin/translations/packages_controller.rb

Constant Summary collapse

VALID_PACKAGE_TYPES =
%w[ayce party_pack xperience buffet set_menu hungry_at_home].freeze

Constants inherited from BaseController

BaseController::INTERNAL_SERVER_ERROR_MESSAGE

Instance Method Summary collapse

Methods inherited from BaseController

#destroy_session, #identity_cache_memoization, #sign_in_page, #user_developer_session

Methods included from LogrageCustomLogger

#append_info_to_payload

Methods included from AdminHelper

#dynamic_pricings_formatter, #link_to_admin_reservations_path_by_id, #link_to_admin_restaurants_path_by_id, #link_to_log, #optional_locales, #optional_locales_with_labels, #staff_signed_in?

Methods included from UpdateLocaleConcern

#setup_locale

Methods inherited from ApplicationController

#after_sign_in_path_for, #after_sign_out_path_for, #default_url_options, #identity_cache_memoization, #render_not_found, #routing_error, search_params_key=

Methods included from ControllerHelpers

#check_boolean_param, #get_banners, #inventory_params, #reservation_params

Instance Method Details

#exportObject

POST /admin/translations/packages/export



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/admin/translations/packages_controller.rb', line 19

def export
  package_type = params.require(:package_type).to_s.downcase
  target_locale = params.require(:target_locale).to_s.downcase

  unless VALID_PACKAGE_TYPES.include?(package_type)
    return render json: { error: "Invalid package_type. Valid types: #{VALID_PACKAGE_TYPES.join(', ')}" },
                  status: :unprocessable_entity
  end

  unless MyLocaleManager.available_locales.map(&:to_s).include?(target_locale) && target_locale != 'en'
    return render json: { error: 'Invalid or unsupported target_locale (must be non-English supported locale).' },
                  status: :unprocessable_entity
  end

  if defined?(BUSINESS_LOGGER)
    BUSINESS_LOGGER.set_business_context({ controller: self.class.name, action: 'export' })
    BUSINESS_LOGGER.info('package_translation_export_enqueue',
                         { user_id: current_user.id, target_locale: target_locale, package_type: package_type })
  end

  ::Translations::ExportPackagesTranslationWorker.perform_async(package_type, target_locale, current_user.id)
  render json: { status: 'queued', target_locale: target_locale, package_type: package_type }
end