This commit is contained in:
Nicolas Bally 2019-06-04 14:36:49 +02:00
parent 429325823c
commit 23eb1c086d
7 changed files with 45 additions and 10 deletions

View File

@ -114,8 +114,8 @@ GEM
net-ssh (2.7.0)
net-ssh-gateway (1.2.0)
net-ssh (>= 2.6.5)
nokogiri (1.6.5)
mini_portile (~> 0.6.0)
nokogiri (1.6.0)
mini_portile (~> 0.5.0)
non-stupid-digest-assets (1.0.4)
orm_adapter (0.5.0)
paypal-sdk-core (0.3.1)

View File

@ -7,11 +7,18 @@ class Renew < ActiveRecord::Base
validates :payment_type_id, :presence => true
validates :join_type, :presence => true
validates :personalized_price, :presence => true, numericality:{greater_than_or_equal_to: 20}, :if => :bienfaiteur?
before_validation do
self.payment_type_id = 3
if !self.bienfaiteur
self.personalized_price = nil
end
if self.join_type == 1
self.payment_type_id = 3
if self.bienfaiteur
self.price = self.personalized_price
elsif self.join_type == 1
self.price = 10.0
elsif self.join_type == 2
self.price = 15.0
@ -36,7 +43,7 @@ class Renew < ActiveRecord::Base
sheet_year = self.sheet.sheet_years.new(:year => Renew::YEAR, :join_type => self.join_type, :paid_at => Time.now, :amount => self.price, :payment_type => self.payment_type_id, )
sheet_year = self.sheet.sheet_years.new(:benefactor => self.bienfaiteur, :year => Renew::YEAR, :join_type => self.join_type, :paid_at => Time.now, :amount => self.price, :payment_type => self.payment_type_id, )
if sheet_year.save
self.return_done = true

View File

@ -35,7 +35,11 @@
%a{:href => "http://www.lepicvert.asso.fr/131/lassociation/adherer", :style => "color:white;text-decoration:none;"}
Attention : votre adhésion n'a pas encore été renouvelée pour
= Date.today.year.to_s+"."
%br
=link_to select_sheet_public_renews_index_path(:s => @options[:sheet].sheet_number.to_s), :style => "color:white;text-decoration:underline;" do
%strong
Nouveau : vous pouvez désormais la renouveler directement en ligne, par carte bancaire en suivant ce lien.
%tr{:style => "background:#f4f3ef"}

View File

@ -2,6 +2,14 @@
%p Pour renouveller votre adhésion vous pouvez indiquer votre numéro d'adhérent ci-dessous :
%ul
%li
Adhésion individuelle : 10 €
%li
Adhésion familiale : 15 €
%li
Bienfaiteur individuel ou familial : 20 € ou plus
=semantic_form_for @renew, :url => save_sheet_public_renews_index_path(), :html => {:method => :get} do |f|
-f.inputs do
@ -10,10 +18,15 @@
=f.input :email, :label => "Email :"
=f.input :join_type, :collection => {"Individuel (10€)" => 1, "Familial (15€)" => 2}, :include_blank => false, :label => "Type d'adhésion", :as => :radio
=f.input :join_type, :collection => {"Individuel" => 1, "Familial" => 2}, :include_blank => false, :label => "Type d'adhésion :", :as => :radio
=f.input :bienfaiteur, :label => "Adhésion bienfaiteur ? (somme libre au dessus de 20€)", :input_html => {:onchange => "if($(this).is(':checked')){$('.bienfaiteur').show();}else{$('.bienfaiteur').hide();}"}
.bienfaiteur{:style => ("display:none" if !@renew.bienfaiteur)}
=f.input :personalized_price, :label => "Montant de votre adhésion bienfaiteur :"
=f.submit "Renouveller mon adhésion par CB"

View File

@ -29,8 +29,11 @@ Survey::Application.configure do
config.assets.debug = true
config.action_mailer.delivery_method = :file
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = { :address => "localhost", :port => 1025 }
config.action_mailer.default_url_options = { :host => HOSTNAME }
Rails.application.routes.default_url_options = config.action_mailer.default_url_options = { :host => HOSTNAME, :protocol => 'http' }
end

View File

@ -0,0 +1,6 @@
class AddBienfaiteurToRenews < ActiveRecord::Migration
def change
add_column :renews, :bienfaiteur, :boolean, :default => false
add_column :renews, :personalized_price, :decimal, :precision => 10, :scale => 2
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20190315002155) do
ActiveRecord::Schema.define(version: 20190604091050) do
create_table "admins", force: true do |t|
t.string "email", default: "", null: false
@ -783,6 +783,8 @@ ActiveRecord::Schema.define(version: 20190315002155) do
t.boolean "return_done", default: false
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "bienfaiteur", default: false
t.decimal "personalized_price", precision: 10, scale: 2
end
add_index "renews", ["sheet_id"], name: "index_renews_on_sheet_id", using: :btree