Allow admin users to load pets

Also allows the new rake task we're building to load, too!
This commit is contained in:
Emi Matchu 2024-01-24 00:42:21 -08:00
parent 610177d3f5
commit c76e8cd2a9
2 changed files with 2 additions and 3 deletions

View file

@ -2,9 +2,10 @@ class PetsController < ApplicationController
rescue_from Pet::PetNotFound, :with => :pet_not_found
rescue_from PetType::DownloadError, SwfAsset::DownloadError, :with => :asset_download_error
rescue_from Pet::DownloadError, :with => :pet_download_error
rescue_from Pet::ModelingDisabled, with: :modeling_disabled
def load
return modeling_disabled unless user_signed_in? && current_user.admin?
raise Pet::PetNotFound unless params[:name]
@pet = Pet.load(
params[:name],

View file

@ -17,9 +17,7 @@ class Pet < ApplicationRecord
joins(:pet_type).where(PetType.arel_table[:id].in(color_ids))
}
class ModelingDisabled < RuntimeError;end
def load!(options={})
raise ModelingDisabled
options[:locale] ||= I18n.default_locale
I18n.with_locale(options.delete(:locale)) do
use_viewer_data(fetch_viewer_data(options.delete(:timeout)), options)