From 73e8a8b4ed960d5d4219164350706bd6cc5a7cd3 Mon Sep 17 00:00:00 2001 From: Mini Robot Date: Sun, 22 Apr 2018 10:54:46 +0200 Subject: [PATCH 01/14] fixed image extensions to fit capital leters --- app/models/image.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/image.rb b/app/models/image.rb index 577e6c2..66857a5 100644 --- a/app/models/image.rb +++ b/app/models/image.rb @@ -14,7 +14,7 @@ class Image < ApplicationRecord } # before_post_process :rename_file validates_attachment_content_type :image, content_type: /\Aimage/ - validates_attachment_file_name :image, matches: [/png\z/, /jpe?g\z/] + validates_attachment_file_name :image, matches: [/png\z/, /jpe?g\z/, /PNG\z/, /JPE?G\z/] do_not_validate_attachment_file_type :image scope :by_image_type, ->(type) { where(imageable_type: type) } scope :by_position_desc, -> { order(position: :desc) } From 604fede5a780832c334881dc603c685d2f34162e Mon Sep 17 00:00:00 2001 From: Adrian Hinz Date: Mon, 23 Apr 2018 08:19:50 +0200 Subject: [PATCH 02/14] fix for image destroy --- app/controllers/ps_admin/image_controller.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/controllers/ps_admin/image_controller.rb b/app/controllers/ps_admin/image_controller.rb index db42e86..894f044 100644 --- a/app/controllers/ps_admin/image_controller.rb +++ b/app/controllers/ps_admin/image_controller.rb @@ -80,9 +80,13 @@ module PsAdmin image = Image.where(id: params[:id]).first unless image.blank? if image.cover.eql?(true) - img = Image.where('imageable_type = ? AND imageable_id = ? AND id != ?', image.imageable_type, image.imageable_id, image.id).first - img.cover = true - img.save + img = Image.by_image_type(image.imageable_type) + .where('imageable_id = ? AND id != ?', + image.imageable_id, image.id).first + unless img.blank? + img.cover = true + img.save + end end image.destroy end From 2a5da1f6ed4a869704af15a1d7636a254bd3242b Mon Sep 17 00:00:00 2001 From: Adrian Hinz Date: Mon, 23 Apr 2018 10:32:27 +0200 Subject: [PATCH 03/14] added default reply_to address --- app/mailers/application_mailer.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 6a4f3b0..5ff92a4 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,5 +1,6 @@ # App Mailer class ApplicationMailer < ActionMailer::Base - default from: 'Kaktusiarnia ' + default from: 'Kaktusiarnia ', + reply_to: 'kaktusiarnia@kaktusiarnia.pl' layout 'mailer' end From 69d65ad96a40d9852a59713b86edfe0c53fc9764 Mon Sep 17 00:00:00 2001 From: Adrian Hinz Date: Mon, 23 Apr 2018 10:56:00 +0200 Subject: [PATCH 04/14] added application_decorator --- Gemfile | 2 ++ app/decorators/application_decorator.rb | 8 ++++++++ 2 files changed, 10 insertions(+) create mode 100644 app/decorators/application_decorator.rb diff --git a/Gemfile b/Gemfile index 7c082d4..f13fdd1 100644 --- a/Gemfile +++ b/Gemfile @@ -42,6 +42,8 @@ gem 'acts_as_tree' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development +gem 'draper' + group :development, :test do # Call 'byebug' anywhere in the code to # stop execution and get a debugger console diff --git a/app/decorators/application_decorator.rb b/app/decorators/application_decorator.rb new file mode 100644 index 0000000..5caf08b --- /dev/null +++ b/app/decorators/application_decorator.rb @@ -0,0 +1,8 @@ +class ApplicationDecorator < Draper::Decorator + # Define methods for all decorated objects. + # Helpers are accessed through `helpers` (aka `h`). For example: + # + # def percent_amount + # h.number_to_percentage object.amount, precision: 2 + # end +end From a7a8c4721455a948093fd1d03069f1fe0ee5417f Mon Sep 17 00:00:00 2001 From: Adrian Hinz Date: Mon, 23 Apr 2018 10:58:11 +0200 Subject: [PATCH 05/14] change old project name --- config/cable.yml | 2 +- config/environments/production.rb | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/cable.yml b/config/cable.yml index 3797adc..77fdaa8 100644 --- a/config/cable.yml +++ b/config/cable.yml @@ -7,4 +7,4 @@ test: production: adapter: redis url: redis://localhost:6379/1 - channel_prefix: SimpleCrm_production + channel_prefix: PdfShop_production diff --git a/config/environments/production.rb b/config/environments/production.rb index d382344..6d140e1 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -72,7 +72,7 @@ Rails.application.configure do # Use a real queuing backend for Active Job (and separate queues per environment) # config.active_job.queue_adapter = :resque - # config.active_job.queue_name_prefix = "SimpleCrm_#{Rails.env}" + # config.active_job.queue_name_prefix = "PdfShop_#{Rails.env}" config.action_mailer.perform_caching = false # Ignore bad email addresses and do not raise email delivery errors. diff --git a/package.json b/package.json index a91bf9b..85a914c 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "SimpleCrm", + "name": "PdfShop", "private": true, "dependencies": {} } From ae3f5bfb8c508404b9834e7aad8f712357321766 Mon Sep 17 00:00:00 2001 From: Adrian Hinz Date: Mon, 23 Apr 2018 13:14:39 +0200 Subject: [PATCH 06/14] change comment to english --- app/models/order_history.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/order_history.rb b/app/models/order_history.rb index 24c36c1..53a7514 100644 --- a/app/models/order_history.rb +++ b/app/models/order_history.rb @@ -1,4 +1,4 @@ -# historia statusow zamowien +# Order change status history class OrderHistory < ApplicationRecord belongs_to :order scope :by_create_desc, -> { order(created_at: :desc) } From 7dd55dd28c81886d11414f847485ac8b6f88cc54 Mon Sep 17 00:00:00 2001 From: Adrian Hinz Date: Mon, 23 Apr 2018 14:40:10 +0200 Subject: [PATCH 07/14] added email to order and added reply_to client email --- app/mailers/order_mailer.rb | 3 ++- app/views/order_mailer/new_order_to_shop_owner.html.erb | 1 + app/views/order_mailer/new_order_to_shop_owner.text.erb | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/mailers/order_mailer.rb b/app/mailers/order_mailer.rb index 5819802..2f67aae 100644 --- a/app/mailers/order_mailer.rb +++ b/app/mailers/order_mailer.rb @@ -17,7 +17,8 @@ class OrderMailer < ApplicationMailer sleep(5) mail(subject: "Nowe zamówienie nr: #{@order.beauty_id}", from: "#{ss.shop_name} ", - to: ss.shop_owners_emails) + to: ss.shop_owners_emails, + reply_to: @order.email) end def status_change(order) diff --git a/app/views/order_mailer/new_order_to_shop_owner.html.erb b/app/views/order_mailer/new_order_to_shop_owner.html.erb index 4a8e384..8060c96 100644 --- a/app/views/order_mailer/new_order_to_shop_owner.html.erb +++ b/app/views/order_mailer/new_order_to_shop_owner.html.erb @@ -80,6 +80,7 @@ <%= @order.full_name %>
+ <%= @order.email %>
<%= raw @order.address.gsub(/(\r\n|\n\r|\r|\n)/, '
') %> diff --git a/app/views/order_mailer/new_order_to_shop_owner.text.erb b/app/views/order_mailer/new_order_to_shop_owner.text.erb index 2799266..eebc48f 100644 --- a/app/views/order_mailer/new_order_to_shop_owner.text.erb +++ b/app/views/order_mailer/new_order_to_shop_owner.text.erb @@ -20,6 +20,7 @@ order_arr << [{:value => 'Razem do zapłaty', :colspan => 3, :align => :right}, Adres dostawy <%= @order.full_name %> +<%= @order.email %> <%= @order.address %> From 31134e52c2ef7c00fc99cd0a4227ba38e52e1dd0 Mon Sep 17 00:00:00 2001 From: Adrian Hinz Date: Mon, 23 Apr 2018 14:40:54 +0200 Subject: [PATCH 08/14] fix for decorator --- app/models/order.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/order.rb b/app/models/order.rb index 7292001..35c34bb 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -74,7 +74,7 @@ class Order < ApplicationRecord end def address - "#{street}\n#{zip_code} #{city}\n\n#{phone}" + "#{street}\n#{zip_code} #{city}\n\ntel: #{phone}" end def order_value From d5285b82ff7a6aac87307b3af076b0c63573fb78 Mon Sep 17 00:00:00 2001 From: Adrian Hinz Date: Mon, 23 Apr 2018 15:18:51 +0200 Subject: [PATCH 09/14] added close div to product show in admin --- app/views/ps_admin/product/partials/_show.html.erb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/views/ps_admin/product/partials/_show.html.erb b/app/views/ps_admin/product/partials/_show.html.erb index 77e9eb1..e3e88b1 100644 --- a/app/views/ps_admin/product/partials/_show.html.erb +++ b/app/views/ps_admin/product/partials/_show.html.erb @@ -49,7 +49,7 @@ @@ -59,6 +59,9 @@ +<% if @ss.recaptcha_chk.eql?(true) %> + <% content_for :header_scripts do %> + + <% end %> <% end %>
@@ -84,7 +86,9 @@
<%= javascript_tag do %> +<% if @ss.recaptcha_chk.eql?(true) %> var onRecaptchaElementLoad = function() { grecaptcha.render('recaptcha', { 'sitekey' : '<%= j ENV["REACAPTCHA_SITE_KEY"]%>', 'hl': 'pl' }); }; +<% end %> $('#changetabbutton1').click(function(e){ e.preventDefault(); $('#checkout_tabs a[href="#billing-info"]').tab('show'); diff --git a/app/views/checkout/partials/_payment_methods.html.erb b/app/views/checkout/partials/_payment_methods.html.erb index a6dc1be..ed0ba61 100644 --- a/app/views/checkout/partials/_payment_methods.html.erb +++ b/app/views/checkout/partials/_payment_methods.html.erb @@ -40,10 +40,12 @@
+ <% if @ss.recaptcha_chk.eql?(true) %>
Potwierdź, że nie jesteś robotem
+ <% end %>
<%= raw submit_tag(raw('Potwierdzam zamówienie'), class: "btn btn-default btn-md round pull-right") %>
From 0b52c0dd9aa585d3805c323a8ea21a46a9eb6ba5 Mon Sep 17 00:00:00 2001 From: Adrian Hinz Date: Mon, 21 May 2018 12:04:16 +0200 Subject: [PATCH 13/14] added status to order --- app/controllers/ps_admin/order_controller.rb | 4 ++-- app/models/order.rb | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/ps_admin/order_controller.rb b/app/controllers/ps_admin/order_controller.rb index 21db86a..87b50ef 100644 --- a/app/controllers/ps_admin/order_controller.rb +++ b/app/controllers/ps_admin/order_controller.rb @@ -9,8 +9,8 @@ module PsAdmin end def show - otp = OrderToPdf.new(@order).call - puts "#{otp.inspect}" + #otp = OrderToPdf.new(@order).call + #puts "#{otp.inspect}" end def destroy diff --git a/app/models/order.rb b/app/models/order.rb index 4d27f7c..dba8f9e 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -28,7 +28,8 @@ class Order < ApplicationRecord 3 => 'Oczekuje na płatność', 4 => 'Zapłacone', 5 => 'Wysłane', - 6 => 'Zakończone' + 6 => 'Zakończone', + 7 => 'Anulowane' }.freeze ORDER_STATUSES_HTML = { @@ -38,7 +39,8 @@ class Order < ApplicationRecord 3 => 'Oczekuje na płatność', 4 => 'Zapłacone', 5 => 'Wysłane', - 6 => 'Zakończone' + 6 => 'Zakończone', + 7 => 'Anulowane' }.freeze def order_summary From 9945371a05492cbba215f4d251b08c1768c4221c Mon Sep 17 00:00:00 2001 From: Mini Robot Date: Fri, 1 Jun 2018 15:14:14 +0200 Subject: [PATCH 14/14] geolocation --- Gemfile | 1 + app/controllers/shop_controller.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/Gemfile b/Gemfile index 4c56d86..f36708e 100644 --- a/Gemfile +++ b/Gemfile @@ -68,3 +68,4 @@ end gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby] gem 'kaminari', '1.1.1' +gem 'geocoder' diff --git a/app/controllers/shop_controller.rb b/app/controllers/shop_controller.rb index ebefeff..f87cfab 100644 --- a/app/controllers/shop_controller.rb +++ b/app/controllers/shop_controller.rb @@ -4,6 +4,7 @@ class ShopController < ApplicationController include PageContent def set_settings + Rails.logger.error request.location.country_code @ss = ScSetting.first redirect_to '/closed.html' if @ss.shop_active.eql?(false) end