comable_frontend 0.1.0 → 0.2.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.
- checksums.yaml +4 -4
- data/Rakefile +10 -10
- data/app/controllers/comable/orders_controller.rb +18 -19
- data/app/controllers/concerns/comable/payment_action.rb +27 -0
- data/app/controllers/concerns/comable/shipment_action.rb +27 -0
- data/app/views/comable/carts/show.slim +1 -1
- data/app/views/comable/orders/confirm.slim +13 -1
- data/app/views/comable/orders/orderer.slim +1 -0
- data/app/views/comable/orders/shipment.slim +11 -0
- data/app/views/layouts/comable/application.slim +8 -1
- data/config/routes.rb +2 -0
- data/lib/comable/frontend/engine.rb +2 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 818130115846669a1166faed5413d2ae2ed988e9
|
4
|
+
data.tar.gz: d024d10b74212e576fe0b68d3776e4875ea6a5e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fef8557e1d66e73985642526013ee0d7532f873c897b0b6f8e87cf993cbc2970746f46bea364c55e3172c4741dc1ff98453122a334ac26fd7d15bf71bd16e40
|
7
|
+
data.tar.gz: 24d80b8c5c0f182eaa586ceeadcdab503b3841b6b21a5f41e612dfdeb2603beccd5daa3bc246d1207eba241fc03102af5c280f71a156d17a01251734f0a9c92c
|
data/Rakefile
CHANGED
@@ -6,9 +6,6 @@ end
|
|
6
6
|
|
7
7
|
require 'rdoc/task'
|
8
8
|
|
9
|
-
$LOAD_PATH.unshift File.expand_path('..', __FILE__)
|
10
|
-
require 'tasks/release'
|
11
|
-
|
12
9
|
RDoc::Task.new(:rdoc) do |rdoc|
|
13
10
|
rdoc.rdoc_dir = 'rdoc'
|
14
11
|
rdoc.title = 'Comable'
|
@@ -16,11 +13,12 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
16
13
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
17
14
|
end
|
18
15
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
16
|
+
APP_RAKEFILE = File.expand_path('../spec/dummy/Rakefile', __FILE__)
|
17
|
+
load 'rails/tasks/engine.rake'
|
18
|
+
|
19
|
+
if File.exist?('comable.gemspec')
|
20
|
+
$LOAD_PATH.unshift File.expand_path('..', __FILE__)
|
21
|
+
require 'tasks/release'
|
24
22
|
|
25
23
|
namespace :app do
|
26
24
|
namespace :spec do
|
@@ -47,7 +45,7 @@ else
|
|
47
45
|
namespace :migrate do
|
48
46
|
task :all do
|
49
47
|
FRAMEWORKS.each do |framework|
|
50
|
-
command = "cd #{framework} && test -d db && bundle exec rake db:migrate RAILS_ENV=#{Rails.env}
|
48
|
+
command = "cd #{framework} && test -d db && bundle exec rake db:migrate RAILS_ENV=#{Rails.env}"
|
51
49
|
puts command
|
52
50
|
system command
|
53
51
|
end
|
@@ -62,7 +60,7 @@ else
|
|
62
60
|
namespace :reset do
|
63
61
|
task :all do
|
64
62
|
FRAMEWORKS.each do |framework|
|
65
|
-
command = "cd #{framework} && test -d db && bundle exec rake db:migrate:reset RAILS_ENV=#{Rails.env}
|
63
|
+
command = "cd #{framework} && test -d db && bundle exec rake db:migrate:reset RAILS_ENV=#{Rails.env}"
|
66
64
|
puts command
|
67
65
|
system command
|
68
66
|
end
|
@@ -74,6 +72,8 @@ else
|
|
74
72
|
task default: ['app:spec:all', 'rubocop']
|
75
73
|
end
|
76
74
|
|
75
|
+
task default: ['app:spec', 'rubocop']
|
76
|
+
|
77
77
|
Bundler::GemHelper.install_tasks
|
78
78
|
|
79
79
|
# from https://github.com/rspec/rspec-rails/issues/936
|
@@ -1,5 +1,8 @@
|
|
1
1
|
module Comable
|
2
2
|
class OrdersController < ApplicationController
|
3
|
+
prepend Comable::ShipmentAction
|
4
|
+
prepend Comable::PaymentAction
|
5
|
+
|
3
6
|
before_filter :load_order
|
4
7
|
before_filter :verify
|
5
8
|
before_filter :redirect_for_logged_in_customer, only: [:new, :orderer]
|
@@ -8,8 +11,6 @@ module Comable
|
|
8
11
|
rescue_from ActiveRecord::RecordInvalid, with: :record_invalid
|
9
12
|
rescue_from Comable::InvalidOrder, with: :order_invalid
|
10
13
|
|
11
|
-
include Decoratable
|
12
|
-
|
13
14
|
def new
|
14
15
|
end
|
15
16
|
|
@@ -23,14 +24,7 @@ module Comable
|
|
23
24
|
def delivery
|
24
25
|
case request.method_symbol
|
25
26
|
when :post
|
26
|
-
redirect_to
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def payment
|
31
|
-
case request.method_symbol
|
32
|
-
when :post
|
33
|
-
redirect_to comable.confirm_order_path
|
27
|
+
redirect_to next_order_path
|
34
28
|
end
|
35
29
|
end
|
36
30
|
|
@@ -40,6 +34,7 @@ module Comable
|
|
40
34
|
def create
|
41
35
|
order = current_customer.order
|
42
36
|
if order.complete?
|
37
|
+
Comable::OrderMailer.complete(order).deliver if current_store.email_activate?
|
43
38
|
flash[:notice] = I18n.t('comable.orders.success')
|
44
39
|
else
|
45
40
|
flash[:alert] = I18n.t('comable.orders.failure')
|
@@ -49,6 +44,17 @@ module Comable
|
|
49
44
|
|
50
45
|
private
|
51
46
|
|
47
|
+
def next_order_path(target_action_name = nil)
|
48
|
+
case (target_action_name || action_name).to_sym
|
49
|
+
when :delivery
|
50
|
+
shipment_required? ? comable.shipment_order_path : next_order_path(:shipment)
|
51
|
+
when :shipment
|
52
|
+
payment_required? ? comable.payment_order_path : next_order_path(:payment)
|
53
|
+
else
|
54
|
+
comable.confirm_order_path
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
52
58
|
def verify
|
53
59
|
return if current_customer.cart.any?
|
54
60
|
flash[:alert] = I18n.t('comable.carts.empty')
|
@@ -70,15 +76,14 @@ module Comable
|
|
70
76
|
order_params_for_orderer
|
71
77
|
when :delivery
|
72
78
|
order_params_for_delivery
|
73
|
-
when :payment
|
74
|
-
order_params_for_payment
|
75
79
|
end
|
76
80
|
end
|
77
81
|
|
78
82
|
def order_params_for_orderer
|
79
83
|
params.require(:order).permit(
|
80
84
|
:family_name,
|
81
|
-
:first_name
|
85
|
+
:first_name,
|
86
|
+
:email
|
82
87
|
)
|
83
88
|
end
|
84
89
|
|
@@ -92,12 +97,6 @@ module Comable
|
|
92
97
|
)
|
93
98
|
end
|
94
99
|
|
95
|
-
def order_params_for_payment
|
96
|
-
params.require(:order).permit(
|
97
|
-
Comable::Payment.table_name.singularize.foreign_key.to_sym
|
98
|
-
)
|
99
|
-
end
|
100
|
-
|
101
100
|
def redirect_for_logged_in_customer
|
102
101
|
return redirect_to delivery_order_path if current_customer.logged_in?
|
103
102
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Comable
|
2
|
+
module PaymentAction
|
3
|
+
def payment
|
4
|
+
case request.method_symbol
|
5
|
+
when :post
|
6
|
+
redirect_to next_order_path
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
# orderride OrdersController#order_params
|
13
|
+
def order_params
|
14
|
+
(action_name.to_sym == :payment) ? order_params_for_payment : super
|
15
|
+
end
|
16
|
+
|
17
|
+
def payment_required?
|
18
|
+
Comable::Payment.exists?
|
19
|
+
end
|
20
|
+
|
21
|
+
def order_params_for_payment
|
22
|
+
params.fetch(:order, {}).permit(
|
23
|
+
:comable_payment_id
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Comable
|
2
|
+
module ShipmentAction
|
3
|
+
def shipment
|
4
|
+
case request.method_symbol
|
5
|
+
when :post
|
6
|
+
redirect_to next_order_path
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
# orderride OrdersController#order_params
|
13
|
+
def order_params
|
14
|
+
(action_name.to_sym == :shipment) ? order_params_for_shipment : super
|
15
|
+
end
|
16
|
+
|
17
|
+
def shipment_required?
|
18
|
+
Comable::ShipmentMethod.activated.exists?
|
19
|
+
end
|
20
|
+
|
21
|
+
def order_params_for_shipment
|
22
|
+
params.fetch(:order, {}).permit(
|
23
|
+
:shipment_method_id
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -2,12 +2,15 @@ h1 注文情報確認
|
|
2
2
|
|
3
3
|
.order
|
4
4
|
.orderer
|
5
|
+
h2 注文者
|
5
6
|
.family_name
|
6
7
|
= @order.family_name
|
7
8
|
.first_name
|
8
9
|
= @order.first_name
|
10
|
+
|
9
11
|
.deliveries
|
10
|
-
- @order.order_deliveries.each do |order_delivery|
|
12
|
+
- @order.order_deliveries.each.with_index(1) do |order_delivery, index|
|
13
|
+
h2 = "配送先[#{index}]"
|
11
14
|
.first_name
|
12
15
|
= order_delivery.family_name
|
13
16
|
.first_name
|
@@ -21,5 +24,14 @@ h1 注文情報確認
|
|
21
24
|
.quantity
|
22
25
|
= order_detail.quantity
|
23
26
|
|
27
|
+
.total
|
28
|
+
h2 お会計
|
29
|
+
.item_total_price
|
30
|
+
= @order.current_item_total_price
|
31
|
+
.shipment_fee
|
32
|
+
= @order.current_shipment_fee
|
33
|
+
.total_price
|
34
|
+
= @order.current_total_price
|
35
|
+
|
24
36
|
= form_for @order, as: :order, url: comable.order_path, method: :post do |f|
|
25
37
|
= f.submit
|
@@ -4,4 +4,5 @@ h1 注文者情報入力
|
|
4
4
|
= form_for @order, as: :order, url: comable.orderer_order_path, method: :put do |f|
|
5
5
|
= f.text_field :family_name, placeholder: '姓'
|
6
6
|
= f.text_field :first_name, placeholder: '名'
|
7
|
+
= f.email_field :email, placeholder: @order.class.human_attribute_name(:email)
|
7
8
|
= f.submit
|
@@ -0,0 +1,11 @@
|
|
1
|
+
h1 発送方法
|
2
|
+
|
3
|
+
.order.shipment
|
4
|
+
= form_for @order, as: :order, url: comable.shipment_order_path, method: :put do |f|
|
5
|
+
ul
|
6
|
+
- Comable::ShipmentMethod.activated.each.with_index do |shipment_method, index|
|
7
|
+
li
|
8
|
+
- checked_flag = @order.shipment_method ? (@order.shipment_method.id == shipment_method.id) : index.zero?
|
9
|
+
= f.radio_button :shipment_method_id, shipment_method.id, checked: checked_flag
|
10
|
+
= f.label :shipment_method_id, shipment_method.name, value: shipment_method.id
|
11
|
+
= f.submit
|
@@ -1,7 +1,14 @@
|
|
1
1
|
doctype html
|
2
2
|
html
|
3
3
|
head
|
4
|
-
title
|
4
|
+
title = current_store.name
|
5
|
+
|
6
|
+
- if current_store.meta_keyword.present?
|
7
|
+
meta name="keywords" content="#{current_store.meta_keyword}"
|
8
|
+
|
9
|
+
- if current_store.meta_description.present?
|
10
|
+
meta name="description" content="#{current_store.meta_description}"
|
11
|
+
|
5
12
|
= stylesheet_link_tag "comable/application", media: "all"
|
6
13
|
= javascript_include_tag "comable/application"
|
7
14
|
= csrf_meta_tags
|
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.
|
4
|
+
version: 0.2.0
|
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-09-
|
11
|
+
date: 2014-09-28 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.
|
19
|
+
version: 0.2.0
|
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.
|
26
|
+
version: 0.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -65,6 +65,8 @@ files:
|
|
65
65
|
- app/controllers/comable/carts_controller.rb
|
66
66
|
- app/controllers/comable/orders_controller.rb
|
67
67
|
- app/controllers/comable/products_controller.rb
|
68
|
+
- app/controllers/concerns/comable/payment_action.rb
|
69
|
+
- app/controllers/concerns/comable/shipment_action.rb
|
68
70
|
- app/views/comable/carts/show.slim
|
69
71
|
- app/views/comable/orders/confirm.slim
|
70
72
|
- app/views/comable/orders/create.slim
|
@@ -72,6 +74,7 @@ files:
|
|
72
74
|
- app/views/comable/orders/new.slim
|
73
75
|
- app/views/comable/orders/orderer.slim
|
74
76
|
- app/views/comable/orders/payment.slim
|
77
|
+
- app/views/comable/orders/shipment.slim
|
75
78
|
- app/views/comable/products/index.slim
|
76
79
|
- app/views/comable/products/show.slim
|
77
80
|
- app/views/layouts/comable/application.slim
|