comable_core 0.3.3 → 0.3.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ea4dbaa8dfc838607fcec82a1fc77d7c36854669
4
- data.tar.gz: cabc6a6dab76d530e84c2e569aa26a6888a27aff
3
+ metadata.gz: eff5ae9b60000ce4171fd14e7848dc952cd084eb
4
+ data.tar.gz: dd80b2206c1d2ac96a99421760547bcc4bd0717f
5
5
  SHA512:
6
- metadata.gz: c1a205986c287b466329fad23c3bf44a1fe6379eff5ee6a4720208ff41212a3ad96b205a0e0fa7bcd6aada1871cbccf575cb076e50df795e296fc5e85e98c39a
7
- data.tar.gz: a7cff0da79f6f1070520c26c61822cf4a67b7e7b373e8e5b17ede7d34d29b2cf8f2e3e7a446787c6edb3578a164e4ef9e97c4c33529ba9691accef16fd3db466
6
+ metadata.gz: d6ba4f76bc521aa0fb526ce74fbdcfe7020ae7ab1db57e911da4434fbc275917436bcb02a84af19b317dfda3de47cd85e21dd83e42d37a1da4519220f57595dc
7
+ data.tar.gz: 598942cd5f8e84f1cc2bd6fc2e51465d99e24474cbfa2c83b1e5fe44ae92254b4b0b2308e7fbfa8819cd2c2f0d35ddb4b589a9883b26ee101e543c5f9101948f
@@ -62,7 +62,7 @@ module Comable
62
62
  content_tag(:div, class: 'radio') do
63
63
  content_tag(:label) do
64
64
  html = ''
65
- html << radio_button_tag(:stock_id, stock.id, false, disabled: stock.soldout?)
65
+ html << radio_button_tag(:stock_id, stock.id, false, disabled: stock.unstocked?)
66
66
  html << stock.code
67
67
  html.html_safe
68
68
  end
@@ -22,7 +22,7 @@ module Comable
22
22
  def find_by_path_name(path_name, root: nil, delimiter: DEFAULT_PATH_NAME_DELIMITER)
23
23
  names = path_name.split(delimiter)
24
24
  names.inject(root) do |category, name|
25
- (category ? category.children : roots).find_by(name: name) || return
25
+ (category ? category.children : roots).find_by(name: name) || break
26
26
  end
27
27
  end
28
28
 
@@ -1,7 +1,8 @@
1
1
  module Comable
2
2
  class Customer < ActiveRecord::Base
3
- include CartOwner
4
- include RoleOwner
3
+ include Comable::CartOwner
4
+ include Comable::RoleOwner
5
+ include Comable::Ransackable
5
6
 
6
7
  has_many :orders, class_name: Comable::Order.name
7
8
  has_many :addresses, class_name: Comable::Address.name, dependent: :destroy
@@ -16,6 +17,8 @@ module Comable
16
17
 
17
18
  devise(*Comable::Config.devise_strategies[:customer])
18
19
 
20
+ ransack_options ransackable_attributes: { except: [:encrypted_password, :reset_password_token, :reset_password_sent_at, :remember_created_at, :bill_address_id, :ship_address_id] }
21
+
19
22
  delegate :full_name, to: :bill_address, allow_nil: true, prefix: :bill
20
23
  delegate :full_name, to: :ship_address, allow_nil: true, prefix: :ship
21
24
 
@@ -63,7 +66,7 @@ module Comable
63
66
  end
64
67
 
65
68
  def incomplete_order
66
- @incomplete_order ||= find_or_initialize_incomplete_order
69
+ @incomplete_order ||= find_incomplete_order || initialize_incomplete_order
67
70
  end
68
71
 
69
72
  def order(order_params = {})
@@ -94,10 +97,6 @@ module Comable
94
97
  @cookies.signed[:guest_token] if @cookies
95
98
  end
96
99
 
97
- def find_or_initialize_incomplete_order
98
- find_incomplete_order || initialize_incomplete_order
99
- end
100
-
101
100
  def initialize_incomplete_order
102
101
  order = Comable::Order.create(incomplete_order_attributes)
103
102
  @cookies.permanent.signed[:guest_token] = order.guest_token if @cookies
@@ -1,6 +1,8 @@
1
1
  module Comable
2
2
  class Order < ActiveRecord::Base
3
3
  include Comable::Checkout
4
+ include Comable::Ransackable
5
+ include Comable::Order::Morrisable
4
6
 
5
7
  belongs_to :customer, class_name: Comable::Customer.name, autosave: false
6
8
  belongs_to :payment_method, class_name: Comable::PaymentMethod.name, autosave: false
@@ -25,22 +27,11 @@ module Comable
25
27
  scope :this_week, -> { where(completed_at: Time.now.beginning_of_week..Time.now.end_of_week) }
26
28
  scope :last_week, -> { where(completed_at: 1.week.ago.beginning_of_week..1.week.ago.end_of_week) }
27
29
 
30
+ ransack_options ransackable_attributes: { except: [:shipment_method_id, :payment_method_id, :bill_address_id, :ship_address_id] }
31
+
28
32
  delegate :full_name, to: :bill_address, allow_nil: true, prefix: :bill
