Merge branch 'master' of ssh://51.254.143.84:9319/home/git/pdfshop

This commit is contained in:
Adrian Hinz 2018-06-02 09:28:11 +02:00
commit 2b5a52923b
21 changed files with 62 additions and 23 deletions

View File

@ -19,7 +19,7 @@ gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0' gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes # See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby # gem 'therubyracer', platforms: :ruby
gem 'bcrypt', platforms: :ruby gem 'bcrypt', '3.1.11', platforms: :ruby
gem 'breadcrumbs_on_rails' gem 'breadcrumbs_on_rails'
gem 'devise' gem 'devise'
gem 'paperclip' gem 'paperclip'
@ -42,6 +42,8 @@ gem 'acts_as_tree'
# Use Capistrano for deployment # Use Capistrano for deployment
# gem 'capistrano-rails', group: :development # gem 'capistrano-rails', group: :development
gem 'draper'
group :development, :test do group :development, :test do
# Call 'byebug' anywhere in the code to # Call 'byebug' anywhere in the code to
# stop execution and get a debugger console # stop execution and get a debugger console
@ -66,3 +68,4 @@ end
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby] gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
gem 'kaminari', '1.1.1' gem 'kaminari', '1.1.1'
gem 'geocoder'

View File

@ -12,3 +12,7 @@
// //
//= require rails-ujs //= require rails-ujs
// require turbolinks // require turbolinks
function closeDiv(div_id) {
$(div_id).html("");
};

View File

@ -26,12 +26,15 @@ class CheckoutController < ShopController
def end_order def end_order
if !@cart.blank? && !@order.blank? 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) if @order.update_attributes(order_params)
@order.status = 1 @order.status = 1
# kopiujemy wszystkie produkty z koszyka i odejmujemy od ilosci # kopiujemy wszystkie produkty z koszyka i odejmujemy od ilosci
# z rezerwacji jesli jest taka potrzeba # z rezerwacji jesli jest taka potrzeba
copy_cart_prod_to_order(@cart, @order) 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 @order.save
# usunac ciasteczko z koszykiem jesli wszystko sie udalo # usunac ciasteczko z koszykiem jesli wszystko sie udalo
delete_cookies_for_cart delete_cookies_for_cart

View File

@ -80,9 +80,13 @@ module PsAdmin
image = Image.where(id: params[:id]).first image = Image.where(id: params[:id]).first
unless image.blank? unless image.blank?
if image.cover.eql?(true) 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)
img.cover = true .where('imageable_id = ? AND id != ?',
img.save image.imageable_id, image.id).first
unless img.blank?
img.cover = true
img.save
end
end end
image.destroy image.destroy
end end

View File

@ -9,8 +9,8 @@ module PsAdmin
end end
def show def show
otp = OrderToPdf.new(@order).call #otp = OrderToPdf.new(@order).call
puts "#{otp.inspect}" #puts "#{otp.inspect}"
end end
def destroy def destroy

View File

@ -4,6 +4,7 @@ class ShopController < ApplicationController
include PageContent include PageContent
def set_settings def set_settings
Rails.logger.error request.location.country_code
@ss = ScSetting.first @ss = ScSetting.first
redirect_to '/closed.html' if @ss.shop_active.eql?(false) redirect_to '/closed.html' if @ss.shop_active.eql?(false)
end end

View File

@ -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

View File

@ -1,5 +1,6 @@
# App Mailer # App Mailer
class ApplicationMailer < ActionMailer::Base 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' layout 'mailer'
end end

View File

@ -17,7 +17,8 @@ class OrderMailer < ApplicationMailer
sleep(5) #to make sure pdf file saved on the disk sleep(5) #to make sure pdf file saved on the disk
mail(subject: "Nowe zamówienie nr: #{@order.beauty_id}", mail(subject: "Nowe zamówienie nr: #{@order.beauty_id}",
from: "#{ss.shop_name} <kaktusiarnia.rumia@gmail.com>", from: "#{ss.shop_name} <kaktusiarnia.rumia@gmail.com>",
to: ss.shop_owners_emails) to: ss.shop_owners_emails,
reply_to: @order.email)
end end
def status_change(order) def status_change(order)

View File

@ -14,7 +14,7 @@ class Image < ApplicationRecord
} }
# before_post_process :rename_file # before_post_process :rename_file
validates_attachment_content_type :image, content_type: /\Aimage/ 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 do_not_validate_attachment_file_type :image
scope :by_image_type, ->(type) { where(imageable_type: type) } scope :by_image_type, ->(type) { where(imageable_type: type) }
scope :by_position_desc, -> { order(position: :desc) } scope :by_position_desc, -> { order(position: :desc) }

View File

