comable_frontend 0.2.1 → 0.2.2
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.
- checksums.yaml +4 -4
- data/app/controllers/comable/carts_controller.rb +12 -9
- data/app/controllers/comable/customers_controller.rb +8 -0
- data/app/controllers/comable/orders_controller.rb +6 -19
- data/app/views/comable/carts/show.slim +3 -1
- data/app/views/comable/customers/show.slim +2 -0
- data/app/views/layouts/comable/application.slim +9 -0
- data/config/routes.rb +4 -0
- metadata +20 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca2beaee12b666d7de3aeb8c5ba9c884b325fac9
|
4
|
+
data.tar.gz: b359b988a3320bf139e1cc3b9fea8925ffa733bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ca78ddf6ef0ec1b15b64fba72eea53f2691a7ced2a389a54142c5c4708a53c59262161ce45f8020f593208220ec34f49129222b173671be9a81b04a7dfada30
|
7
|
+
data.tar.gz: f2f7f1a40860083fe4a0bdd0153458db2e0c38326af59076924189fb96a2c021b72e077ab46a65d96bf857142a4580c4385ab73be28ce0ae975d7a68746092b9
|
@@ -2,14 +2,9 @@ module Comable
|
|
2
2
|
class CartsController < Comable::ApplicationController
|
3
3
|
rescue_from Comable::NoStock, with: :no_stock
|
4
4
|
|
5
|
-
def show
|
6
|
-
end
|
7
|
-
|
8
5
|
def add
|
9
|
-
cart_item =
|
10
|
-
cart_item ||= Comable::Product.where(id: params[:product_id]).first
|
6
|
+
cart_item = find_cart_item
|
11
7
|
return redirect_by_product_not_found unless cart_item
|
12
|
-
return redirect_by_product_not_found if cart_item.is_a?(Comable::Product) && cart_item.sku?
|
13
8
|
|
14
9
|
current_customer.add_cart_item(cart_item, cart_item_options)
|
15
10
|
|
@@ -18,10 +13,10 @@ module Comable
|
|
18
13
|
end
|
19
14
|
|
20
15
|
def update
|
21
|
-
|
22
|
-
return redirect_by_product_not_found unless
|
16
|
+
cart_item = find_cart_item
|
17
|
+
return redirect_by_product_not_found unless cart_item
|
23
18
|
|
24
|
-
current_customer.reset_cart_item(
|
19
|
+
current_customer.reset_cart_item(cart_item, cart_item_options)
|
25
20
|
|
26
21
|
flash[:notice] = I18n.t('comable.carts.update')
|
27
22
|
redirect_to cart_path
|
@@ -39,6 +34,14 @@ module Comable
|
|
39
34
|
redirect_to cart_path
|
40
35
|
end
|
41
36
|
|
37
|
+
def find_cart_item
|
38
|
+
cart_item = Comable::Stock.where(id: params[:stock_id]).first
|
39
|
+
cart_item ||= Comable::Product.where(id: params[:product_id]).first
|
40
|
+
return unless cart_item
|
41
|
+
return if cart_item.is_a?(Comable::Product) && cart_item.sku?
|
42
|
+
cart_item
|
43
|
+
end
|
44
|
+
|
42
45
|
def cart_item_options
|
43
46
|
options = {}
|
44
47
|
options.update(quantity: params[:quantity].to_i) if params[:quantity]
|
@@ -5,15 +5,10 @@ module Comable
|
|
5
5
|
|
6
6
|
before_filter :load_order
|
7
7
|
before_filter :verify
|
8
|
-
before_filter :redirect_for_logged_in_customer, only: [:new, :orderer]
|
9
8
|
after_filter :save_order, except: :create
|
10
9
|
|
11
|
-
rescue_from ActiveRecord::RecordInvalid, with: :record_invalid
|
12
10
|
rescue_from Comable::InvalidOrder, with: :order_invalid
|
13
11
|
|
14
|
-
def new
|
15
|
-
end
|
16
|
-
|
17
12
|
def orderer
|
18
13
|
case request.method_symbol
|
19
14
|
when :post
|
@@ -28,14 +23,11 @@ module Comable
|
|
28
23
|
end
|
29
24
|
end
|
30
25
|
|
31
|
-
def confirm
|
32
|
-
end
|
33
|
-
|
34
26
|
def create
|
35
27
|
order = current_customer.order
|
36
28
|
if order.complete?
|
37
|
-
Comable::OrderMailer.complete(order).deliver if current_store.email_activate?
|
38
29
|
flash[:notice] = I18n.t('comable.orders.success')
|
30
|
+
send_order_complete_mail
|
39
31
|
else
|
40
32
|
flash[:alert] = I18n.t('comable.orders.failure')
|
41
33
|
redirect_to comable.confirm_order_path
|
@@ -44,6 +36,10 @@ module Comable
|
|
44
36
|
|
45
37
|
private
|
46
38
|
|
39
|
+
def send_order_complete_mail
|
40
|
+
Comable::OrderMailer.complete(@order).deliver if current_store.email_activate?
|
41
|
+
end
|
42
|
+
|
47
43
|
def next_order_path(target_action_name = nil)
|
48
44
|
case (target_action_name || action_name).to_sym
|
49
45
|
when :delivery
|
@@ -97,18 +93,9 @@ module Comable
|
|
97
93
|
)
|
98
94
|
end
|
99
95
|
|
100
|
-
def
|
101
|
-
return redirect_to delivery_order_path if current_customer.logged_in?
|
102
|
-
end
|
103
|
-
|
104
|
-
def record_invalid
|
96
|
+
def order_invalid
|
105
97
|
flash[:alert] = I18n.t('comable.orders.failure')
|
106
98
|
redirect_to comable.cart_path
|
107
99
|
end
|
108
|
-
|
109
|
-
def order_invalid(exception)
|
110
|
-
flash[:alert] = exception.message
|
111
|
-
redirect_to comable.cart_path
|
112
|
-
end
|
113
100
|
end
|
114
101
|
end
|
@@ -12,7 +12,16 @@ html
|
|
12
12
|
= stylesheet_link_tag "comable/application", media: "all"
|
13
13
|
= javascript_include_tag "comable/application"
|
14
14
|
= csrf_meta_tags
|
15
|
+
|
15
16
|
body
|
16
17
|
- flash.each do |name, msg|
|
17
18
|
= content_tag(:div, msg, id: "flash_#{name}")
|
19
|
+
|
20
|
+
nav
|
21
|
+
ul
|
22
|
+
- if current_customer.signed_in?
|
23
|
+
li = link_to 'Logout', comable.destroy_customer_session_path, method: :delete
|
24
|
+
- else
|
25
|
+
li = link_to 'Login', comable.new_customer_session_path
|
26
|
+
|
18
27
|
== yield
|
data/config/routes.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: comable_frontend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- YOSHIDA Hiroki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: comable_core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.2.
|
19
|
+
version: 0.2.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.2.
|
26
|
+
version: 0.2.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: jquery-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description: Provide frontend functions for Comable.
|
56
70
|
email:
|
57
71
|
- hyoshida@appirits.com
|
@@ -63,11 +77,13 @@ files:
|
|
63
77
|
- Rakefile
|
64
78
|
- app/controllers/comable/application_controller.rb
|
65
79
|
- app/controllers/comable/carts_controller.rb
|
80
|
+
- app/controllers/comable/customers_controller.rb
|
66
81
|
- app/controllers/comable/orders_controller.rb
|
67
82
|
- app/controllers/comable/products_controller.rb
|
68
83
|
- app/controllers/concerns/comable/payment_action.rb
|
69
84
|
- app/controllers/concerns/comable/shipment_action.rb
|
70
85
|
- app/views/comable/carts/show.slim
|
86
|
+
- app/views/comable/customers/show.slim
|
71
87
|
- app/views/comable/orders/confirm.slim
|
72
88
|
- app/views/comable/orders/create.slim
|
73
89
|
- app/views/comable/orders/delivery.slim
|