From 2e989083bd190a24444e422353b4d25f102581be Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 7 Apr 2022 15:13:34 +1000 Subject: [PATCH] Remove unused icons from Spree:Taxon The icons are not used any more and the default icon file never existed in our code base (only in Spree when we depended on that). And it's better to remove this clutter before migrating those files to Active Storage. We are keeping the icon files in storage as a backup. The whole folder `/spree/taxons` can be deleted when desired. But storage is cheap. --- app/models/spree/taxon.rb | 11 ----------- app/views/spree/admin/taxonomies/_taxon.html.haml | 2 +- .../20220407051248_remove_icon_from_spree_taxons.rb | 8 ++++++++ db/schema.rb | 6 +----- 4 files changed, 10 insertions(+), 17 deletions(-) create mode 100644 db/migrate/20220407051248_remove_icon_from_spree_taxons.rb diff --git a/app/models/spree/taxon.rb b/app/models/spree/taxon.rb index 848c02f3ec..24b87584e7 100644 --- a/app/models/spree/taxon.rb +++ b/app/models/spree/taxon.rb @@ -2,8 +2,6 @@ module Spree class Taxon < ApplicationRecord - include Spree::Core::S3Support - acts_as_nested_set dependent: :destroy belongs_to :taxonomy, class_name: 'Spree::Taxonomy', touch: true @@ -14,15 +12,6 @@ module Spree validates :name, presence: true - has_attached_file :icon, - styles: { mini: '32x32>', normal: '128x128>' }, - default_style: :mini, - url: '/spree/taxons/:id/:style/:basename.:extension', - path: ':rails_root/public/spree/taxons/:id/:style/:basename.:extension', - default_url: '/assets/default_taxon.png' - - supports_s3 :icon - # Indicate which filters should be used for this taxon def applicable_filters [] diff --git a/app/views/spree/admin/taxonomies/_taxon.html.haml b/app/views/spree/admin/taxonomies/_taxon.html.haml index 6c5e5273b9..ce8fd21247 100644 --- a/app/views/spree/admin/taxonomies/_taxon.html.haml +++ b/app/views/spree/admin/taxonomies/_taxon.html.haml @@ -2,6 +2,6 @@ %ul - taxon.children.each do |child| %li{id: "#{child.id}", rel: "taxon"} - %a{href: "#", style: "background-image: url(#{child.icon.url});"}= child.name + %a{href: "#"}= child.name - if child.children.length > 0 = render partial: 'taxon', locals: { taxon: child } diff --git a/db/migrate/20220407051248_remove_icon_from_spree_taxons.rb b/db/migrate/20220407051248_remove_icon_from_spree_taxons.rb new file mode 100644 index 0000000000..6f18fb96cf --- /dev/null +++ b/db/migrate/20220407051248_remove_icon_from_spree_taxons.rb @@ -0,0 +1,8 @@ +class RemoveIconFromSpreeTaxons < ActiveRecord::Migration[6.1] + def change + remove_column :spree_taxons, :icon_file_name, :string + remove_column :spree_taxons, :icon_content_type, :string + remove_column :spree_taxons, :icon_file_size, :integer + remove_column :spree_taxons, :icon_updated_at, :datetime + end +end diff --git a/db/schema.rb b/db/schema.rb index 49efdfd456..dbd9b1b3cf 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2022_02_21_165207) do +ActiveRecord::Schema.define(version: 2022_04_07_051248) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -976,10 +976,6 @@ ActiveRecord::Schema.define(version: 2022_02_21_165207) do t.datetime "updated_at", null: false t.integer "lft" t.integer "rgt" - t.string "icon_file_name", limit: 255 - t.string "icon_content_type", limit: 255 - t.integer "icon_file_size" - t.datetime "icon_updated_at" t.text "description" t.string "meta_title", limit: 255 t.string "meta_description", limit: 255