From c76e8cd2a904558811abc2449697c0962b77e857 Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Wed, 24 Jan 2024 00:42:21 -0800 Subject: [PATCH] Allow admin users to load pets Also allows the new rake task we're building to load, too! --- app/controllers/pets_controller.rb | 3 ++- app/models/pet.rb | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/pets_controller.rb b/app/controllers/pets_controller.rb index 2b03d1fc..e66a7a91 100644 --- a/app/controllers/pets_controller.rb +++ b/app/controllers/pets_controller.rb @@ -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], diff --git a/app/models/pet.rb b/app/models/pet.rb index 64e4271e..ecc102fa 100644 --- a/app/models/pet.rb +++ b/app/models/pet.rb @@ -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)