29
33
  delegate :full_name, to: :ship_address, allow_nil: true, prefix: :ship
30
34
 
31
- class << self
32
- def morris_keys
33
- %w( count price )
34
- end
35
-
36
- def to_morris
37
- this = (Rails::VERSION::MAJOR == 3) ? scoped : all
38
- this.group_by { |order| order.completed_at.to_date }.map do |date, orders|
39
- { date: date, count: orders.count, price: orders.sum(&:total_price) }
40
- end.to_json
41
- end
42
- end
43
-
44
35
  def complete
45
36
  ActiveRecord::Base.transaction do
46
37
  run_callbacks :complete do
@@ -64,10 +55,13 @@ module Comable
64
55
  completed_at && completed_at_was.nil?
65
56
  end
66
57
 
67
- def soldout_stocks
68
- order_details.to_a.select(&:soldout_stock?)
58
+ def stocked_items
59
+ order_details.to_a.select(&:unstocked?)
69
60
  end
70
61
 
62
+ alias_method :soldout_stocks, :stocked_items
63
+ deprecate :soldout_stocks, deprecator: Comable::Deprecator.instance
64
+
71
65
  # 時価商品合計を取得
72
66
  def current_item_total_price
73
67
  order_details.to_a.sum(&:current_subtotal_price)
@@ -0,0 +1,20 @@
1
+ module Comable
2
+ class Order < ActiveRecord::Base
3
+ module Morrisable
4
+ extend ActiveSupport::Concern
5
+
6
+ module ClassMethods
7
+ def morris_keys
8
+ %w( count price )
9
+ end
10
+
11
+ def to_morris
12
+ this = (Rails::VERSION::MAJOR == 3) ? scoped : all
13
+ this.group_by { |order| order.completed_at.to_date }.map do |date, orders|
14
+ { date: date, count: orders.count, price: orders.sum(&:total_price) }
15
+ end.to_json
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -44,19 +44,22 @@ module Comable
44
44
  price * quantity
45
45
  end
46
46
 
47
- def soldout_stock?
47
+ def unstocked?
48
48
  stock_with_clean_quantity do |stock|
49
- stock.soldout?(quantity: quantity)
49
+ stock.unstocked?(quantity: quantity)
50
50
  end
51
51
  end
52
52
 
53
- def valid_stock_quantity
54
- return unless soldout_stock?
55
- errors.add :quantity, Comable.t('errors.messages.product_soldout', name: stock.name_with_sku)
56
- end
53
+ alias_method :soldout_stock?, :unstocked?
54
+ deprecate :soldout_stock?, deprecator: Comable::Deprecator.instance
57
55
 
58
56
  private
59
57
 
58
+ def valid_stock_quantity
59
+ return unless unstocked?
60
+ errors.add :quantity, Comable.t('errors.messages.out_of_stock', name: stock.name_with_sku)
61
+ end
62
+
60
63
  def stock_with_clean_quantity
61
64
  quantity_will = stock.quantity
62
65
  stock.quantity = stock.quantity_was if stock.quantity_was
@@ -2,6 +2,7 @@ module Comable
2
2
  class Product < ActiveRecord::Base
3
3
  include Comable::SkuItem
4
4
  include Comable::Product::Search
5
+ include Comable::Ransackable
5
6
 
6
7
  has_many :stocks, class_name: Comable::Stock.name, dependent: :destroy
7
8
  has_many :images, class_name: Comable::Image.name, dependent: :destroy
@@ -15,6 +16,8 @@ module Comable
15
16
  validates :sku_h_item_name, length: { maximum: 255 }
16
17
  validates :sku_v_item_name, length: { maximum: 255 }
17
18
 
19
+ ransack_options attribute_select: { associations: :stocks }
20
+
18
21
  # Add conditions for the images association.
19
22
  # Override method of the images association to support Rails 3.x.
20
23
  def images
@@ -27,14 +30,20 @@ module Comable
27
30
  'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/PjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMTcxIiBoZWlnaHQ9IjE4MCIgdmlld0JveD0iMCAwIDE3MSAxODAiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPjxkZWZzLz48cmVjdCB3aWR0aD0iMTcxIiBoZWlnaHQ9IjE4MCIgZmlsbD0iI0VFRUVFRSIvPjxnPjx0ZXh0IHg9IjU4IiB5PSI5MCIgc3R5bGU9ImZpbGw6I0FBQUFBQTtmb250LXdlaWdodDpib2xkO2ZvbnQtZmFtaWx5OkFyaWFsLCBIZWx2ZXRpY2EsIE9wZW4gU2Fucywgc2Fucy1zZXJpZiwgbW9ub3NwYWNlO2ZvbnQtc2l6ZToxMHB0O2RvbWluYW50LWJhc2VsaW5lOmNlbnRyYWwiPjE3MXgxODA8L3RleHQ+PC9nPjwvc3ZnPg=='
28
31
  end
29
32
 
30
- def unsold?
31
- stocks.unsold.exists?
33
+ def stocked?
34
+ stocks.stocked.exists?
32
35
  end
33
36
 
34
- def soldout?
35
- !unsold?
37
+ alias_method :unsold?, :stocked?
38
+ deprecate :unsold?, deprecator: Comable::Deprecator.instance
39
+
40
+ def unstocked?
41
+ !stocked?
36
42
  end
