From a9c9d0dc394aefd90291878c48e654a31662dea0 Mon Sep 17 00:00:00 2001 From: Benjamin ter Kuile Date: Sat, 5 May 2018 18:36:53 -0300 Subject: [PATCH] Callbackify autoload! since it is empty and fixes a but (forgotten in a controller) --- app/assets/javascripts/dunlop.coffee | 4 ++-- app/controllers/dunlop/source_files_controller.rb | 2 +- app/models/dunlop/source_file_model.rb | 6 ++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/dunlop.coffee b/app/assets/javascripts/dunlop.coffee index 3a471e2..8e7584b 100644 --- a/app/assets/javascripts/dunlop.coffee +++ b/app/assets/javascripts/dunlop.coffee @@ -35,8 +35,8 @@ $ -> try HawkEye.add_general_configuration facet: - state: - colors: + colors: + state: uncategorized: "#eee" unplanned: "#aaa" planned: "#99b" diff --git a/app/controllers/dunlop/source_files_controller.rb b/app/controllers/dunlop/source_files_controller.rb index fcea42d..5ebf189 100644 --- a/app/controllers/dunlop/source_files_controller.rb +++ b/app/controllers/dunlop/source_files_controller.rb @@ -27,7 +27,7 @@ class Dunlop::SourceFilesController < Dunlop::ApplicationController redirect_to source_files_path, alert: "No type specified" and return unless params[:source_file][:sti_type].present? authorize! :manage, @source_file @source_file.creator = current_user - @source_file.save && @source_file.autoload! + @source_file.save redirect_to source_files_path end diff --git a/app/models/dunlop/source_file_model.rb b/app/models/dunlop/source_file_model.rb index f3143f1..bb32193 100644 --- a/app/models/dunlop/source_file_model.rb +++ b/app/models/dunlop/source_file_model.rb @@ -4,6 +4,7 @@ module Dunlop::SourceFileModel if attachment.persisted? {} else + # This strategy fails when the original_file of a model is changed. But is for here no usecase {'Content-Disposition' => %|attachment; filename="#{attachment.pre_set_original_file&.original_filename.presence || attachment.class.name + Time.now.getutc.iso8601}"|} end end @@ -31,6 +32,7 @@ module Dunlop::SourceFileModel event(:failed) { transition any => :failed } end + after_create { autoload! } end def deactivate_loaded_source_file @@ -213,10 +215,6 @@ module Dunlop::SourceFileModel end alias_method :load_scheduled!, :load_scheduled_source_files - def for_select - classes.map{|klass| [klass.model_name.human, klass.name]} - end - def has_panda_original_file(options = {}) environments = Array.wrap(options.delete(:environments)) || %w[production staging] if environments.include?(Rails.env)