@ -28,7 +28,8 @@ class Order < ApplicationRecord
3 => 'Oczekuje na płatność', 3 => 'Oczekuje na płatność',
4 => 'Zapłacone', 4 => 'Zapłacone',
5 => 'Wysłane', 5 => 'Wysłane',
6 => 'Zakończone' 6 => 'Zakończone',
7 => 'Anulowane'
}.freeze }.freeze
ORDER_STATUSES_HTML = { ORDER_STATUSES_HTML = {
@ -38,7 +39,8 @@ class Order < ApplicationRecord
3 => '<span class="badge bg-maroon">Oczekuje na płatność</span>', 3 => '<span class="badge bg-maroon">Oczekuje na płatność</span>',
4 => '<span class="badge bg-light-blue">Zapłacone</span>', 4 => '<span class="badge bg-light-blue">Zapłacone</span>',
5 => '<span class="badge bg-fuchsia">Wysłane</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 }.freeze
def order_summary def order_summary
@ -50,7 +52,11 @@ class Order < ApplicationRecord
end end
def beauty_id def beauty_id
id.to_s.rjust(8, '0') if order_number.nil?
'---------'
else
order_number.to_s.rjust(8, '0')
end
end end
def date_checkout def date_checkout
@ -74,7 +80,7 @@ class Order < ApplicationRecord
end end
def address def address
"#{street}\n#{zip_code} #{city}\n\n#{phone}" "#{street}\n#{zip_code} #{city}\n\ntel: #{phone}"
end end
def order_value def order_value

View File

@ -1,4 +1,4 @@
# historia statusow zamowien # Order change status history
class OrderHistory < ApplicationRecord class OrderHistory < ApplicationRecord
belongs_to :order belongs_to :order
scope :by_create_desc, -> { order(created_at: :desc) } scope :by_create_desc, -> { order(created_at: :desc) }

View File

@ -11,8 +11,10 @@
</div> </div>
</div> </div>
<% else %> <% else %>
<% content_for :header_scripts do %> <% if @ss.recaptcha_chk.eql?(true) %>
<script src='https://www.google.com/recaptcha/api.js?onload=onRecaptchaElementLoad&render=explicit' async="async" defer="defer"></script> <% 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 %> <% end %>
<div class="row"> <div class="row">
<div class="col-sm-12"> <div class="col-sm-12">
@ -84,7 +86,9 @@
</div> </div>
<!-- end row --> <!-- end row -->
<%= javascript_tag do %> <%= javascript_tag do %>
<% if @ss.recaptcha_chk.eql?(true) %>
var onRecaptchaElementLoad = function() { grecaptcha.render('recaptcha', { 'sitekey' : '<%= j ENV["REACAPTCHA_SITE_KEY"]%>', 'hl': 'pl' }); }; var onRecaptchaElementLoad = function() { grecaptcha.render('recaptcha', { 'sitekey' : '<%= j ENV["REACAPTCHA_SITE_KEY"]%>', 'hl': 'pl' }); };
<% end %>
$('#changetabbutton1').click(function(e){ $('#changetabbutton1').click(function(e){
e.preventDefault(); e.preventDefault();
$('#checkout_tabs a[href="#billing-info"]').tab('show'); $('#checkout_tabs a[href="#billing-info"]').tab('show');

View File

@ -40,10 +40,12 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<% if @ss.recaptcha_chk.eql?(true) %>
<h5 class="thin subtitle">Potwierdź, że nie jesteś robotem</h5> <h5 class="thin subtitle">Potwierdź, że nie jesteś robotem</h5>
<div class="form-group"> <div class="form-group">
<div id="recaptcha"></div> <div id="recaptcha"></div>
</div> </div>
<% end %>
<div class="form-group"> <div class="form-group">
<%= raw submit_tag(raw('Potwierdzam zamówienie'), class: "btn btn-default btn-md round pull-right") %> <%= raw submit_tag(raw('Potwierdzam zamówienie'), class: "btn btn-default btn-md round pull-right") %>
</div> </div>

View File

@ -80,6 +80,7 @@
<tr> <tr>
<td style="padding:0.5em 0 0.5em 0.5em; background-color:#EBECEE;"> <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.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 \>') %> <%= raw @order.address.gsub(/(\r\n|\n\r|\r|\n)/, '<br \>') %>
</td> </td>
</tr> </tr>

View File

@ -20,6 +20,7 @@ order_arr << [{:value => 'Razem do zapłaty', :colspan => 3, :align => :right},
Adres dostawy Adres dostawy
<%= @order.full_name %> <%= @order.full_name %>
<%= @order.email %>
<%= @order.address %> <%= @order.address %>

View File

@ -28,7 +28,7 @@
<% end %> <% end %>
</td> </td>
<td style="text-align:center; vertical-align:middle;"> <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>
<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.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> <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>

View File

@ -49,7 +49,7 @@
</div> </div>
</div> </div>
<div class="box-footer"> <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> </div>
</div> </div>
@ -58,7 +58,7 @@
<%= javascript_include_tag 'bootstrap-editable' %> <%= javascript_include_tag 'bootstrap-editable' %>
<script> <script>
$.fn.editable.defaults.mode = 'popup'; $.fn.editable.defaults.mode = 'popup';
$(document).ready(function () { $(document).ready(function () {
$('.xedit').editable({ $('.xedit').editable({
success: function (response, newValue) { success: function (response, newValue) {
if (!response.success) if (!response.success)

View File

@ -7,4 +7,4 @@ test:
production: production:
adapter: redis adapter: redis
url: redis://localhost:6379/1 url: redis://localhost:6379/1
channel_prefix: SimpleCrm_production channel_prefix: PdfShop_production

View File

@ -72,7 +72,7 @@ Rails.application.configure do
# Use a real queuing backend for Active Job (and separate queues per environment) # Use a real queuing backend for Active Job (and separate queues per environment)
# config.active_job.queue_adapter = :resque # 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 config.action_mailer.perform_caching = false
# Ignore bad email addresses and do not raise email delivery errors. # Ignore bad email addresses and do not raise email delivery errors.

View File

@ -1,5 +1,5 @@
{ {
"name": "SimpleCrm", "name": "PdfShop",
"private": true, "private": true,
"dependencies": {} "dependencies": {}
} }