37
43
 
44
+ alias_method :soldout?, :unstocked?
45
+ deprecate :soldout?, deprecator: Comable::Deprecator.instance
46
+
38
47
  def category_path_names=(category_path_names, delimiter: Comable::Category::DEFAULT_PATH_NAME_DELIMITER)
39
48
  self.categories = Comable::Category.find_by_path_names(category_path_names, delimiter: delimiter)
40
49
  end
@@ -6,6 +6,7 @@ module Comable
6
6
  class Stock < ActiveRecord::Base
7
7
  include Comable::SkuItem
8
8
  include Comable::SkuChoice
9
+ include Comable::Ransackable
9
10
 
10
11
  belongs_to :product, class_name: Comable::Product.name
11
12
 
@@ -15,11 +16,21 @@ module Comable
15
16
 
16
17
  # @!scope class
17
18
  # 品切れでない在庫インスタンスを返す
18
- scope :unsold, -> { where('quantity > ?', 0) }
19
+ scope :stocked, -> { where('quantity > ?', 0) }
20
+
21
+ class << self
22
+ alias_method :unsold, :stocked
23
+ deprecate :unsold, deprecator: Comable::Deprecator.instance
24
+ end
19
25
 
20
26
  # @!scope class
21
27
  # 品切れの在庫インスタンスを返す
22
- scope :soldout, -> { where('quantity <= ?', 0) }
28
+ scope :unstocked, -> { where('quantity <= ?', 0) }
29
+
30
+ class << self
31
+ alias_method :soldout, :unstocked
32
+ deprecate :soldout, deprecator: Comable::Deprecator.instance
33
+ end
23
34
 
24
35
  #
25
36
  # @!endgroup
@@ -37,28 +48,38 @@ module Comable
37
48
  delegate :sku_h_item_name, to: :product
38
49
  delegate :sku_v_item_name, to: :product
39
50
 
51
+ ransack_options attribute_select: { associations: :product }, ransackable_attributes: { except: :product_id }
52
+
40
53
  # 在庫の有無を取得する
41
54
  #
42
55
  # @example
43
- # stock.unsold? #=> true
56
+ # stock.quanaity = 1
57
+ # stock.stocked? #=> true
44
58
  #
45
59
  # @param quantity [Fixnum] 減算する在庫数を指定する
46
60
  # @return [Boolean] 在庫があれば true を返す
47
- # @see #soldout?
48
- def unsold?(quantity: 1)
61
+ # @see #unstocked?
62
+ def stocked?(quantity: 1)
49
63
  (self.quantity - quantity) >= 0
50
64
  end
51
65
 
66
+ alias_method :unsold?, :stocked?
67
+ deprecate :unsold?, deprecator: Comable::Deprecator.instance
68
+
52
69
  # 在庫の有無を取得する
53
70
  #
54
71
  # @example
55
- # stock.soldout? #=> false
72
+ # stock.quanaity = 1
73
+ # stock.unstocked? #=> false
56
74
  #
57
75
  # @param quantity [Fixnum] 減算する在庫数を指定する
58
- # @return [Boolean] {#unsold?} の逆。在庫がなければ true を返す
59
- # @see #unsold?
60
- def soldout?(quantity: 1)
61
- !unsold?(quantity: quantity)
76
+ # @return [Boolean] {#stocked?} の逆。在庫がなければ true を返す
77
+ # @see #stocked?
78
+ def unstocked?(quantity: 1)
79
+ !stocked?(quantity: quantity)
62
80
  end
81
+
82
+ alias_method :soldout?, :unstocked?
83
+ deprecate :soldout?, deprecator: Comable::Deprecator.instance
63
84
  end
64
85
  end
@@ -0,0 +1,38 @@
1
+ module Comable
2
+ module Ransackable
3
+ extend ActiveSupport::Concern
4
+
5
+ module ClassMethods
6
+ attr_reader :_ransack_options
7
+
8
+ def ransack_options(options = nil)
9
+ if options
10
+ @_ransack_options = options
11
+ else
12
+ @_ransack_options || {}
13
+ end
14
+ end
15
+
16
+ def ransackable_attribute?
17
+ klass.ransackable_attributes(auth_object).include? str
18
+ end
19
+
20
+ def ransackable_attributes(_auth_object = nil)
21
+ ransackable_attributes_options = ransack_options[:ransackable_attributes] || {}
22
+ if ransackable_attributes_options[:only]
23
+ [ransackable_attributes_options[:only]].flatten.map(&:to_s)
24
+ else
25
+ column_names + _ransackers.keys - [ransackable_attributes_options[:except]].flatten.map(&:to_s)
26
+ end
27
+ end
28
+
29
+ def ransackable_association?
30
+ klass.ransackable_associations(auth_object).include? str
31
+ end
32
+
33
+ def ransackable_associations(_auth_object = nil)
34
+ reflect_on_all_associations.map { |a| a.name.to_s }
35
+ end
36
+ end
37
+ end
38
+ end
@@ -9,7 +9,7 @@ module Comable
9
9
  admin
10
10
  reporter
11
11
  customer
12
- ), default: :customer, predicates: true
12
+ ), default: :customer, predicates: true, scope: true
13
13
  end
14
14
  end
15
15
  end
@@ -6,9 +6,14 @@ module Comable
6
6
  module SkuChoice
7
7
  def name_with_sku
8
8
  return name unless sku?
9
+ name + "(#{sku_name})"
10
+ end
11
+
12
+ def sku_name
13
+ return unless sku?
9
14
  sku_name = sku_h_choice_name
10
15
  sku_name += '/' + sku_v_choice_name if sku_v_choice_name.present?
11
- name + "(#{sku_name})"
16
+ sku_name
12
17
  end
13
18
  end
14
19
  end
@@ -0,0 +1,280 @@
1
+ en:
2
+ comable:
3
+ cart: 'Cart'
4
+ shopping_cart: 'Shopping Cart'
5
+ checkout: 'Checkout'
6
+ show_cart: 'Show Cart'
7
+ search: 'Search'
8
+ category: 'Category'
9
+ my_account: 'My Account'
10
+ sign_in: 'Login'
11
+ sign_out: 'Logout'
12
+ guest: 'Guest'
13
+ guest_order: 'Guest Checkout'
14
+ add_to_cart: 'Add to Cart'
15
+ browse_related_products: 'Browse related products'
16
+ reorder: 'Buy it Again'
17
+ change_email_or_password: 'Change email address or password'
18
+ edit_your_address_book: 'Edit your address book'
19
+ address_book: 'Address book'
20
+ order_history: 'Order history'
21
+ next_step: 'Continue'
22
+ use_this_address: 'Use this address'
23
+ complete_order: 'Place your order'
24
+ use_as_billing_address: 'Use as Billing Address'
25
+ use_as_shipping_address: 'Use as Shipping Address'
26
+ new_billing_address: 'New billing address'
27
+ new_shipping_address: 'New shiping address'
28
+ edit_billing_address: 'Edit billing address'
29
+ edit_shipping_address: 'Edit shiping address'
30
+ other_addresses: 'Other addresses'
31
+ new_address: 'New address'
32
+ successful: 'Successful'
33
+ failure: 'Failure'
34
+
35
+ price: &price
36
+ 'Price'
37
+ quantity: &quantity
38
+ 'Quantity'
39
+ item_total_price: &item_total_price
40
+ 'Item total'
41
+ item_total_quantity: &item_total_quantity
42
+ 'Item total quantity'
43
+ soldout:
44
+ 'Soldout'
45
+ honorific: &honorific
46
+ 'Dear %{name}'
47
+
48
+ checkout_flow:
49
+ sign_in: 'Login'
50
+ address_and_payment: 'Address & Payment'
51
+ confirm: 'Confirm'
52
+ complete: 'Place Order'
53
+
54
+ actions:
55
+ new: 'New'
56
+ edit: 'Edit'
57
+ create: 'Create'
58
+ update: 'Update'
59
+ destroy: 'Destroy'
60
+ cancel: 'Cancel'
61
+ continue: 'Continue'
62
+
63
+ errors:
64
+ messages:
65
+ out_of_stock: '(%{name}) was Sold Out.'
66
+ out_of_stocks: 'Sold Out Items.'
67
+ product_not_found: '%{name} could not be found or has been deleted.'
68
+ products_not_found: 'This item could not be found or has been deleted.'
69
+
70
+ carts:
71
+ added: 'An item is added to Cart'
72
+ empty: 'Cart is empty.'
73
+ updated: 'Cart Updated'
74
+ invalid: 'Cart Errored'
75
+
76
+ orders:
77
+ success: 'Your order has been placed.'
78
+ failure: 'Your order has failed. Please check your order again.'
79
+
80
+ order_mailer:
81
+ complete:
82
+ subject: 'Your %{store_name} order has been placed (Order: %{order_code})'
83
+ dear: *honorific
84
+ introductions: |-
85
+ Thank you for shopping with %{store_name}.
86
+ Your order details:
87
+ outroductions: |-
88
+ We hope to see you again soon.
89
+ %{store_name}
90
+
91
+ admin:
92
+ not_found: 'Record not found.'
93
+ general: 'General'
94
+ images: 'Images'
95
+ main_image: 'Main image'
96
+ sub_image: 'Sub image'
97
+ home: 'Home'
98
+ product: 'Product'
99
+ index: 'List'
100
+ search: 'Search'
101
+ back_to_store: 'Back to Store'
102
+ confirmation_to_remove_product: 'This operation cannot be undone. Would you like to proceed?'
103
+ confirmation_to_remove_stock: 'This operation cannot be undone. Would you like to proceed?'
104
+ you_can_drag_and_drop: 'Edit the category tree by drag-and-drop.'
105
+ you_can_right_click: 'Open the context menu by right click.'
106
+ link_to_add_new_node: 'Add a new category from the following link: '
107
+ link_to_add_new_stock: 'Add a new stock from the following link: '
108
+ check_this_product_in_frontend: 'Check this product in Store'
109
+ note: 'NOTE:'
110
+ results: 'results'
111
+ times: 'times'
112
+ more: 'More'
113
+ access_denied: 'Access denied'
114
+ order_count: 'Order count'
115
+ new_orders: 'New Order'
116
+ new_users: 'New User'
117
+ sales: 'Sales'
118
+ better_than_last_week: 'Better than last week (%{percentage}%)'
119
+ edit_profile: 'Edit profile'
120
+ please_fill_when_using_sku: 'Please fill the text fielde when using sku.'
121
+ operation: 'Operation'
122
+ stocks: 'Stocks'
123
+ clear_search_conditions: 'Clear search conditions'
124
+ add_search_condition: 'Add search condition'
125
+ remove_search_condition: '×'
126
+ advanced_search: 'Advanced search'
127
+ bill: 'Billing address'
128
+ ship: 'Shipping address'
129
+ add_sub_image: 'Add a sub image'
130
+ sign_in: 'Login'
131
+ sign_out: 'Logout'
132
+ nav:
133
+ dashboard: 'Dashboard'
134
+ order: 'Orders'
135
+ product: 'Products'
136
+ stock: 'Stocks'
137
+ category: 'Categories'
138
+ customer: 'Users'
139
+ general_settings: 'General settings'
140
+ store: 'Store'
141
+ shipment_method: 'Shipment methods'
142
+ payment_method: 'Payment methods'
143
+ products:
144
+ detail: 'Product details'
145
+ orders:
146
+ detail: 'Order details'
147
+ cart: 'Cart infomation'
148
+ customer: 'User details'
149
+ shipment: 'Shipment fee'
150
+ payment: 'Payment charge'
151
+ customers:
152
+ detail: 'User details'
153
+ edit: 'Editing user'
154
+ new_orders: 'Recently orders (%{count})'
155
+ stores:
156
+ edit: 'Editing store'
157
+ shipment_methods:
158
+ edit: 'Editing shipment method'
159
+ payment_methods:
160
+ edit: 'Editing payment method'
161
+ actions:
162
+ index: 'List'
163
+ new: 'New'
164
+ edit: 'Edit'
165
+ update: 'Update'
166
+ destroy: 'Destroy'
167
+ save: 'Save'
168
+ cancel: 'Cancel'
169
+ categories:
170
+ new_node: 'New category'
171
+
172
+ activerecord:
173
+ state_machines:
174
+ comable/order:
175
+ state:
176
+ states:
177
+ cart: 'Cart'
178
+ orderer: 'Billing address'
179
+ delivery: 'Shipping address'
180
+ shipment: 'Shipment method'
181
+ payment: 'Payment method'
182
+ confirm: 'Order confirmed'
183
+ complete: 'Order placed'
184
+
185
+ models:
186
+ comable/order: 'Orders'
187
+ comable/order_details: 'Order details'
188
+
189
+ attributes:
190
+ comable/customer:
191
+ id: 'ID'
192
+ email: 'Email address'
193
+ password: 'Password'
194
+ password_confirmation: 'Password (confirmation)'
195
+ current_password: 'Current password'
196
+ bill_address: 'Billing address'
197
+ ship_address: 'Shipping address'
198
+ bill_full_name: 'Full name of the billing address'
199
+ orders: 'Orders'
200
+ role: 'Role'
201
+ comable/order:
202
+ code: 'Order number'
203
+ email: 'Email address'
204
+ bill_address: 'Billing address'
205
+ ship_address: 'Shipping address'
206
+ payment_method: 'Payment method'
207
+ shipment_method: 'Shipment method'
208
+ shipment_fee: 'Shipment fee'
209
+ item_total_price: 'Item total'
210
+ total_price: 'Total'
211
+ order_details: 'Order details'
212
+ completed_at: 'Comleted at'
213
+ state: 'State'
214
+ bill_address: 'Billing address'
215
+ ship_address: 'Shipping adress'
216
+ bill_full_name: 'Full name of the billing address'
217
+ order_details: 'Order details'
218
+ comable/order_detail: &comable_order_detail
219
+ quantity: *quantity
220
+ price: *price
221
+ product: 'Product'
222
+ subtotal_price: 'Subtotal'
223
+ comable/address: &comable_address
224
+ full_name: 'Full name'
225
+ family_name: 'Last name'
226
+ first_name: 'First name'
227
+ state_name: 'State name'
228
+ zip_code: 'Zip code'
229
+ city: 'City'
230
+ detail: 'Detail'
231
+ phone_number: 'Phone number'
232
+ comable/product:
233
+ code: 'Code'
234
+ name: 'Name'
235
+ price: 'Price'
236
+ caption: 'Caption'
237
+ categories: 'Categories'
238
+ sku_h_item_name: 'SKU Horizontal item name'
239
+ sku_v_item_name: 'SKU Vertical item name'
240
+ comable/stock:
241
+ code: 'SKU Code'
242
+ quantity: 'Quantity'
243
+ sku_h_choice_name: 'SKU Horizontal choice name'
244
+ sku_v_choice_name: 'SKU Vertical choice name'
245
+ comable/store:
246
+ name: 'Name'
247
+ meta_keywords: 'Meta keywords'
248
+ meta_description: 'Meta description'
249
+ email_sender: 'Email sender'
250
+ email_activate_flag: 'Email activated'
251
+ comable/shipment_method:
252
+ name: 'Name'
253
+ fee: 'Fee'
254
+ activate_flag: 'Activated'
255
+ traking_url: 'Tracking URL'
256
+ comable/payment_method:
257
+ name: 'Name'
258
+ payment_provider: 'Oayment provider'
259
+ enable_price: 'Enable price range'
260
+ comable/order/order_details:
261
+ <<: *comable_order_detail
262
+ comable/order/bill_address:
263
+ <<: *comable_address
264
+ comable/order/ship_address:
265
+ <<: *comable_address
266
+
267
+ enumerize:
268
+ comable/customer:
269
+ role:
270
+ customer: 'Customer'
271
+ reporter: 'Reporter'
272
+ admin: 'Administrator'
273
+
274
+ views:
275
+ pagination:
276
+ first: "&laquo; First"
277
+ last: "Last &raquo;"
278
+ next: "Next &rsaquo;"
279
+ previous: "&lsaquo; Previous"
280
+ truncate: "&hellip;"
@@ -40,7 +40,7 @@ ja:
40
40
  '合計価格'
41
41
  item_total_quantity: &item_total_quantity
42
42
  '合計商品数'
43
- soldout: &soldout
43
+ soldout:
44
44
  '品切れ'
45
45
  honorific: &honorific
46
46
  '%{name} 様'
@@ -62,8 +62,8 @@ ja:
62
62
 
63
63
  errors:
64
64
  messages:
65
- product_soldout: '(%{name})が在庫を超過しています。'
66
- products_soldout: '在庫を超過する個数の注文が含まれている可能性があります。'
65
+ out_of_stock: '(%{name})が在庫を超過しています。'
66
+ out_of_stocks: '在庫を超過する個数の注文が含まれている可能性があります。'
67
67
  product_not_found: '%{name}は存在しないか削除された可能性があります。'
68
68
  products_not_found: 'ご指定の商品は存在しないか削除された可能性があります。'
69
69
 
@@ -72,7 +72,6 @@ ja:
72
72
  empty: 'カートに商品が入っていません'
73
73
  updated: 'カートの内容が変更されました'
74
74
  invalid: 'カートにいくつかのエラーがあります'
75
- soldout: *soldout
76
75
 
77
76
  orders:
78
77
  success: '注文が完了しました'
@@ -122,6 +121,9 @@ ja:
122
121
  operation: 操作
123
122
  stocks: 在庫
124
123
  clear_search_conditions: 検索条件をクリア
124
+ add_search_condition: 検索条件を追加
125
+ remove_search_condition: '×'
126
+ advanced_search: 詳細検索
125
127
  bill: 請求先
126
128
  ship: 配送先
127
129
  add_sub_image: サブ画像を追加
@@ -196,7 +198,13 @@ ja:
196
198
  bill_full_name: 配送先氏名
197
199
  orders: 注文数
198
200
  role: 権限
201
+ sign_in_count: ログイン回数
202
+ current_sign_in_at: ログイン日時
203
+ last_sign_in_at: 最終ログイン日時
204
+ current_sign_in_ip: ログインIP
205
+ last_sign_in_ip: 最終ログインIP
199
206
  comable/order:
207
+ id: ID
200
208
  code: 注文番号
201
209
  email: メールアドレス
202
210
  bill_address: ご請求先
@@ -213,6 +221,9 @@ ja:
213
221
  ship_address: 配送先住所
214
222
  bill_full_name: 配送先氏名
215
223
  order_details: 注文明細
224
+ customer_id: ユーザーID
225
+ guest_token: ゲストトークン
226
+ shipment_tracking_number: 発送トラッキング番号
216
227
  comable/order_detail: &comable_order_detail
217
228
  quantity: *quantity
218
229
  price: *price
@@ -228,6 +239,7 @@ ja:
228
239
  detail: その他
229
240
  phone_number: 電話番号
230
241
  comable/product:
242
+ id: ID
231
243
  code: 商品コード
232
244
  name: 商品名
233
245
  price: 価格
@@ -236,6 +248,7 @@ ja:
236
248
  sku_h_item_name: SKU横軸項目名
237
249
  sku_v_item_name: SKU縦軸項目名
238
250
  comable/stock:
251
+ id: ID
239
252
  code: SKU商品コード
240
253
  quantity: 在庫
241
254
  sku_h_choice_name: SKU横軸選択肢名
@@ -276,3 +289,10 @@ ja:
276
289
  next: "次 &rsaquo;"
277
290
  previous: "&lsaquo; 前"
278
291
  truncate: "&hellip;"
292
+
293
+ ransack:
294
+ predicates:
295
+ gteq: 以上
296
+ lteq: 以下
297
+ eq_any_splitted: 完全一致
298
+ cont_any_splitted: 部分一致
data/db/seeds.rb ADDED
@@ -0,0 +1,5 @@
1
+ seeds_path = File.join(File.dirname(__FILE__), 'seeds')
2
+
3
+ Dir.glob(File.join(seeds_path, '**/*.rb')).sort.each do |fixture_file|
4
+ require fixture_file
5
+ end
@@ -0,0 +1,51 @@
1
+ require 'highline/import'
2
+
3
+ def default_email
4
+ 'comable@example.com'
5
+ end
6
+
7
+ def default_password
8
+ 'password'
9
+ end
10
+
11
+ def ask_admin_email
12
+ if ENV['ADMIN_EMAIL']
13
+ ENV['ADMIN_EMAIL']
14
+ else
15
+ ask("Email [#{default_email}]: ") do |q|
16
+ q.echo = true
17
+ q.whitespace = :strip
18
+ end
19
+ end.presence || default_email
20
+ end
21
+
22
+ def ask_admin_password
23
+ if ENV['ADMIN_PASSWORD']
24
+ ENV['ADMIN_PASSWORD']
25
+ else
26
+ ask("Password [#{default_password}]: ") do |q|
27
+ q.echo = false
28
+ q.whitespace = :strip
29
+ end
30
+ end.presence || default_password
31
+ end
32
+
33
+ def create_admin_user
34
+ email = ask_admin_email
35
+ password = ask_admin_password
36
+
37
+ if Comable::Customer.where(email: email).exists?
38
+ puts "WARNING: The email address has already existed: #{email}"
39
+ else
40
+ Comable::Customer.with_role(:admin).new do |obj|
41
+ obj.email = email
42
+ obj.password = password
43
+ end.save!
44
+ end
45
+ end
46
+
47
+ if Comable::Customer.with_role(:admin).exists?
48
+ puts 'Admin user has already been previously created.'
49
+ else
50
+ create_admin_user
51
+ end
@@ -0,0 +1,26 @@
1
+ if Rails::VERSION::MAJOR > 3
2
+ module Comable
3
+ class Deprecator < ActiveSupport::Deprecation
4
+ def initialize(deprecation_horizon = '0.4.0', gem_name = 'Comable')
5
+ super
6
+ end
7
+ end
8
+ end
9
+ else
10
+ # TODO: Deprecated itself!
11
+ module Comable
12
+ class Deprecator
13
+ include Singleton
14
+ end
15
+ end
16
+
17
+ class Module
18
+ def deprecate_with_deprecator(*method_names)
19
+ options = method_names.extract_options!
20
+ options.delete(:deprecator) if options.present?
21
+ deprecate_without_deprecator
22
+ end
23
+
24
+ alias_method_chain :deprecate, :deprecator
25
+ end
26
+ end
data/lib/comable_core.rb CHANGED
@@ -12,6 +12,7 @@ require 'comable/core/engine'
12
12
  require 'comable/errors'
13
13
  require 'comable/payment_provider'
14
14
  require 'comable/state_machine_patch'
15
+ require 'comable/deprecator'
15
16
 
16
17
  module Comable
17
18
  class << self
@@ -0,0 +1,128 @@
1
+ require 'rails/generators'
2
+ require 'bundler'
3
+ require 'bundler/cli'
4
+
5
+ module Comable
6
+ class InstallGenerator < Rails::Generators::Base
7
+ class_option :migrate, type: :boolean, default: true, banner: 'Run Comable migrations'
8
+ class_option :seed, type: :boolean, default: true, banner: 'Load seed data (migrations must be run)'
9
+ class_option :admin_email, type: :string
10
+ class_option :admin_password, type: :string
11
+
12
+ class << self
13
+ def source_paths
14
+ paths = superclass.source_paths
15
+ paths << File.expand_path('../templates', __FILE__)
16
+ paths.flatten
17
+ end
18
+ end
19
+
20
+ def prepare_options
21
+ @migrate_flag = options[:migrate]
22
+ @seed_flag = @migrate_flag ? options[:seed] : false
23
+ end
24
+
25
+ def add_files
26
+ template 'config/initializers/comable.rb', 'config/initializers/comable.rb'
27
+ end
28
+
29
+ def configure_application
30
+ application <<-APP
31
+ config.to_prepare do
32
+ # Overriding Models and Controllers
33
+ # refs: http://edgeguides.rubyonrails.org/engines.html#overriding-models-and-controllers
34
+ Dir.glob(Rails.root.join('app/**/*_decorator*.rb')).each do |c|
35
+ Rails.configuration.cache_classes ? require_dependency(c) : load(c)
36
+ end
37
+ end
38
+ APP
39
+ end
40
+
41
+ def append_seeds
42
+ append_file 'db/seeds.rb', <<-SEEDS
43
+ # Seed data for Comable
44
+ Comable::Core::Engine.load_seed if defined?(Comable::Core)
45
+ SEEDS
46
+ end
47
+
48
+ def install_migrations
49
+ say_status :copying, 'migrations'
50
+ quietly { rake 'comable:install:migrations' }
51
+ end
52
+
53
+ def create_database
54
+ say_status :creating, 'database'
55
+ quietly { rake 'db:create' }
56
+ end
57
+
58
+ def run_migrations
59
+ if @migrate_flag
60
+ say_status :running, 'migrations'
61
+ quietly { rake 'db:migrate' }
62
+ else
63
+ say_status :skipping, "migrations (don't forget to run rake db:migrate)"
64
+ end
65
+ end
66
+
67
+ def load_seed_data
68
+ if @seed_flag
69
+ say_status :loading, 'seed data'
70
+ rake_seed
71
+ else
72
+ say_status :skipping, 'seed data (you can always run rake db:seed)'
73
+ end
74
+ end
75
+
76
+ def insert_routes
77
+ insert_into_file File.join('config', 'routes.rb'), after: "Rails.application.routes.draw do\n" do
78
+ <<-ROUTES
79
+ # This line mounts Comable's routes at the root of your application.
80
+ # This means, any requests to URLs such as /products, will go to Comable::ProductsController.
81
+ # If you would like to change where this engine is mounted, simply change the :at option to something different.
82
+ #
83
+ # We ask that you don't use the :as option here, as Comable relies on it being the default of "comable"
84
+ mount Comable::Core::Engine, at: '/'
85
+ ROUTES
86
+ end
87
+
88
+ message_for_insert_routes unless options[:quiet]
89
+ end
90
+
91
+ def complete
92
+ message_for_complete unless options[:quiet]
93
+ end
94
+
95
+ private
96
+
97
+ def rake_seed
98
+ cmd = -> { rake("db:seed #{rake_seed_arguments.join(' ')}") }
99
+
100
+ if options[:admin_email] && options[:admin_password]
101
+ quietly { cmd.call }
102
+ else
103
+ cmd.call
104
+ end
105
+ end
106
+
107
+ def rake_seed_arguments
108
+ arguments = []
109
+ arguments << "ADMIN_EMAIL=#{options[:admin_email]}" if options[:admin_email]
110
+ arguments << "ADMIN_PASSWORD=#{options[:admin_password]}" if options[:admin_password]
111
+ arguments
112
+ end
113
+
114
+ def message_for_insert_routes
115
+ puts '*' * 50
116
+ puts "We added the following line to your application's config/routes.rb file:"
117
+ puts ' '
118
+ puts " mount Comable::Core::Engine, at: '/'"
119
+ end
120
+
121
+ def message_for_complete
122
+ puts '*' * 50
123
+ puts "Comable has been installed successfully. You're all ready to go!"
124
+ puts ' '
125
+ puts 'Enjoy!'
126
+ end
127
+ end
128
+ end
@@ -0,0 +1,16 @@
1
+ # Comable Configurations
2
+ #
3
+ Comable.setup do |config|
4
+ # Example:
5
+ #
6
+ # Uncomment to change devise strategies
7
+ # config.devise_strategies[:customer] = %i(
8
+ # database_authenticatable
9
+ # timeoutable
10
+ # registerable
11
+ # confirmable
12
+ # recoverable
13
+ # rememberable
14
+ # trackable
15
+ # )
16
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comable_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - YOSHIDA Hiroki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-03 00:00:00.000000000 Z
11
+ date: 2015-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -128,6 +128,20 @@ dependencies:
128
128
  - - "~>"
129
129
  - !ruby/object:Gem::Version
130
130
  version: '1.10'
131
+ - !ruby/object:Gem::Dependency
132
+ name: highline
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: 1.6.21
138
+ type: :runtime
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: 1.6.21
131
145
  description: Provide core functions for Comable.
132
146
  email:
133
147
  - hyoshida@appirits.com
@@ -149,6 +163,7 @@ files:
149
163
  - app/models/comable/customer.rb
150
164
  - app/models/comable/image.rb
151
165
  - app/models/comable/order.rb
166
+ - app/models/comable/order/morrisable.rb
152
167
  - app/models/comable/order_detail.rb
153
168
  - app/models/comable/payment_method.rb
154
169
  - app/models/comable/product.rb
@@ -158,11 +173,13 @@ files:
158
173
  - app/models/concerns/comable/cart_owner.rb
159
174
  - app/models/concerns/comable/checkout.rb
160
175
  - app/models/concerns/comable/product/search.rb
176
+ - app/models/concerns/comable/ransackable.rb
161
177
  - app/models/concerns/comable/role_owner.rb
162
178
  - app/models/concerns/comable/sku_choice.rb
163
179
  - app/models/concerns/comable/sku_item.rb
164
180
  - app/uploaders/image_uploader.rb
165
181
  - app/views/comable/order_mailer/complete.text.erb
182
+ - config/locales/en.yml
166
183
  - config/locales/ja.yml
167
184
  - db/migrate/20131214194807_create_comable_products.rb
168
185
  - db/migrate/20140120032559_create_comable_customers.rb
@@ -176,14 +193,19 @@ files:
176
193
  - db/migrate/20150111031228_create_comable_categories.rb
177
194
  - db/migrate/20150111031229_create_comable_products_categories.rb
178
195
  - db/migrate/20150112173706_create_comable_images.rb
196
+ - db/seeds.rb
197
+ - db/seeds/comable/customers.rb
179
198
  - lib/comable/core/configuration.rb
180
199
  - lib/comable/core/engine.rb
200
+ - lib/comable/deprecator.rb
181
201
  - lib/comable/errors.rb
182
202
  - lib/comable/payment_provider.rb
183
203
  - lib/comable/payment_provider/base.rb
184
204
  - lib/comable/payment_provider/general.rb
185
205
  - lib/comable/state_machine_patch.rb
186
206
  - lib/comable_core.rb
207
+ - lib/generators/comable/install/install_generator.rb
208
+ - lib/generators/comable/install/templates/config/initializers/comable.rb
187
209
  - lib/tasks/comable_tasks.rake
188
210
  homepage: https://github.com/hyoshida/comable#comable
189
211
  licenses: