Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
[EN-499] Adds uploading of mailer logo to store form
Robert Nowakowski3a4acaa8b769
diff --git a/backend/app/views/spree/admin/stores/_form.html.erb b/backend/app/views/spree/admin/stores/_form.html.erbindex e00bc0304b..ea02284156 100644--- a/backend/app/views/spree/admin/stores/_form.html.erb+++ b/backend/app/views/spree/admin/stores/_form.html.erb@@ -19,6 +19,16 @@<%= f.error_message_on :logo %><% end %><% end %>+ <%= f.field_container :mailer_logo, class: ['form-group'] do %>+ <% if @store.mailer_logo.attached? %>+ <%= image_tag main_app.url_for(@store.mailer_logo.variant(resize: '244x104>')) %>+ <% end %>+ <%= f.field_container :mailer_logo, class: ['form-group'] do %>+ <%= f.label :mailer_logo, Spree.t(:mailer_logo) %><br />+ <%= f.file_field :mailer_logo, accept: 'image/png, image/jpeg' %>+ <%= f.error_message_on :mailer_logo %>+ <% end %>+ <% end %><%= f.field_container :name, class: ['form-group'] do %><%= f.label :name, raw(Spree.t(:name) + required_span_tag) %><%= f.text_field :name, class: 'form-control', required: true %>diff --git a/core/app/helpers/spree/mail_helper.rb b/core/app/helpers/spree/mail_helper.rbindex 4293404560..02333a5c7c 100644--- a/core/app/helpers/spree/mail_helper.rb+++ b/core/app/helpers/spree/mail_helper.rb@@ -12,7 +12,7 @@ module Spreeenddef store_logo- @order&.store&.logo || current_store.logo+ @order&.store&.mailer_logo || @order&.store&.logo || current_store.mailer_logo || current_store.logoenddef default_logodiff --git a/core/app/models/spree/store.rb b/core/app/models/spree/store.rbindex b2afab1ce3..6f81fde862 100644--- a/core/app/models/spree/store.rb+++ b/core/app/models/spree/store.rb@@ -18,6 +18,7 @@ module Spreeendhas_one_attached :logo+ has_one_attached :mailer_logobefore_save :ensure_default_exists_and_is_uniquebefore_destroy :validate_not_defaultdiff --git a/core/config/locales/en.yml b/core/config/locales/en.ymlindex d29feaaba3..001c499d9b 100644--- a/core/config/locales/en.yml+++ b/core/config/locales/en.yml@@ -1036,6 +1036,7 @@ en:make_refund: Make refundmake_sure_the_above_reimbursement_amount_is_correct: Make sure the above reimbursement amount is correctmail_from_address: Mail from address+ mailer_logo: Mailer logo (JPG or PNG images only)manage_promotion_categories: Manage Promotion Categoriesmanual_intervention_required: Manual intervention requiredmanage_variants: Manage Variantsdiff --git a/core/lib/spree/permitted_attributes.rb b/core/lib/spree/permitted_attributes.rbindex 8bbb12db25..63855a98a6 100644--- a/core/lib/spree/permitted_attributes.rb+++ b/core/lib/spree/permitted_attributes.rb@@ -101,7 +101,7 @@ module Spree:customer_support_email, :facebook, :twitter, :instagram,:description, :address, :contact_email, :contact_phone,:default_locale, :default_country_id, :supported_currencies,- :new_order_notifications_email]+ :new_order_notifications_email, :mailer_logo]@@store_credit_attributes = %i[amount currency category_id memo]diff --git a/core/spec/helpers/mail_helper_spec.rb b/core/spec/helpers/mail_helper_spec.rbindex b0d9bb96a8..d9f1a22e8c 100644--- a/core/spec/helpers/mail_helper_spec.rb+++ b/core/spec/helpers/mail_helper_spec.rb@@ -67,12 +67,12 @@ module Spreelet(:logo_image) { File.open(File.expand_path('../../app/assets/images/logo/spree_50.png', __dir__)) }before do- store.logo.attach(io: logo_image, filename: 'spree_50.png', content_type: 'image/png')+ store.mailer_logo.attach(io: logo_image, filename: 'spree_50.png', content_type: 'image/png')@order = create(:order, store: store)endit 'shows logo attached to orders store' do- expect(subject).to include(store.logo.attachment.filename.to_s)+ expect(subject).to include(store.mailer_logo.attachment.filename.to_s)endend@@ -80,11 +80,11 @@ module Spreelet(:logo_image) { File.open(File.expand_path('../../app/assets/images/noimage/mini.png', __dir__)) }before do- store.logo.attach(io: logo_image, filename: 'mini.png', content_type: 'image/png')+ store.mailer_logo.attach(io: logo_image, filename: 'mini.png', content_type: 'image/png')endit 'shows logo attached to current store' do- expect(subject).to include(store.logo.attachment.filename.to_s)+ expect(subject).to include(store.mailer_logo.attachment.filename.to_s)endendend