forgeos_commerce_front 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/COPYING +339 -0
- data/COPYING.LESSER +165 -0
- data/Gemfile +2 -0
- data/LICENSE +2 -0
- data/README.textile +28 -0
- data/app/assets/images/commerce_front/cart/calulate.png +0 -0
- data/app/assets/images/commerce_front/cart/cart.png +0 -0
- data/app/assets/images/commerce_front/cart/change_quantity.png +0 -0
- data/app/assets/images/commerce_front/cart/delete.png +0 -0
- data/app/assets/images/commerce_front/cart/reduction.png +0 -0
- data/app/assets/images/commerce_front/cart/steps_left.png +0 -0
- data/app/assets/images/commerce_front/cart/steps_right.png +0 -0
- data/app/assets/images/commerce_front/product.jpg +0 -0
- data/app/assets/javascripts/commerce_front/functions.js +10 -0
- data/app/assets/javascripts/commerce_front/init.js +4 -0
- data/app/assets/javascripts/commerce_front/jquery.jnotify.min.js +21 -0
- data/app/assets/stylesheets/commerce_front/_cart.css.sass +97 -0
- data/app/assets/stylesheets/commerce_front/_common.css.sass +13 -0
- data/app/assets/stylesheets/commerce_front/_forms.css.sass +15 -0
- data/app/assets/stylesheets/commerce_front/_jnotify.css.sass +65 -0
- data/app/assets/stylesheets/commerce_front/style.css.sass +4 -0
- data/app/controllers/addresses_controller.rb +71 -0
- data/app/controllers/application_controller.rb +21 -0
- data/app/controllers/cart_controller.rb +144 -0
- data/app/controllers/newsletters_controller.rb +20 -0
- data/app/controllers/order_controller.rb +413 -0
- data/app/controllers/orders_controller.rb +32 -0
- data/app/controllers/person_sessions_controller.rb +23 -0
- data/app/controllers/users_controller.rb +164 -0
- data/app/helpers/application_helper.rb +73 -0
- data/app/helpers/cart_helper.rb +25 -0
- data/app/helpers/order_helper.rb +59 -0
- data/app/models/address.rb +18 -0
- data/app/models/notifier.rb +88 -0
- data/app/models/order.rb +13 -0
- data/app/models/user.rb +16 -0
- data/app/models/user_address.rb +15 -0
- data/app/views/addresses/_address_form.html.haml +18 -0
- data/app/views/addresses/_multiple_address_form.html.haml +27 -0
- data/app/views/cart/_free_products.html.haml +3 -0
- data/app/views/cart/_tbody.html.haml +25 -0
- data/app/views/cart/_total.html.haml +46 -0
- data/app/views/cart/index.html.haml +32 -0
- data/app/views/notifier/newsletter.html.haml +2 -0
- data/app/views/notifier/reset_password.html.haml +9 -0
- data/app/views/notifier/validation_user_account.html.haml +9 -0
- data/app/views/notifier/waiting_for_cheque_notification.html.haml +2 -0
- data/app/views/order/_form_address.html.haml +44 -0
- data/app/views/order/_tbody.html.haml +21 -0
- data/app/views/order/_total.html.haml +50 -0
- data/app/views/order/cheque_payment.html.haml +1 -0
- data/app/views/order/create.html.haml +76 -0
- data/app/views/order/deliveries.html.haml +28 -0
- data/app/views/order/new.html.haml +26 -0
- data/app/views/order/so_colissimo.html.haml +8 -0
- data/app/views/orders/index.html.haml +34 -0
- data/app/views/person_sessions/_form.html.haml +23 -0
- data/app/views/person_sessions/new.html.haml +1 -0
- data/app/views/person_sessions/new_reset_password.html.haml +7 -0
- data/app/views/users/_edit_form.html.haml +61 -0
- data/app/views/users/_form_create.html.haml +27 -0
- data/app/views/users/_form_quick_create.html.haml +16 -0
- data/app/views/users/_login_or_new.html.haml +10 -0
- data/app/views/users/forgotten_password.html.haml +12 -0
- data/app/views/users/new.html.haml +1 -0
- data/app/views/users/new_password.html.haml +10 -0
- data/app/views/users/show.html.haml +1 -0
- data/config/commerce.example.yml +27 -0
- data/config/initializers/commerce_front.rb +6 -0
- data/config/locales/fr.yml +85 -0
- data/config/routes.rb +17 -0
- data/db/migrate/20110311134232_add_form_attributes_to_addresses.rb +9 -0
- data/lib/field_error_proc_changer.rb +19 -0
- data/lib/forgeos/commerce_front.rb +6 -0
- data/lib/forgeos/commerce_front/engine.rb +10 -0
- data/lib/forgeos/commerce_front/version.rb +5 -0
- data/lib/forgeos_commerce_front.rb +1 -0
- data/lib/tasks/install.rake +13 -0
- data/recipes/deploy.rb +6 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +9 -0
- data/test/dummy/app/assets/stylesheets/application.css +7 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +42 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +27 -0
- data/test/dummy/config/environments/production.rb +51 -0
- data/test/dummy/config/environments/test.rb +39 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +10 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/log/development.log +0 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +26 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/forgeos_commerce_front_test.rb +7 -0
- data/test/test_helper.rb +10 -0
- metadata +197 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
class PersonSessionsController < ApplicationController
|
|
2
|
+
|
|
3
|
+
def new
|
|
4
|
+
@person_session = PersonSession.new
|
|
5
|
+
@user = User.new(params[:user])
|
|
6
|
+
session[:return_to] = params[:return_to] if params[:return_to].present?
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def create
|
|
10
|
+
@person_session = PersonSession.new(params[:person_session])
|
|
11
|
+
if @person_session.save
|
|
12
|
+
redirect_to_stored_location(:user)
|
|
13
|
+
flash[:notice] = t('log.in.success').capitalize
|
|
14
|
+
else
|
|
15
|
+
flash[:error] = t('log.in.failed').capitalize
|
|
16
|
+
redirect_to_stored_location do
|
|
17
|
+
@user = User.new
|
|
18
|
+
render :action => :new
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
class UsersController < ApplicationController
|
|
2
|
+
before_filter :login_required, :only => [:show, :update]
|
|
3
|
+
before_filter :get_user, :only => [:show, :update]
|
|
4
|
+
before_filter :manage_address, :only => [:update]
|
|
5
|
+
around_filter FieldErrorProcChanger.new(
|
|
6
|
+
Proc.new do |html_tag, instance|
|
|
7
|
+
error_message = instance.object.errors.on(instance.method_name)
|
|
8
|
+
if error_message && !(html_tag =~ /^<label|type="hidden"/)
|
|
9
|
+
if html_tag.match(/class="/)
|
|
10
|
+
html_tag.gsub!(/class="/, "class=\"error_on_this_field ")
|
|
11
|
+
else
|
|
12
|
+
html_tag.gsub!(/\/>$/, " class=\"error_on_this_field\"\/>")
|
|
13
|
+
end
|
|
14
|
+
html_tag = "#{html_tag}<div class=\"field_error\">#{error_message.is_a?(Array) ? error_message.first : error_message}</div>"
|
|
15
|
+
else
|
|
16
|
+
html_tag
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
), :only => [:create, :update]
|
|
20
|
+
|
|
21
|
+
def show
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def new
|
|
25
|
+
@user = User.new(params[:user])
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def create
|
|
29
|
+
cookies.delete :auth_token
|
|
30
|
+
@user = User.new(params[:user])
|
|
31
|
+
password = params[:user][:password]
|
|
32
|
+
if (not Forgeos::CONFIG[:account]['checkout_quick_create'] or not password) and Forgeos::CONFIG[:account]['password_generated']
|
|
33
|
+
password = generate_password(10)
|
|
34
|
+
@user.email_confirmation = @user.email if @user.respond_to?('email_confirmation=')
|
|
35
|
+
@user.password = password
|
|
36
|
+
@user.password_confirmation = password
|
|
37
|
+
end
|
|
38
|
+
if @user.save
|
|
39
|
+
if @generated_password
|
|
40
|
+
Notifier.deliver_validation_user_account(@user, password)
|
|
41
|
+
else
|
|
42
|
+
@user.activate
|
|
43
|
+
PersonSession.create(@user,true)
|
|
44
|
+
end
|
|
45
|
+
flash[:notice] = I18n.t('success', :scope => [:user, :create])
|
|
46
|
+
redirect_to_stored_location(login_path)
|
|
47
|
+
else
|
|
48
|
+
Rails.logger.info("\033[01;33m#{@user.errors.inspect}\033[0m")
|
|
49
|
+
if @user.errors.on(:civility)
|
|
50
|
+
flash[:error] = 'Veuillez préciser votre civilité'
|
|
51
|
+
else
|
|
52
|
+
flash[:error] = I18n.t('error', :scope => [:user, :create])
|
|
53
|
+
end
|
|
54
|
+
render :action => 'new'
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def activate
|
|
59
|
+
unless params[:activation_code].blank?
|
|
60
|
+
user = User.find_by_perishable_token(params[:activation_code])
|
|
61
|
+
if user
|
|
62
|
+
if user.active?
|
|
63
|
+
flash[:warning] = I18n.t('already_active', :scope => [:user, :activate])
|
|
64
|
+
return redirect_to(:root)
|
|
65
|
+
end
|
|
66
|
+
user.activate
|
|
67
|
+
user.reset_perishable_token!
|
|
68
|
+
PersonSession.create(user, true)
|
|
69
|
+
flash[:notice] = I18n.t('success', :scope => [:user, :activate])
|
|
70
|
+
return redirect_to(:action => :show)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
flash[:error] = I18n.t('error', :scope => [:user, :activate])
|
|
74
|
+
redirect_to(:root)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def update
|
|
78
|
+
if @user.update_attributes(params[:user])
|
|
79
|
+
flash[:notice] = I18n.t('success', :scope => [:user, :update])
|
|
80
|
+
else
|
|
81
|
+
flash[:error] = I18n.t('error', :scope => [:user, :update])
|
|
82
|
+
end
|
|
83
|
+
render(:action => :show)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def forgotten_password
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def reset_password
|
|
90
|
+
user = User.find_by_email(params[:email])
|
|
91
|
+
unless user
|
|
92
|
+
flash[:warning] = I18n.t('unknown_user', :scope => [:user, :reset_password], :email => params[:email])
|
|
93
|
+
return redirect_to(:action => :forgotten_password)
|
|
94
|
+
end
|
|
95
|
+
begin
|
|
96
|
+
Notifier.deliver_reset_password(user)
|
|
97
|
+
flash[:notice] = I18n.t('success', :scope => [:user, :reset_password])
|
|
98
|
+
rescue StandardError
|
|
99
|
+
flash[:error] = I18n.t('error', :scope => [:user, :reset_password])
|
|
100
|
+
end
|
|
101
|
+
redirect_to(:root)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def new_password
|
|
105
|
+
@user = User.find_by_perishable_token(params[:user_token])
|
|
106
|
+
unless @user
|
|
107
|
+
flash[:error] = I18n.t('error', :scope => [:user, :new_password])
|
|
108
|
+
redirect_to(:root)
|
|
109
|
+
end
|
|
110
|
+
@user.activate
|
|
111
|
+
@user.reset_perishable_token!
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def update_password
|
|
115
|
+
@user = User.find_by_perishable_token(params[:user_token])
|
|
116
|
+
unless @user
|
|
117
|
+
flash[:error] = I18n.t('error', :scope => [:user, :new_password])
|
|
118
|
+
redirect_to(:root)
|
|
119
|
+
end
|
|
120
|
+
@user.reset_perishable_token!
|
|
121
|
+
if @user.update_attributes(params[:user].reject{|k, v| !k.to_s.match(/^password/)})
|
|
122
|
+
flash[:notice] = I18n.t('success', :scope => [:user, :update])
|
|
123
|
+
redirect_to(login_path)
|
|
124
|
+
else
|
|
125
|
+
flash[:error] = I18n.t('error', :scope => [:user, :update])
|
|
126
|
+
render(:action => :new_password)
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
private
|
|
131
|
+
def generate_password(size)
|
|
132
|
+
s = ""
|
|
133
|
+
size.times { s << (i = Kernel.rand(62); i += ((i < 10) ? 48 : ((i < 36) ? 55 : 61 ))).chr }
|
|
134
|
+
@generated_password = true
|
|
135
|
+
return s
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def manage_address
|
|
139
|
+
if params[:user] and params[:user][:address_invoice_attributes]
|
|
140
|
+
params[:user][:address_invoice_attributes][:name] = params[:user][:lastname]
|
|
141
|
+
params[:user][:address_invoice_attributes][:firstname] = params[:user][:firstname]
|
|
142
|
+
params[:user][:address_invoice_attributes][:designation] = 'Première adresse'
|
|
143
|
+
params[:user][:address_invoice_attributes][:civility] = params[:user][:civility]
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def get_user
|
|
148
|
+
@user = current_user
|
|
149
|
+
unless @user.is_a?(User)
|
|
150
|
+
if @user.is_a?(Administrator)
|
|
151
|
+
flash[:warning] = t(:administrator_warning)
|
|
152
|
+
if request.referer
|
|
153
|
+
return redirect_to(:back)
|
|
154
|
+
else
|
|
155
|
+
return redirect_to(:root)
|
|
156
|
+
end
|
|
157
|
+
else
|
|
158
|
+
flash[:error] = t(:not_authorized)
|
|
159
|
+
return render(:text => '', :status => 401, :layout => true)
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
module ApplicationHelper
|
|
2
|
+
|
|
3
|
+
def display_avatar(avatar, thumb=:small)
|
|
4
|
+
if avatar and not avatar.new_record?
|
|
5
|
+
image_tag(avatar.public_filename(thumb))
|
|
6
|
+
else
|
|
7
|
+
image_tag('front/blank-avatar.jpg')
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def password_fields(form, options={})
|
|
12
|
+
base_options = {
|
|
13
|
+
:password_field => :password,
|
|
14
|
+
:confirmation_field => :password_confirmation,
|
|
15
|
+
:password_label => t(:password),
|
|
16
|
+
:confirmation_label => t(:password_confirmation).capitalize,
|
|
17
|
+
:label_class => '',
|
|
18
|
+
:input_class => '',
|
|
19
|
+
:field_class => 'grid_5',
|
|
20
|
+
}
|
|
21
|
+
opts = base_options.merge(options)
|
|
22
|
+
password_field = opts[:password_field]
|
|
23
|
+
confirmation_field = opts[:confirmation_field]
|
|
24
|
+
|
|
25
|
+
fields = ''
|
|
26
|
+
fields += "<div class='#{opts[:field_class]} password_field'>"
|
|
27
|
+
fields += "<div class='#{opts[:label_class]} password_field'>"
|
|
28
|
+
fields += form.label(password_field, opts[:password_label])
|
|
29
|
+
fields += '</div>'
|
|
30
|
+
fields += "<div class='#{opts[:input_class]} password_field'>"
|
|
31
|
+
fields += form.password_field(password_field)
|
|
32
|
+
fields += '</div>'
|
|
33
|
+
fields += '</div>'
|
|
34
|
+
fields += "<div class='#{opts[:field_class]} password_field'>"
|
|
35
|
+
fields += "<div class='#{opts[:label_class]} password_field'>"
|
|
36
|
+
fields += form.label(confirmation_field, opts[:confirmation_label])
|
|
37
|
+
fields += "</div>"
|
|
38
|
+
fields += "<div class='#{opts[:input_class]} password_field'>"
|
|
39
|
+
fields += form.password_field(confirmation_field)
|
|
40
|
+
fields += "</div>"
|
|
41
|
+
fields += "</div>"
|
|
42
|
+
fields += "<script type=\"text/javascript\">
|
|
43
|
+
$('#user_password').bind('keyup', function(){
|
|
44
|
+
if ($(this).val().length > 5){
|
|
45
|
+
$(this).addClass('right_password');
|
|
46
|
+
$(this).removeClass('wrong_password');
|
|
47
|
+
} else{
|
|
48
|
+
$(this).addClass('wrong_password');
|
|
49
|
+
$(this).removeClass('right_password');
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
$('#user_password_confirmation').bind('keyup', function() {
|
|
53
|
+
if($(this).val() == $('#user_password').val()){
|
|
54
|
+
$(this).addClass('right_password');
|
|
55
|
+
$(this).removeClass('wrong_password');
|
|
56
|
+
} else{
|
|
57
|
+
$(this).addClass('wrong_password');
|
|
58
|
+
$(this).removeClass('right_password');
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
</script>"
|
|
62
|
+
fields
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def options_for_countries(value)
|
|
66
|
+
iso_codes = Forgeos::CONFIG[:addresses]['available_countries']
|
|
67
|
+
iso_code = Forgeos::CONFIG[:addresses]['default_country']
|
|
68
|
+
default_country = Country.first(:select => :id, :conditions => { :iso => iso_code})
|
|
69
|
+
default_country_id = (default_country ? default_country.id : nil)
|
|
70
|
+
countries = Country.all(:conditions => {:iso => iso_codes}, :select => 'id,printable_name', :order=>'printable_name')
|
|
71
|
+
options_from_collection_for_select(countries, :id, :printable_name, (value.nil? ? default_country_id : value))
|
|
72
|
+
end
|
|
73
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
module CartHelper
|
|
3
|
+
|
|
4
|
+
# Display a link to remove a cart product from the current cart
|
|
5
|
+
def remove_cart_product_link(cart_product_id)
|
|
6
|
+
link_to_function 'supprimer', remote_function(:url => { :controller => 'cart', :action => 'delete_product', :id => cart_product_id} , :confirm => 'Voulez-vous vraiment supprimer ce produit de votre panier ?'), :class => 'delete_product'
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# Display the voucher form
|
|
10
|
+
def display_voucher
|
|
11
|
+
content = "<span> Bénéficiez-vous d'un code avantage ?</span>"
|
|
12
|
+
content += "<div class='voucherbox'> <label> Code avantage </label>"
|
|
13
|
+
content += text_field_tag(:voucher_code, "", :id => 'voucher_code') + ""
|
|
14
|
+
content +=
|
|
15
|
+
button_to_function(
|
|
16
|
+
'Valider le code',
|
|
17
|
+
remote_function(
|
|
18
|
+
:url => {:controller => 'cart', :action => 'add_voucher'},
|
|
19
|
+
:with => "'voucher_code='+$('#voucher_code').val()"
|
|
20
|
+
),
|
|
21
|
+
:class => 'no-custom'
|
|
22
|
+
)
|
|
23
|
+
content += "</div>"
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
module OrderHelper
|
|
2
|
+
|
|
3
|
+
def payment_methods_list
|
|
4
|
+
content = ''
|
|
5
|
+
setting = Setting.current
|
|
6
|
+
|
|
7
|
+
setting.payment_method_availables.each do |payment_method|
|
|
8
|
+
payment_infos = setting.payment_method_settings(payment_method)
|
|
9
|
+
content += payment_radio_button_tag(payment_method, payment_infos[:image])
|
|
10
|
+
|
|
11
|
+
if payment_method.to_sym == :cyberplus and setting.payment_method_settings_with_env(payment_method)[:payment_config] != 'SINGLE'
|
|
12
|
+
if current_user.cart.total >= setting.payment_method_settings_with_env(payment_method)[:multi_minimum_cart].to_f
|
|
13
|
+
content += payment_radio_button_tag("#{payment_method}_multi", payment_infos[:image_multi])
|
|
14
|
+
else
|
|
15
|
+
message = setting.payment_method_settings_with_env(payment_method)[:multi_message]
|
|
16
|
+
flash[:warning] = message if message.present?
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
content
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def payment_radio_button_tag(payment, image = '')
|
|
25
|
+
payment_tag = content_tag(:div, :class => 'paiement' ) do
|
|
26
|
+
radio_button_tag(:payment_type, payment, params[:payment_type] == payment.to_s) +
|
|
27
|
+
content_tag(:label, t(payment, :scope => [:payment], :count => 1).capitalize )
|
|
28
|
+
end
|
|
29
|
+
payment_tag += image_tag(image) if image.present?
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def display_cheque_message
|
|
33
|
+
if Setting.current.payment_method_available?(:cheque)
|
|
34
|
+
Setting.current.cheque_message(@order)
|
|
35
|
+
else
|
|
36
|
+
t(:not_active, :scope => [:payment]).capitalize
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def step_order(index=0)
|
|
41
|
+
## urls need change
|
|
42
|
+
urls = [{:controller => 'cart'}, {:controller => 'order', :action => 'informations'}, {:controller => 'order', :action => 'informations'}, {:controller => 'order', :action => 'informations'}]
|
|
43
|
+
labels = ['Mon panier', 'Livraison', 'Paiement', 'Validation']
|
|
44
|
+
links = []
|
|
45
|
+
|
|
46
|
+
labels.each_with_index do |label,i|
|
|
47
|
+
link = link_to(label, urls[i])
|
|
48
|
+
_class = 'checkout_link'
|
|
49
|
+
_class += " checkout_link_#{i}"
|
|
50
|
+
_class += ' current_checkout_link' if i == index
|
|
51
|
+
span = content_tag(:span, link)
|
|
52
|
+
div = content_tag(:div, span, :class => _class)
|
|
53
|
+
links << div
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
content_tag(:div, links, :class => 'checkout_links')
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
load File.join(Gem.loaded_specs['forgeos_core'].full_gem_path, 'app', 'models', 'address.rb')
|
|
2
|
+
Address.class_eval do
|
|
3
|
+
attr_reader :form, :form_attributes
|
|
4
|
+
|
|
5
|
+
before_save :check_form_attributes
|
|
6
|
+
|
|
7
|
+
def initialize(*params)
|
|
8
|
+
super(*params)
|
|
9
|
+
@form_attributes = {} unless form_attributes
|
|
10
|
+
@form = Form.find_by_model('Address')
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def check_form_attributes
|
|
14
|
+
form.form_attributes.all(:conditions => {:attributes_forms => {:validate => true}}).each do |form_attribute|
|
|
15
|
+
errors.add(form_attribute.access_method, I18n.t('activerecord.errors.messages.blank')) if form_attributes[form_attribute.access_method].blank?
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
class Notifier < ActionMailer::Base
|
|
3
|
+
|
|
4
|
+
helper_method :price_with_currency
|
|
5
|
+
helper :application
|
|
6
|
+
include ActionController::UrlWriter
|
|
7
|
+
|
|
8
|
+
def validation_user_account(user, password)
|
|
9
|
+
|
|
10
|
+
@user = user
|
|
11
|
+
@password = password
|
|
12
|
+
|
|
13
|
+
mail(
|
|
14
|
+
:from => Setting.current.email,
|
|
15
|
+
:to => user.email,
|
|
16
|
+
:subject => "[#{Setting.current.name}] #{I18n.t(:subject, :scope => [:emails, :new_account])}"
|
|
17
|
+
)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def reset_password(user)
|
|
21
|
+
@user = user
|
|
22
|
+
|
|
23
|
+
mail(
|
|
24
|
+
:to => user.email,
|
|
25
|
+
:from => Setting.current.email,
|
|
26
|
+
:subject "[#{Setting.current.name}] #{I18n.t(:subject, :scope => [:emails, :reset_password])}"
|
|
27
|
+
)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def newsletter(email)
|
|
31
|
+
@email = email
|
|
32
|
+
mail(
|
|
33
|
+
:to => email,
|
|
34
|
+
:subject "[#{Setting.current.name}] #{I18n.t(:subject, :scope => [:emails, :newsletter])}",
|
|
35
|
+
:from => Setting.current.email
|
|
36
|
+
)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def order_confirmation(user, order)
|
|
40
|
+
|
|
41
|
+
@user = user
|
|
42
|
+
@order = order
|
|
43
|
+
@address_delivery = order.address_delivery
|
|
44
|
+
@address_invoice = order.address_invoice
|
|
45
|
+
@url = url_for(:action=>"root", :controller=>"url_catcher")
|
|
46
|
+
|
|
47
|
+
# Rendering PDF file
|
|
48
|
+
#TODO check PDFKIT and pdf mime_type
|
|
49
|
+
current_body = {
|
|
50
|
+
:user_fullname => order.user.fullname,
|
|
51
|
+
:order_total => order.total,
|
|
52
|
+
:order => order,
|
|
53
|
+
:order_details => order.order_details,
|
|
54
|
+
:user => user,
|
|
55
|
+
:address_invoice => order.address_invoice,
|
|
56
|
+
:address_delivery => order.address_delivery
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
html = render(:file => '/orders/show.pdf.haml', :body => current_body, :layout => 'order_pdf')
|
|
60
|
+
|
|
61
|
+
kit = PDFKit.new(html, :title => "#{I18n.t(:order, :scope => [:emails, :order_confirmation]).capitalize} #{order.reference}" )
|
|
62
|
+
kit.stylesheets = [Rails.root.join('public', 'stylesheets', 'front', 'invoice-print.css')]
|
|
63
|
+
|
|
64
|
+
attachments["#{application.parameterize('_')}_#{I18n.t(:order, :scope => [:emails, :order_confirmation])}_#{order.reference}.pdf"] = kit.to_pdf
|
|
65
|
+
|
|
66
|
+
mail(
|
|
67
|
+
:to => user.email,
|
|
68
|
+
:from => Setting.current.email,
|
|
69
|
+
:subject => "[#{Setting.current.name}] #{I18n.t(:subject, :scope => [:emails, :order_confirmation], :id => order.reference)}"
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def waiting_for_cheque_notification(order)
|
|
75
|
+
@order = order
|
|
76
|
+
mail(
|
|
77
|
+
:to => order.user.email,
|
|
78
|
+
:from => Setting.current.email,
|
|
79
|
+
:subject => "[#{Setting.current.name}] #{I18n.t(:subject, :scope => [:emails, :waiting_for_cheque_notification])}"
|
|
80
|
+
)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
private
|
|
84
|
+
def price_with_currency(price)
|
|
85
|
+
template.number_to_currency(price, :precision => 2, :unit => '€')
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
end
|