plaquette cabanes
7
Gemfile
@ -79,5 +79,12 @@ gem "twitter-bootstrap-rails"
|
||||
gem 'formtastic', "2.3.0"
|
||||
gem 'formtastic-bootstrap'
|
||||
|
||||
gem 'paypal-sdk-merchant'
|
||||
|
||||
|
||||
|
||||
gem 'wicked_pdf'
|
||||
gem "posix-spawn"
|
||||
|
||||
# Use debugger
|
||||
# gem 'debugger', group: [:development, :test]
|
||||
|
11
Gemfile.lock
@ -116,6 +116,11 @@ GEM
|
||||
mini_portile (~> 0.6.0)
|
||||
non-stupid-digest-assets (1.0.4)
|
||||
orm_adapter (0.5.0)
|
||||
paypal-sdk-core (0.3.1)
|
||||
multi_json (~> 1.0)
|
||||
xml-simple
|
||||
paypal-sdk-merchant (1.116.0)
|
||||
paypal-sdk-core (~> 0.3.0)
|
||||
posix-spawn (0.3.9)
|
||||
pygments.rb (0.6.0)
|
||||
posix-spawn (~> 0.3.6)
|
||||
@ -191,6 +196,9 @@ GEM
|
||||
raindrops (~> 0.7)
|
||||
warden (1.2.3)
|
||||
rack (>= 1.0)
|
||||
wicked_pdf (0.11.0)
|
||||
rails
|
||||
xml-simple (1.1.4)
|
||||
yajl-ruby (1.1.0)
|
||||
|
||||
PLATFORMS
|
||||
@ -219,6 +227,8 @@ DEPENDENCIES
|
||||
net-ssh (~> 2.7.0)
|
||||
nokogiri
|
||||
non-stupid-digest-assets
|
||||
paypal-sdk-merchant
|
||||
posix-spawn
|
||||
pygments.rb
|
||||
rails (= 4.0.12)
|
||||
redcarpet
|
||||
@ -231,3 +241,4 @@ DEPENDENCIES
|
||||
twitter-bootstrap-rails
|
||||
uglifier (>= 1.3.0)
|
||||
unicorn (= 4.6.3)
|
||||
wicked_pdf
|
||||
|
@ -1,8 +1,19 @@
|
||||
|
||||
@import "bootstrap";
|
||||
@import "jquery.bxslider";
|
||||
|
||||
@import "fontawesome/font-awesome";
|
||||
|
||||
|
||||
.observer-et-photographier-la-faune-sans-deranger{
|
||||
.couv{
|
||||
|
||||
float:left;
|
||||
width:300px;
|
||||
margin-right:10px;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
iframe{
|
||||
margin:auto;
|
||||
width:100%;
|
||||
|
103
app/controllers/admin/orders_controller.rb
Normal file
@ -0,0 +1,103 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
class Admin::OrdersController < ApplicationController
|
||||
layout "admin"
|
||||
|
||||
before_filter :auth_admin
|
||||
|
||||
|
||||
def index
|
||||
|
||||
|
||||
@orders = Order.order("created_at DESC")
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
def new
|
||||
|
||||
@order = Order.new(:paid_at => Date.today)
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
def edit
|
||||
@order = Order.find(params[:id])
|
||||
|
||||
end
|
||||
|
||||
def show
|
||||
@order = Order.find(params[:id])
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
@order = Order.new(order_params)
|
||||
|
||||
|
||||
if @order.save
|
||||
|
||||
@order.order_products << OrderProduct.new(:name => "Observer et photographier la faune sans déranger", :description => "desc", :price => 10.0, :slug => "observer-et-photographier-la-faune-sans-deranger")
|
||||
@order.save
|
||||
|
||||
|
||||
EbookMailer.confirm(@order.email, public_order_url(:id => @order.token)).deliver
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
else
|
||||
render :action => "new"
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@order = Order.find(params[:id])
|
||||
|
||||
|
||||
if @order.update_attributes(order_params)
|
||||
|
||||
else
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
def destroy
|
||||
@order = Order.find(params[:id])
|
||||
|
||||
@order.destroy
|
||||
flash[:notice] = "Le témoignage de "+@order.author.to_s+" a bien été supprimé."
|
||||
|
||||
|
||||
end
|
||||
|
||||
def resend
|
||||
@order = Order.find(params[:id])
|
||||
EbookMailer.resend(@order.email, public_order_url(:id => @order.token)).deliver
|
||||
redirect_to :back
|
||||
end
|
||||
|
||||
private
|
||||
def order_params
|
||||
params.require(:order).permit(:email, :name, :payment_type, :paid_at, :paid)
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
349
app/controllers/public/orders_controller.rb
Normal file
@ -0,0 +1,349 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
|
||||
class Public::OrdersController < ApplicationController
|
||||
|
||||
layout "ebook"
|
||||
skip_before_filter :verify_authenticity_token, :only => [:ipn]
|
||||
|
||||
def new
|
||||
@order = Order.new
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
@order = Order.new(params.require(:order).permit!)
|
||||
@order.order_products << OrderProduct.new(:name => "Observer et photographier la faune sans déranger", :description => "Exemplaire personnel", :price => 10.0, :slug => "observer-et-photographier-la-faune-sans-deranger")
|
||||
if @order.save
|
||||
respond_to do |format|
|
||||
format.html { redirect_to paid_by_paypal_public_order_path(@order.token)}
|
||||
|
||||
format.js { }
|
||||
end
|
||||
else
|
||||
render :action => :new
|
||||
end
|
||||
end
|
||||
|
||||
def download
|
||||
@order = Order.find_by_token(params[:id])
|
||||
|
||||
if @order and @order.paid
|
||||
if params[:file] == "pdf"
|
||||
@order.downloads_count = @order.downloads_count.to_i+1
|
||||
@order.save
|
||||
|
||||
|
||||
@temp_file = "#{Rails.root}/pdf/#{@order.token}_temp.pdf"
|
||||
@final_file = "#{Rails.root}/pdf/#{@order.token}.pdf"
|
||||
spacing = 5
|
||||
|
||||
pdf = WickedPdf.new.pdf_from_string("<br />",
|
||||
:no_background => true,
|
||||
:page_size => "A4",
|
||||
|
||||
:footer => {:spacing => 19, :content => "<html><body style='background:transparent;'><p style='text-align:right;font-family:arial;font-size:10px; color:#E2E4E6;'> Exemplaire personnel de #{@order.firstname} #{@order.name}</p></body></html>" },
|
||||
:margin => {
|
||||
:top => 0,
|
||||
:bottom => 30,
|
||||
:left =>20,
|
||||
:right => 13
|
||||
|
||||
}
|
||||
|
||||
|
||||
)
|
||||
|
||||
|
||||
File.open(@temp_file, 'wb') do |file|
|
||||
file << pdf
|
||||
end
|
||||
|
||||
|
||||
require 'posix/spawn'
|
||||
|
||||
|
||||
|
||||
child = ::POSIX::Spawn::Child.new 'pdftk', Rails.root.to_s+'/pdf/plaquette-cabane.pdf', 'background', @temp_file, 'output', @final_file
|
||||
|
||||
|
||||
@data_to_send = File.open( @final_file).read
|
||||
File.delete(@temp_file)
|
||||
File.delete(@final_file)
|
||||
# @data_to_send = File.open( @temp_file).read
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
send_data @data_to_send, :filename => "plaquette-cabane-#{@order.token}.pdf" , :type => 'application/pdf'
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def paid
|
||||
@order = Order.find_by_token(params[:id])
|
||||
if @order.paid
|
||||
redirect_to public_order_path(@order.token)
|
||||
else
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to paid_by_paypal_public_order_path(@order.token)}
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
def show
|
||||
@order = Order.find_by_token(params[:id])
|
||||
|
||||
|
||||
end
|
||||
def paid_by_paypal
|
||||
@order = Order.find_by_token(params[:id])
|
||||
if @order.paid
|
||||
redirect_to public_order_path(@order.token)
|
||||
end
|
||||
|
||||
products = []
|
||||
@order.order_products.each do |order_product|
|
||||
products << {:Name => order_product.name,:Quantity => 1,:Amount => {:currencyID => "EUR",:value => order_product.price } }
|
||||
end
|
||||
|
||||
require 'paypal-sdk-merchant'
|
||||
@api = PayPal::SDK::Merchant::API.new
|
||||
|
||||
|
||||
@set_express_checkout = @api.build_set_express_checkout({
|
||||
:SetExpressCheckoutRequestDetails => {
|
||||
:custom => @order.token,
|
||||
:ReturnURL => do_paypal_payment_public_order_url(@order),
|
||||
:CancelURL => paid_public_order_url(@order),
|
||||
:NoShipping => 1,
|
||||
:PaymentDetails => [{
|
||||
:OrderTotal => {
|
||||
:currencyID => "EUR",
|
||||
:value =>@order.total },
|
||||
|
||||
:NotifyURL => "http fdgdgf"+ipn_public_order_path(@order),
|
||||
:ShipToAddress => {
|
||||
:Name => @order.name+" "+@order.firstname.to_s,
|
||||
:Street1 => @order.street1,
|
||||
:Street2 => @order.street2,
|
||||
:CityName => @order.cityname,
|
||||
:StateOrProvince => "",
|
||||
:Country => @order.country,
|
||||
:PostalCode => @order.postal_code },
|
||||
:PaymentDetailsItem => products,
|
||||
:PaymentAction => "Sale" }] } })
|
||||
|
||||
# Make API call & get response
|
||||
@set_express_checkout_response = @api.set_express_checkout(@set_express_checkout)
|
||||
|
||||
# Access Response
|
||||
if @set_express_checkout_response.success?
|
||||
|
||||
@get_express_checkout_details = @api.build_get_express_checkout_details({
|
||||
:Token => @order.token })
|
||||
|
||||
@get_express_checkout_details_response = @api.get_express_checkout_details(@get_express_checkout_details)
|
||||
|
||||
|
||||
|
||||
|
||||
@payment_detail = @get_express_checkout_details_response.GetExpressCheckoutDetailsResponseDetails.PaymentDetails[0]
|
||||
|
||||
|
||||
redirect_to @api.express_checkout_url(@set_express_checkout_response.Token)
|
||||
else
|
||||
@set_express_checkout_response.Errors
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
def do_paypal_payment
|
||||
|
||||
|
||||
require 'paypal-sdk-merchant'
|
||||
@api = PayPal::SDK::Merchant::API.new
|
||||
|
||||
|
||||
@get_express_checkout_details = @api.build_get_express_checkout_details({:Token => params[:token] })
|
||||
|
||||
@get_express_checkout_details_response = @api.get_express_checkout_details(@get_express_checkout_details)
|
||||
|
||||
|
||||
|
||||
|
||||
# Access Response
|
||||
if @get_express_checkout_details_response.success?
|
||||
|
||||
@order = Order.find_by_token(@get_express_checkout_details_response.GetExpressCheckoutDetailsResponseDetails.Custom.to_s)
|
||||
|
||||
|
||||
|
||||
|
||||
else
|
||||
|
||||
|
||||
@get_express_checkout_details_response.Errors
|
||||
end
|
||||
|
||||
# Build request object
|
||||
@do_express_checkout_payment = @api.build_do_express_checkout_payment({
|
||||
:DoExpressCheckoutPaymentRequestDetails => {
|
||||
:PaymentAction => "Sale",
|
||||
:Token => params[:token],
|
||||
:PayerID => params[:PayerID],
|
||||
:PaymentDetails => [{
|
||||
:OrderTotal => {
|
||||
:currencyID => "EUR",
|
||||
:value => @order.total },
|
||||
:NotifyURL => "http:// "+ipn_public_order_path(@order) }] } })
|
||||
|
||||
# Make API call & get response
|
||||
@do_express_checkout_payment_response = @api.do_express_checkout_payment(@do_express_checkout_payment)
|
||||
|
||||
# Access Response
|
||||
if @do_express_checkout_payment_response.success?
|
||||
@payment_info = @do_express_checkout_payment_response.DoExpressCheckoutPaymentResponseDetails.PaymentInfo[0]
|
||||
|
||||
@do_express_checkout_payment_response.DoExpressCheckoutPaymentResponseDetails
|
||||
@do_express_checkout_payment_response.FMFDetails
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if @payment_info.PaymentStatus.to_s == "Completed"
|
||||
@order.payment_type = "1"
|
||||
@order.paid = true
|
||||
@order.paid_at = Time.now
|
||||
@order.save
|
||||
|
||||
EbookMailer.confirm(@order.email, public_order_url(:id => @order.token)).deliver
|
||||
|
||||
|
||||
redirect_to public_order_path(:id => @order.token, :download => true)
|
||||
else
|
||||
render :file => 'public/500.html', :status => 500, :layout => false
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
else
|
||||
render :file => 'public/500.html', :status => 500, :layout => false
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
def ipn
|
||||
|
||||
|
||||
@api = PayPal::SDK::Merchant.new
|
||||
if @api.ipn_valid?(request.raw_post) # return true or false
|
||||
@order = Order.find_by_token(params[:custom].to_s)
|
||||
if params[:payment_status] == "Completed"
|
||||
|
||||
|
||||
@order.payment_type= 1
|
||||
@order.paid = true
|
||||
@order.paid_at = Time.now
|
||||
|
||||
@order.paypal_test_ipn= params[:test_ipn]
|
||||
|
||||
@order.paypal_txn_type = params[:txn_type]
|
||||
@order.paypal_txn_id = params[:txn_id]
|
||||
@order.paypal_payment_date = params[:payment_date]
|
||||
|
||||
@order.paypal_payment_status = params[:payment_status]
|
||||
@order.paypal_reason_code = params[:reason_code]
|
||||
@order.paypal_payment_type = params[:payment_type]
|
||||
|
||||
@order.paypal_mc_currency = params[:mc_currency]
|
||||
@order.paypal_mc_fee = params[:mc_fee]
|
||||
@order.paypal_mc_gross = params[:mc_gross]
|
||||
|
||||
@order.paypal_residence_country = params[:residence_country]
|
||||
@order.paypal_last_name = params[:last_name]
|
||||
@order.paypal_first_name = params[:first_name]
|
||||
@order.paypal_payer_email = params[:payer_email]
|
||||
@order.paypal_payer_id = params[:payer_id]
|
||||
@order.paypal_payer_status = params[:payer_status]
|
||||
|
||||
@order.paypal_receiver_id = params[:receiver_id]
|
||||
@order.paypal_receiver_email = params[:receiver_email]
|
||||
|
||||
@order.paypal_protection_eligibility = params[:protection_eligibility]
|
||||
@order.paypal_ipn_track_id = params[:ipn_track_id]
|
||||
|
||||
@order.save
|
||||
puts "le paiement de la commande #{@order.id} par paypal est validé"
|
||||
|
||||
else
|
||||
@order.paypal_test_ipn= params[:test_ipn]
|
||||
|
||||
@order.paypal_txn_type = params[:txn_type]
|
||||
@order.paypal_txn_id = params[:txn_id]
|
||||
@order.paypal_payment_date = params[:payment_date]
|
||||
|
||||
@order.paypal_payment_status = params[:payment_status]
|
||||
@order.paypal_reason_code = params[:reason_code]
|
||||
@order.paypal_payment_type = params[:payment_type]
|
||||
|
||||
@order.paypal_mc_currency = params[:mc_currency]
|
||||
@order.paypal_mc_fee = params[:mc_fee]
|
||||
@order.paypal_mc_gross = params[:mc_gross]
|
||||
|
||||
@order.paypal_residence_country = params[:residence_country]
|
||||
@order.paypal_last_name = params[:last_name]
|
||||
@order.paypal_first_name = params[:first_name]
|
||||
@order.paypal_payer_email = params[:payer_email]
|
||||
@order.paypal_payer_id = params[:payer_id]
|
||||
@order.paypal_payer_status = params[:payer_status]
|
||||
|
||||
@order.paypal_receiver_id = params[:receiver_id]
|
||||
@order.paypal_receiver_email = params[:receiver_email]
|
||||
|
||||
@order.paypal_protection_eligibility = params[:protection_eligibility]
|
||||
@order.paypal_ipn_track_id = params[:ipn_track_id]
|
||||
@order.paid_at = nil
|
||||
@order.paid = false
|
||||
@order.save
|
||||
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
end
|
||||
render :inline => "test"
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
33
app/mailers/ebook_mailer.rb
Normal file
@ -0,0 +1,33 @@
|
||||
class EbookMailer < ActionMailer::Base
|
||||
layout 'mail'
|
||||
default from: "contact@lepicvert.asso.fr"
|
||||
|
||||
# Subject can be set in your I18n file at config/locales/en.yml
|
||||
# with the following lookup:
|
||||
#
|
||||
# en.question.deliver.subject
|
||||
#
|
||||
def confirm(mailto, link)
|
||||
@mailto = mailto
|
||||
@link = link
|
||||
|
||||
mail to: @mailto,:reply_to => "contact@lepicvert.asso.fr", :subject => "Observer et photographier la faune sans déranger"
|
||||
end
|
||||
|
||||
def resend(mailto, link)
|
||||
@mailto = mailto
|
||||
@link = link
|
||||
|
||||
mail to: @mailto,:reply_to => "contact@lepicvert.asso.fr", :subject => "Observer et photographier la faune sans déranger"
|
||||
end
|
||||
|
||||
|
||||
|
||||
def reset_password(user, options = {})
|
||||
@user = user
|
||||
@options = options
|
||||
mail(:to => user.email, :subject => "Réinitialisation de votre mot de passe.")
|
||||
end
|
||||
|
||||
|
||||
end
|
29
app/models/order.rb
Normal file
@ -0,0 +1,29 @@
|
||||
class Order < ActiveRecord::Base
|
||||
|
||||
validates :name, :presence => true
|
||||
|
||||
validates :email, :presence => true, :format => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
|
||||
has_many :order_products, :dependent => :destroy
|
||||
#validates :cgv,:acceptance => {:message => "Vous devez accepter les conditions générales de vente."}
|
||||
attr_accessor :cgv
|
||||
before_save do
|
||||
self.total = 0.0
|
||||
self.order_products.each do |order_product|
|
||||
|
||||
self.total = self.total + order_product.price.to_d
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
before_create do
|
||||
self.generate_token
|
||||
end
|
||||
|
||||
def generate_token
|
||||
begin
|
||||
self[:token] = SecureRandom.urlsafe_base64
|
||||
end while Order.exists?(:token => self[token])
|
||||
end
|
||||
|
||||
|
||||
end
|
2
app/models/order_product.rb
Normal file
@ -0,0 +1,2 @@
|
||||
class OrderProduct < ActiveRecord::Base
|
||||
end
|
12
app/views/admin/orders/_form.html.haml
Normal file
@ -0,0 +1,12 @@
|
||||
= semantic_form_for [:admin,@order], :remote => true do |form|
|
||||
.content
|
||||
= form.inputs do
|
||||
= form.input :name, :label => "Prénom / nom :"
|
||||
= form.input :email, :label => "Email :"
|
||||
= form.input :payment_type, :label => "Type de paiement : ", :collection => {"Paypal" => "1", "Offert" => "2", "Chèque" => "3"}, :include_blank => false
|
||||
= form.input :paid_at, :label => "Date de paiement :", :as => :qi_date_picker
|
||||
=form.input :paid, :label => "Payé ?"
|
||||
|
||||
|
||||
.actions
|
||||
= form.submit "Sauvegarder", :class => "btn btn-primary"
|
12
app/views/admin/orders/_new_form.html.haml
Normal file
@ -0,0 +1,12 @@
|
||||
= semantic_form_for [:admin,@order], :remote => true do |form|
|
||||
.content
|
||||
= form.inputs do
|
||||
= form.input :name, :label => "Prénom / nom :"
|
||||
= form.input :email, :label => "Email :"
|
||||
= form.input :payment_type, :label => "Type de paiement : ", :collection => {"Paypal" => "1", "Offert" => "2", "Chèque" => "3"}, :include_blank => false
|
||||
= form.input :paid_at, :label => "Date de paiement :", :as => :qi_date_picker
|
||||
=form.input :paid, :label => "Payé ?"
|
||||
|
||||
|
||||
.actions
|
||||
= form.submit "Sauvegarder", :class => "btn btn-primary"
|
31
app/views/admin/orders/_order.html.haml
Normal file
@ -0,0 +1,31 @@
|
||||
%tr#order_row.order_row{:id => order.id, :class => ("cancel" if !order.paid)}
|
||||
%td=l order.created_at
|
||||
%td=order.email
|
||||
%td=order.name
|
||||
%td
|
||||
-if order.paid
|
||||
="Payée" if order.paid
|
||||
par
|
||||
= "Paypal" if order.payment_type== 1.to_s
|
||||
= "Offert" if order.payment_type== 2.to_s
|
||||
= "Chèque" if order.payment_type== 3.to_s
|
||||
-else
|
||||
Paiement abandonné
|
||||
%td=number_to_currency order.total if order.paid
|
||||
%td=number_to_currency order.paypal_mc_fee if order.paid
|
||||
%td
|
||||
-begin
|
||||
= order.downloads_count
|
||||
-rescue
|
||||
|
||||
|
||||
|
||||
|
||||
%td{:style => "width:100px;"}
|
||||
=# link_to i(:trash), [:admin, order], :confirm => 'Voulez-vous vraiment supprimer cette order ?', :method => :delete, :remote => true
|
||||
=link_to i(:eye), public_order_url(:id => order.token), :target => "_blank"
|
||||
|
||||
= link_to i(:"envelope-o"), resend_admin_order_path(order), :data => {:confirm => "Voulez-vous vraiment renvoyer les infos pour cette commande ?"}
|
||||
|
||||
= link_to i(:pencil), edit_admin_order_path(order), :remote => true
|
||||
|
3
app/views/admin/orders/create.js.erb
Normal file
@ -0,0 +1,3 @@
|
||||
close_pane_hover();
|
||||
|
||||
$('#orders').html("<%= escape_javascript(render(Order.order("created_at DESC")))%>");
|
2
app/views/admin/orders/edit.js.erb
Normal file
@ -0,0 +1,2 @@
|
||||
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",550,600);
|
||||
|
26
app/views/admin/orders/index.html.haml
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
.header
|
||||
|
||||
.right
|
||||
=link_to "Ajouter", new_admin_order_path, :remote => true, :class => "btn btn-primary"
|
||||
%h1 Liste des commandes
|
||||
|
||||
%table.table.table-border
|
||||
%tr
|
||||
%td
|
||||
Somme estimée :
|
||||
%td
|
||||
=number_to_currency @orders.where(:paid => true).sum(:total)
|
||||
%td
|
||||
Nombre de commandes payées :
|
||||
%td
|
||||
=@orders.where(:paid => true).count
|
||||
%td
|
||||
Nombre de commandes abandonnées :
|
||||
%td
|
||||
=@orders.count - @orders.where(:paid => true).count
|
||||
|
||||
%table.table.table-striped#orders
|
||||
|
||||
=render @orders
|
||||
|
2
app/views/admin/orders/new.js.erb
Normal file
@ -0,0 +1,2 @@
|
||||
show_pane_hover("<%= escape_javascript(render(:partial => "new_form"))%>",550,600);
|
||||
|
3
app/views/admin/orders/update.js.erb
Normal file
@ -0,0 +1,3 @@
|
||||
close_pane_hover();
|
||||
|
||||
$('#order_row_<%= @order.id %>').replaceWith("<%= escape_javascript(render(@order))%>");
|
14
app/views/ebook_mailer/confirm.html.haml
Normal file
@ -0,0 +1,14 @@
|
||||
%p ************************ Attention ! conservez bien ce mail ! *****************************
|
||||
|
||||
%p Bonjour,
|
||||
|
||||
%p Votre transaction est maintenant terminée.
|
||||
|
||||
%p Nous vous remercions pour votre commande.
|
||||
|
||||
%p Vous pouvez télécharger votre exemplaire personnel à cette adresse :
|
||||
|
||||
%p
|
||||
=link_to @link, @link
|
||||
|
||||
%p L'équipe du Pic Vert
|
11
app/views/ebook_mailer/resend.html.haml
Normal file
@ -0,0 +1,11 @@
|
||||
%p ************************ Attention ! conservez bien ce mail ! *****************************
|
||||
|
||||
%p Bonjour,
|
||||
|
||||
%p Vous trouverez ci-dessous les informations pour accéder à votre votre exemplaire personnel.
|
||||
|
||||
%p
|
||||
=link_to @link, @link
|
||||
|
||||
%p L'équipe du Pic Vert
|
||||
|
@ -66,6 +66,13 @@
|
||||
%li.divider
|
||||
%li= link_to "Contributeurs", admin_authors_path
|
||||
|
||||
%li.dropdown
|
||||
%a{:href => "#", :data => {:toggle => "dropdown"}}
|
||||
Commandes
|
||||
%b.caret
|
||||
%ul.dropdown-menu
|
||||
%li= link_to "Commandes", admin_orders_path
|
||||
|
||||
|
||||
%li.dropdown
|
||||
%a{:href => "#", :class => "dropdown-toggle", :data => {:toggle => "dropdown"}}
|
||||
|
110
app/views/layouts/ebook.html.haml
Normal file
@ -0,0 +1,110 @@
|
||||
!!!
|
||||
|
||||
%html{:lang => "fr", "xml:lang" => "fr", :xmlns => "http://www.w3.org/1999/xhtml"}
|
||||
%head
|
||||
%title=@title.to_s+" "
|
||||
|
||||
|
||||
%meta{ :"http-equiv" => "Content-Type", :content => "text/html; charset=utf-8" }
|
||||
%meta{ :"name" => "Description", :content => @description }
|
||||
%meta{ :"name" => "Keywords", :content => @keywords }
|
||||
|
||||
|
||||
= javascript_include_tag "public"
|
||||
|
||||
= csrf_meta_tag
|
||||
|
||||
= stylesheet_link_tag 'public'
|
||||
= stylesheet_link_tag '/fonts/Stylograph/stylesheet.css'
|
||||
<script src="//use.typekit.net/ipv8wby.js"></script>
|
||||
<script>try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
=javascript_include_tag "http://maps.google.com/maps/api/js?sensor=false®ion=FR"
|
||||
|
||||
%body
|
||||
|
||||
|
||||
-if flash[:error] or flash[:notice] or flash[:alert]
|
||||
.flash
|
||||
|
||||
=flash[:error]
|
||||
=flash[:notice]
|
||||
=flash[:alert]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-if !(@menu_item and @menu_item.slug and @menu_item.slug == "index" )
|
||||
%p{:style => "height:80px;"}
|
||||
|
||||
|
||||
#slider_content
|
||||
.top
|
||||
|
||||
=link_to image_tag("/logo_pic_vert.png", :id => "logo"), "/"
|
||||
|
||||
|
||||
#main
|
||||
#corps{:class => (@menu_item.slug if @menu_item)}
|
||||
|
||||
|
||||
-if @menu_item and @menu_item.slug and @menu_item.slug == "index"
|
||||
.main_section_title
|
||||
=link_to "Actualités +", "/blog.html"
|
||||
|
||||
-article = Article.before(Date.today).recents.first
|
||||
|
||||
-if article
|
||||
%a{:href => public_article_path(:id => article.slug)}
|
||||
.first_article
|
||||
.image=image_tag article.image_file.file.large.medium.url if article.image_file
|
||||
|
||||
.description
|
||||
%h1=article.title
|
||||
=simple_format article.description
|
||||
.clear
|
||||
|
||||
-articles = Article.before(Date.today).recents.offset(1).limit(6)
|
||||
|
||||
-if articles
|
||||
.articles
|
||||
-articles.each do |article|
|
||||
%a{:href => public_article_path(:id => article.slug)}
|
||||
.article
|
||||
.image=image_tag article.image_file.file.large.medium.url if article.image_file
|
||||
|
||||
|
||||
.description
|
||||
%h2=article.title
|
||||
|
||||
.clear
|
||||
|
||||
|
||||
|
||||
=yield
|
||||
|
||||
#sidebar
|
||||
-if @menu_item and @menu_item.slug and @menu_item.slug == "index"
|
||||
.main_section_title
|
||||
Prochainement +
|
||||
|
||||
|
||||
=#render Event.recents.limit(2)
|
||||
|
||||
=yield :sidebar
|
||||
|
||||
.clear
|
||||
|
||||
|
||||
.bottom
|
||||
|
||||
=link_to image_tag("/nb.png"), "http://nicolasbally.com", :target => "_blank"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
//#5bb1f3
|
||||
//#e16b13
|
||||
//
|
||||
-if @options[:sheet] and @options[:sheet].last_year < Date.today.year
|
||||
-if @options and @options[:sheet] and @options[:sheet].last_year < Date.today.year
|
||||
%tr{:style => "background:#e16b13;"}
|
||||
%td{:colspan => "3", :style => "padding:10px;text-align:center;color:white;"}
|
||||
%a{:href => "http://www.lepicvert.asso.fr/131/lassociation/adherer", :style => "color:white;text-decoration:none;"}
|
||||
@ -57,15 +57,15 @@
|
||||
|
||||
%td{:style => "padding-top:20px;vertical-align:top;padding-right:30px;color:#2d2d2d;width:300px;text-align:right;"}
|
||||
%p
|
||||
-if @options[:person]
|
||||
-if @options and @options[:person]
|
||||
Ce mail est envoyé à
|
||||
=@options[:person].firstname
|
||||
=@options[:person].surname
|
||||
%br
|
||||
-if @options[:sheet] and @options[:sheet].corporate?
|
||||
-if @options and @options[:sheet] and @options[:sheet].corporate?
|
||||
=@options[:sheet].corporate
|
||||
%br
|
||||
-if @options[:sheet]
|
||||
-if @options and @options[:sheet]
|
||||
Cotisation à jour pour
|
||||
=@options[:sheet].last_year.to_s+"."
|
||||
|
||||
@ -75,7 +75,7 @@
|
||||
%tr{:style => "background:#393939;color:#f6f6f6;text-align:center;"}
|
||||
%td{:colspan => 3, :style => "padding:10px;font-size:12px;"}
|
||||
Vous recevez ce mail car vous êtes adhérent ou sympatisant de l'association Le Pic Vert. Si vous ne souhaitez plus recevoir de mail de notre part n'hésitez pas à nous contacter.
|
||||
-if @options[:sheet]
|
||||
-if @options and @options[:sheet]
|
||||
="-"
|
||||
N° d'adhésion :
|
||||
="#"+@options[:sheet].sheet_number.to_s
|
||||
|
@ -0,0 +1,8 @@
|
||||
|
||||
|
||||
%a.order_button{ :href => new_public_order_path()}
|
||||
=image_tag("/arreter-de-fumer/couv.jpg")
|
||||
%strong Cliquez ici pour commander
|
||||
%br
|
||||
Et téléchargez votre ebook tout de suite.
|
||||
.clear
|
11
app/views/public/orders/create.js.erb
Normal file
@ -0,0 +1,11 @@
|
||||
$(".confirm").show(100,function (){
|
||||
$('#new_order').hide(100, function(){
|
||||
|
||||
window.location.href = '<%= paid_by_paypal_public_order_path(@order.token) %>';
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
78
app/views/public/orders/new.html.haml
Normal file
@ -0,0 +1,78 @@
|
||||
|
||||
.observer-et-photographier-la-faune-sans-deranger
|
||||
%h1 Observer et photographier la faune sans déranger
|
||||
|
||||
-content_for :sidebar do
|
||||
%br
|
||||
=image_tag "/plaquette-cabane/004.jpg", :class => "couv"
|
||||
%br
|
||||
%br
|
||||
=image_tag "/plaquette-cabane/002.jpg", :class => "couv"
|
||||
%br
|
||||
%br
|
||||
=image_tag "/plaquette-cabane/003.jpg", :class => "couv"
|
||||
%br
|
||||
%br
|
||||
=image_tag "/plaquette-cabane/001.jpg", :class => "couv"
|
||||
|
||||
|
||||
%p
|
||||
|
||||
L’association de protection de la nature Le Pic vert a aménagé cinq cabanes d’observations dans les réserves naturelles qu’elle gère en Isère, France, en mettant au point des techniques originales permettant d’observer et de photographier la faune sauvage de très près, sans la déranger.
|
||||
%p
|
||||
Afin de faire connaître ce nouveau modèle d’observatoire Le Pic vert vient de publier une plaquette décrivant les plans et le matériel utilisés et permettant à chacun de construire sa propre cabane.
|
||||
%p
|
||||
Ce document,rédigé par Jean François Noblet, richement illustré, s’adresse aux gestionnaires d’espaces verts ou naturels, aux parcs animaliers, aux parcs nationaux et régionaux, aux réserves naturelles et à toutes les personnes qui souhaitent photographier les oiseaux de leur jardin.
|
||||
%p
|
||||
Cette plaquette est uniquement diffusée par internet à titre personnel dans le format PDF. Elle est vendue 10€.
|
||||
|
||||
%h3 Comment commander ?
|
||||
%p Le plus simple est de commander cette plaquette directement sur cette page en payant avec votre compte paypal où par carte bancaire. Ainsi vous pourrez la télécharger dès le paiement effectué.
|
||||
%p Vous pouvez également envoyer 10€ par chèque ou virement à l’association Le Pic vert (24 place de la mairie 38140 Réaumont). N'oubliez pas de nous communiquer également votre nom et votre prénom, ainsi qu'un mail où vous envoyer le lien de téléchargement une fois le paiement encaissé.
|
||||
|
||||
|
||||
|
||||
%p N'hésitez pas à nous contacter pour plus d'information au 04 76 91 34 33.
|
||||
|
||||
|
||||
%h3 Commander directement en ligne
|
||||
%p Vous pourrez télécharger votre exemplaire personnel dès le paiement effectué.
|
||||
%p Pour cela vous pouvez remplir le formulaire ci-dessous
|
||||
|
||||
=image_tag "/plaquette-cabane/couv.jpg", :class => "couv", :style => "width:300px;float:left;margin-right:10px;"
|
||||
=semantic_form_for [:public, @order], :remote => true, :id => "new_form", :onsubmit => "$('.confirm').show();" do |f|
|
||||
= f.inputs do
|
||||
=f.input :email, :label => "Email :"
|
||||
=f.input :name, :label => "Nom :"
|
||||
=f.input :firstname, :label => "Prénom :"
|
||||
=f.input :street1, :label => "Adresse :"
|
||||
=f.input :street2, :label => "Adresse (suite) :"
|
||||
=f.input :postal_code, :label => "Code Postal :"
|
||||
=f.input :cityname, :label => "Ville :"
|
||||
|
||||
=f.input :country, :label => "Pays :", :collection => [["France","FR"], ["Suisse","CH"], ["Espagne","ES"], ["Italie","IT"]], :as => :select, :include_blank => false
|
||||
#legals
|
||||
|
||||
%h3=# CONDITIONS GENERALES DE VENTE
|
||||
%p
|
||||
|
||||
|
||||
=#f.input :cgv, :label => raw("J'accepte les conditions générales de vente"), :as => :boolean, :label_html => {}
|
||||
|
||||
|
||||
|
||||
=f.submit "Commander", :type => :image, :src => "/paypal-button.png", :style => "width:180px;float:left;"
|
||||
=image_tag "/paypal-info.jpg", :style => "float:left;width:270px;margin-left:20px;margin-top:-12px;"
|
||||
.confirm{:style => "display:none;"}
|
||||
<br /><br /><p><strong>Vous allez être redirigé vers la page de paiement, merci de patienter...</strong></p>
|
||||
.clear
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
3
app/views/public/orders/new.js.erb
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
$(".observer-et-photographier-la-faune-sans-deranger").replaceWith("<%= escape_javascript(render(:template => "public/orders/new.html.haml")) %>");
|
||||
resize();
|
1
app/views/public/orders/paid.html.haml
Normal file
@ -0,0 +1 @@
|
||||
=link_to "Payer par paypal", paid_by_paypal_public_order_path(@order.token)
|
1
app/views/public/orders/paid_by_paypal.haml
Normal file
@ -0,0 +1 @@
|
||||
=#debug @set_express_checkout_response.Errors
|
16
app/views/public/orders/show.haml
Normal file
@ -0,0 +1,16 @@
|
||||
-if @order.paid
|
||||
%h1 Observer et photographier la faune sans déranger
|
||||
%h2 Nous avons bien enregistré votre paiement et nous vous en remercions.
|
||||
%p Un mail de confirmation vous a été envoyé.
|
||||
%p Vous pouvez des à présent télécharger votre exemplaire personnel en cliquant sur le lien ci-dessous :
|
||||
.download_ebook
|
||||
=image_tag "/plaquette-cabane/couv.jpg", :class => "couv", :style => "float:left;width:200px;margin-right:10px"
|
||||
%ul
|
||||
%li=link_to "télécharger le document au format PDF", download_public_order_path(@order.token, :file => "pdf" )
|
||||
|
||||
.clear
|
||||
|
||||
-else
|
||||
|
||||
Il semble que le paiement de votre commande ne soit pas valide, où que vous avez été remboursé. Si ce n'est pas le cas merci de nous contacter
|
||||
=link_to "contact@lepicvert.asso.fr", "contact@lepicvert.asso.fr"
|
2
config/initializers/paypal.rb
Normal file
@ -0,0 +1,2 @@
|
||||
PayPal::SDK.load("config/paypal.yml", Rails.env)
|
||||
PayPal::SDK.logger = Rails.logger
|
35
config/paypal.yml
Normal file
@ -0,0 +1,35 @@
|
||||
test: &default
|
||||
|
||||
# Credentials for REST APIs
|
||||
|
||||
# Mode can be 'live' or 'sandbox'
|
||||
mode: sandbox
|
||||
|
||||
# Credentials for Classic APIs
|
||||
#app_id: APP-80W284485P519543T
|
||||
username: vendeur2_api1.quartz-agence.com
|
||||
password: DV8N5WJ99B3F9XR4
|
||||
signature: AFcWxV21C7fd0v3bYYYRCpSSRl31A0ZCUMdM5PSBzplf61L2JGijF.WT
|
||||
# # With Certificate
|
||||
# cert_path: "config/cert_key.pem"
|
||||
sandbox_email_address: vendeur@quartz-agence.com
|
||||
|
||||
# # IP Address
|
||||
# ip_address: 127.0.0.1
|
||||
# # HTTP Proxy
|
||||
# http_proxy: http://proxy-ipaddress:3129/
|
||||
|
||||
# verbose_logging: true
|
||||
|
||||
development:
|
||||
<<: *default
|
||||
|
||||
production:
|
||||
mode: live
|
||||
username: paypal_api1.lepicvert.asso.fr
|
||||
password: D8LBWSCY6LYUUPDZ
|
||||
signature: Apa4uPDrYN4D6g2sohKaa7zmk.MfAje2cAyV1YgX9I3775USA0gZIrrM
|
||||
# # With Certificate
|
||||
# cert_path: "config/cert_key.pem"
|
||||
#sandbox_email_address: vendeur@quartz-agence.com
|
||||
|
@ -1,5 +1,7 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
Survey::Application.routes.draw do
|
||||
get "plaquette-observatoires.html" => redirect("/public/orders/new")
|
||||
get "observer-et-photographier-la-faune-sans-deranger.html" => "public/menu_items#observer-et-photographier-la-faune-sans-deranger"
|
||||
get "agenda/:id.html" => "public/events#show", :as => "public_event"
|
||||
get "agenda.html" => "public/events#index", :as => "public_events"
|
||||
get 'actualites/:id.html' => "public/articles#show", :as => "public_article"
|
||||
@ -20,6 +22,20 @@ Survey::Application.routes.draw do
|
||||
|
||||
get 'mail_assets/:token.png' => "admin/mail_trackings#update", :as => :image_tracking
|
||||
|
||||
|
||||
namespace :public do
|
||||
resources :orders do
|
||||
|
||||
member do
|
||||
get :download
|
||||
get :paid
|
||||
get :paid_by_paypal
|
||||
get :do_paypal_payment
|
||||
post :ipn
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
namespace :portlet do
|
||||
resources :event_contents
|
||||
resources :break_contents
|
||||
@ -50,7 +66,11 @@ Survey::Application.routes.draw do
|
||||
end
|
||||
#admin
|
||||
namespace :admin do
|
||||
|
||||
resources :orders do
|
||||
member do
|
||||
get :resend
|
||||
end
|
||||
end
|
||||
resources :authors
|
||||
resources :password_resets
|
||||
|
||||
|
55
db/migrate/20141101225630_create_orders.rb
Normal file
@ -0,0 +1,55 @@
|
||||
class CreateOrders < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :orders do |t|
|
||||
t.string :email
|
||||
t.string :subtotal, :precision => 15, :scale => 10
|
||||
t.string :partner_id
|
||||
t.string :total, :precision => 15, :scale => 10
|
||||
t.string :firstname
|
||||
t.string :name
|
||||
t.string :street1
|
||||
t.string :street2
|
||||
t.string :cityname
|
||||
t.string :state_or_province
|
||||
t.string :country
|
||||
t.string :payment_type
|
||||
t.datetime :paid_at
|
||||
t.boolean :paid
|
||||
t.string :postal_code
|
||||
t.string :token
|
||||
t.string :sheet_token
|
||||
|
||||
|
||||
t.string :paypal_test_ipn
|
||||
|
||||
t.string :paypal_txn_type
|
||||
t.string :paypal_txn_id
|
||||
t.datetime :paypal_payment_date
|
||||
|
||||
t.string :paypal_payment_status
|
||||
t.string :paypal_reason_code
|
||||
t.string :paypal_payment_type
|
||||
|
||||
t.string :paypal_mc_currency
|
||||
t.string :paypal_mc_fee
|
||||
t.string :paypal_mc_gross
|
||||
|
||||
t.string :paypal_residence_country
|
||||
t.string :paypal_last_name
|
||||
t.string :paypal_first_name
|
||||
t.string :paypal_payer_email
|
||||
t.string :paypal_payer_id
|
||||
t.string :paypal_payer_status
|
||||
|
||||
t.string :paypal_receiver_id
|
||||
t.string :paypal_receiver_email
|
||||
|
||||
t.string :paypal_protection_eligibility
|
||||
t.string :paypal_ipn_track_id
|
||||
|
||||
t.integer :downloads_count
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
17
db/migrate/20141101230810_create_order_products.rb
Normal file
@ -0,0 +1,17 @@
|
||||
class CreateOrderProducts < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :order_products do |t|
|
||||
t.integer :product_id
|
||||
t.references :order
|
||||
t.string :name
|
||||
t.text :description
|
||||
t.decimal :price, :precision => 15, :scale => 10
|
||||
t.string :slug
|
||||
t.string :pdf_path
|
||||
t.string :epub_path
|
||||
t.string :mobi_path
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
57
db/schema.rb
@ -508,6 +508,63 @@ ActiveRecord::Schema.define(version: 20150121145821) do
|
||||
|
||||
add_index "notes", ["admin_id"], name: "index_notes_on_admin_id", using: :btree
|
||||
|
||||
create_table "order_products", force: true do |t|
|
||||
t.integer "product_id"
|
||||
t.integer "order_id"
|
||||
t.string "name"
|
||||
t.text "description"
|
||||
t.decimal "price", precision: 15, scale: 10
|
||||
t.string "slug"
|
||||
t.string "pdf_path"
|
||||
t.string "epub_path"
|
||||
t.string "mobi_path"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "orders", force: true do |t|
|
||||
t.string "email"
|
||||
t.string "subtotal"
|
||||
t.string "partner_id"
|
||||
t.string "total"
|
||||
t.string "firstname"
|
||||
t.string "name"
|
||||
t.string "street1"
|
||||
t.string "street2"
|
||||
t.string "cityname"
|
||||
t.string "state_or_province"
|
||||
t.string "country"
|
||||
t.string "payment_type"
|
||||
t.datetime "paid_at"
|
||||
t.boolean "paid"
|
||||
t.string "postal_code"
|
||||
t.string "token"
|
||||
t.string "sheet_token"
|
||||
t.string "paypal_test_ipn"
|
||||
t.string "paypal_txn_type"
|
||||
t.string "paypal_txn_id"
|
||||
t.datetime "paypal_payment_date"
|
||||
t.string "paypal_payment_status"
|
||||
t.string "paypal_reason_code"
|
||||
t.string "paypal_payment_type"
|
||||
t.string "paypal_mc_currency"
|
||||
t.string "paypal_mc_fee"
|
||||
t.string "paypal_mc_gross"
|
||||
t.string "paypal_residence_country"
|
||||
t.string "paypal_last_name"
|
||||
t.string "paypal_first_name"
|
||||
t.string "paypal_payer_email"
|
||||
t.string "paypal_payer_id"
|
||||
t.string "paypal_payer_status"
|
||||
t.string "paypal_receiver_id"
|
||||
t.string "paypal_receiver_email"
|
||||
t.string "paypal_protection_eligibility"
|
||||
t.string "paypal_ipn_track_id"
|
||||
t.integer "downloads_count"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "pages", force: true do |t|
|
||||
t.text "title"
|
||||
t.text "description"
|
||||
|
BIN
pdf/plaquette-cabane.pdf
Normal file
BIN
public/paypal-button.png
Executable file
After Width: | Height: | Size: 12 KiB |
BIN
public/paypal-info.jpg
Executable file
After Width: | Height: | Size: 33 KiB |
BIN
public/plaquette-cabane/001.jpg
Normal file
After Width: | Height: | Size: 180 KiB |
BIN
public/plaquette-cabane/002.jpg
Normal file
After Width: | Height: | Size: 187 KiB |
BIN
public/plaquette-cabane/003.jpg
Normal file
After Width: | Height: | Size: 156 KiB |
BIN
public/plaquette-cabane/004.jpg
Normal file
After Width: | Height: | Size: 211 KiB |
BIN
public/plaquette-cabane/couv.jpg
Normal file
After Width: | Height: | Size: 888 KiB |