Merge branch 'master' of ssh://51.254.143.84:9319/home/git/pdfshop
This commit is contained in:
commit
2b5a52923b
5
Gemfile
5
Gemfile
|
|
@ -19,7 +19,7 @@ gem 'sass-rails', '~> 5.0'
|
|||
gem 'uglifier', '>= 1.3.0'
|
||||
# See https://github.com/rails/execjs#readme for more supported runtimes
|
||||
# gem 'therubyracer', platforms: :ruby
|
||||
gem 'bcrypt', platforms: :ruby
|
||||
gem 'bcrypt', '3.1.11', platforms: :ruby
|
||||
gem 'breadcrumbs_on_rails'
|
||||
gem 'devise'
|
||||
gem 'paperclip'
|
||||
|
|
@ -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
|
||||
|
|
@ -66,3 +68,4 @@ end
|
|||
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
|
||||
|
||||
gem 'kaminari', '1.1.1'
|
||||
gem 'geocoder'
|
||||
|
|
|
|||
|
|
@ -12,3 +12,7 @@
|
|||
//
|
||||
//= require rails-ujs
|
||||
// require turbolinks
|
||||
|
||||
function closeDiv(div_id) {
|
||||
$(div_id).html("");
|
||||
};
|
||||
|
|
|
|||
|
|
@ -26,12 +26,15 @@ class CheckoutController < ShopController
|
|||
|
||||
def end_order
|
||||
if !@cart.blank? && !@order.blank?
|
||||
if RecaptchaVerifier.verify(params['g-recaptcha-response'], request.ip)
|
||||
if @ss.recaptcha_chk.eql?(false) || (@ss.recaptcha_chk.eql?(true) && RecaptchaVerifier.verify(params['g-recaptcha-response'], request.ip))
|
||||
if @order.update_attributes(order_params)
|
||||
@order.status = 1
|
||||
# kopiujemy wszystkie produkty z koszyka i odejmujemy od ilosci
|
||||
# z rezerwacji jesli jest taka potrzeba
|
||||
copy_cart_prod_to_order(@cart, @order)
|
||||
orders_max_number = Order.where('order_number IS NOT NULL')
|
||||
.order('order_number DESC').first
|
||||
@order.order_number = orders_max_number.order_number + 1
|
||||
@order.save
|
||||
# usunac ciasteczko z koszykiem jesli wszystko sie udalo
|
||||
delete_cookies_for_cart
|
||||
|
|
|
|||
|
|
@ -80,10 +80,14 @@ 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 = 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
|
||||
@product = Product.where(id: params[:product_id]).first
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
# App Mailer
|
||||
class ApplicationMailer < ActionMailer::Base
|
||||
default from: 'Kaktusiarnia <kaktusiarnia.rumia@gmail.com>'
|
||||
default from: 'Kaktusiarnia <kaktusiarnia.rumia@gmail.com>',
|
||||
reply_to: 'kaktusiarnia@kaktusiarnia.pl'
|
||||
layout 'mailer'
|
||||
end
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ class OrderMailer < ApplicationMailer
|
|||
sleep(5) #to make sure pdf file saved on the disk
|
||||
mail(subject: "Nowe zamówienie nr: #{@order.beauty_id}",
|
||||
from: "#{ss.shop_name} <kaktusiarnia.rumia@gmail.com>",
|
||||
to: ss.shop_owners_emails)
|
||||
to: ss.shop_owners_emails,
|
||||
reply_to: @order.email)
|
||||
end
|
||||
|
||||
def status_change(order)
|
||||
|
|
|
|||
|
|
@ -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) }
|
||||
|
|
|
|||
|
|
@ -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 => '<span class="badge bg-maroon">Oczekuje na płatność</span>',
|
||||
4 => '<span class="badge bg-light-blue">Zapłacone</span>',
|
||||
5 => '<span class="badge bg-fuchsia">Wysłane</span>',
|
||||
6 => '<span class="badge bg-navy">Zakończone</span>'
|
||||
6 => '<span class="badge bg-navy">Zakończone</span>',
|
||||
7 => '<span class="badge bg-orange-active">Anulowane</span>'
|
||||
}.freeze
|
||||
|
||||
def order_summary
|
||||
|
|
@ -50,7 +52,11 @@ class Order < ApplicationRecord
|
|||
end
|
||||
|
||||
def beauty_id
|
||||
id.to_s.rjust(8, '0')
|
||||
if order_number.nil?
|
||||
'---------'
|
||||
else
|
||||
order_number.to_s.rjust(8, '0')
|
||||
end
|
||||
end
|
||||
|
||||
def date_checkout
|
||||
|
|
@ -74,7 +80,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
|
||||
|
|
|
|||
|
|
@ -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) }
|
||||
|
|
|
|||
|
|
@ -11,9 +11,11 @@
|
|||
</div>
|
||||
</div>
|
||||
<% else %>
|
||||
<% if @ss.recaptcha_chk.eql?(true) %>
|
||||
<% content_for :header_scripts do %>
|
||||
<script src='https://www.google.com/recaptcha/api.js?onload=onRecaptchaElementLoad&render=explicit' async="async" defer="defer"></script>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div id="error"></div>
|
||||
|
|
@ -84,7 +86,9 @@
|
|||
</div>
|
||||
<!-- end row -->
|
||||
<%= 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');
|
||||
|
|
|
|||
|
|
@ -40,10 +40,12 @@
|
|||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<% if @ss.recaptcha_chk.eql?(true) %>
|
||||
<h5 class="thin subtitle">Potwierdź, że nie jesteś robotem</h5>
|
||||
<div class="form-group">
|
||||
<div id="recaptcha"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="form-group">
|
||||
<%= raw submit_tag(raw('Potwierdzam zamówienie'), class: "btn btn-default btn-md round pull-right") %>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@
|
|||
<tr>
|
||||
<td style="padding:0.5em 0 0.5em 0.5em; background-color:#EBECEE;">
|
||||
<span style="color:#0cd4d2; font-weight:bold;"><%= @order.full_name %></span><br>
|
||||
<span style="color:#0cd4d2; font-weight:bold;"><%= @order.email %></span><br>
|
||||
<%= raw @order.address.gsub(/(\r\n|\n\r|\r|\n)/, '<br \>') %>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ order_arr << [{:value => 'Razem do zapłaty', :colspan => 3, :align => :right},
|
|||
Adres dostawy
|
||||
|
||||
<%= @order.full_name %>
|
||||
<%= @order.email %>
|
||||
|
||||
<%= @order.address %>
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
<% end %>
|
||||
</td>
|
||||
<td style="text-align:center; vertical-align:middle;">
|
||||
<%= image_tag image.image.url(:medium) %>
|
||||
<%= link_to image_tag(image.image.url(:medium)), image.image.url(:original), target: '_blank' %>
|
||||
</td>
|
||||
<td style="text-align:center; vertical-align:middle;"><%= raw image.cover.eql?(true) ? '<h4><i class="fa fa-check text-green"></i></h4>' : link_to(raw('<h4><i class="fa fa-close text-red"></i></h4>'), {controller: '/ps_admin/image', action: 'set_cover', id: image.id, product_id: @product.id, cover: 1}, remote: true) %></td>
|
||||
<td style="text-align:center; vertical-align:middle;"><%= raw image.active.eql?(true) ? link_to(raw('<h4><i class="fa fa-eye text-green"></i></h4>'), {controller: '/ps_admin/image', action: 'set_active', id: image.id, product_id: @product.id, active: 0}, remote: true) : link_to(raw('<h4><i class="fa fa-eye-slash text-red"></i></h4>'), {controller: '/ps_admin/image', action: 'set_active', id: image.id, product_id: @product.id, active: 1}, remote: true) %></td>
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<%= link_to 'Zamknij', '#', class: 'btn btn-success', onclick: 'closeForm()' %>
|
||||
<%= link_to 'Zamknij', '#', class: 'btn btn-success', onclick: 'closeDiv("#products_form")' %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -7,4 +7,4 @@ test:
|
|||
production:
|
||||
adapter: redis
|
||||
url: redis://localhost:6379/1
|
||||
channel_prefix: SimpleCrm_production
|
||||
channel_prefix: PdfShop_production
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "SimpleCrm",
|
||||
"name": "PdfShop",
|
||||
"private": true,
|
||||
"dependencies": {}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue