comable_core 0.2.3 → 0.3.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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +16 -4
  4. data/app/controllers/concerns/comable/permitted_attributes.rb +15 -0
  5. data/app/helpers/comable/application_helper.rb +36 -1
  6. data/app/helpers/comable/products_helper.rb +35 -8
  7. data/app/mailers/comable/order_mailer.rb +1 -1
  8. data/app/models/comable/ability.rb +18 -0
  9. data/app/models/comable/address.rb +6 -2
  10. data/app/models/comable/category.rb +72 -0
  11. data/app/models/comable/customer.rb +53 -53
  12. data/app/models/comable/image.rb +11 -0
  13. data/app/models/comable/order.rb +42 -47
  14. data/app/models/comable/order_detail.rb +30 -37
  15. data/app/models/comable/payment_method.rb +26 -0
  16. data/app/models/comable/product.rb +29 -3
  17. data/app/models/comable/shipment_method.rb +4 -0
  18. data/app/models/comable/stock.rb +8 -24
  19. data/app/models/comable/store.rb +7 -2
  20. data/{lib → app/models/concerns}/comable/cart_owner.rb +25 -11
  21. data/app/models/concerns/comable/checkout.rb +90 -0
  22. data/app/models/concerns/comable/product/search.rb +41 -0
  23. data/app/models/concerns/comable/role_owner.rb +15 -0
  24. data/app/uploaders/image_uploader.rb +7 -0
  25. data/app/views/comable/order_mailer/complete.text.erb +7 -9
  26. data/config/locales/ja.yml +237 -8
  27. data/db/migrate/20140120032559_create_comable_customers.rb +1 -4
  28. data/db/migrate/20140502060116_create_comable_stocks.rb +2 -3
  29. data/db/migrate/20140723175431_create_comable_orders.rb +4 -5
  30. data/db/migrate/20140723175810_create_comable_order_details.rb +3 -3
  31. data/db/migrate/20140817194104_create_comable_payment_methods.rb +11 -0
  32. data/db/migrate/20140926063541_create_comable_stores.rb +1 -1
  33. data/db/migrate/20141024025526_create_comable_addresses.rb +2 -2
  34. data/db/migrate/20150111031228_create_comable_categories.rb +9 -0
  35. data/db/migrate/20150111031229_create_comable_products_categories.rb +8 -0
  36. data/db/migrate/20150112173706_create_comable_images.rb +8 -0
  37. data/lib/comable/core/configuration.rb +6 -0
  38. data/lib/comable/core/engine.rb +23 -11
  39. data/lib/comable/errors.rb +0 -3
  40. data/lib/comable/{payment_method → payment_provider}/base.rb +1 -1
  41. data/lib/comable/{payment_method → payment_provider}/general.rb +1 -1
  42. data/lib/comable/{payment_method.rb → payment_provider.rb} +3 -3
  43. data/lib/comable/state_machine_patch.rb +16 -0
  44. data/lib/comable_core.rb +13 -3
  45. metadata +97 -10
  46. data/app/models/comable/order_delivery.rb +0 -21
  47. data/app/models/comable/payment.rb +0 -24
  48. data/db/migrate/20140723175624_create_comable_order_deliveries.rb +0 -9
  49. data/db/migrate/20140817194104_create_comable_payments.rb +0 -11
@@ -1,20 +1,79 @@
1
1
  ja:
2
2
  comable:
3
+ cart: カート
4
+ shopping_cart: ショッピングカート
5
+ checkout: レジに進む
6
+ show_cart: カートを見る
7
+ search: 検索
8
+ category: カテゴリー
9
+ my_account: マイアカウント
10
+ sign_in: ログイン
11
+ sign_out: ログアウト
12
+ guest: ゲスト
13
+ guest_order: ログインせずに進む
14
+ add_to_cart: カートに入れる
15
+ browse_related_products: 関連商品を探す
16
+ reorder: 再度注文
17
+ change_email_or_password: メールアドレス、パスワードを変更する
18
+ edit_your_address_book: アドレス帳を編集する
19
+ address_book: アドレス帳
20
+ order_history: 注文履歴
21
+ next_step: 次へ進む
22
+ use_this_address: この住所を使う
23
+ complete_order: 注文を確定する
24
+ use_as_billing_address: 請求先住所として使用する
25
+ use_as_shipping_address: 配送先住所として使用する
26
+ new_billing_address: 新しい請求先住所
27
+ new_shipping_address: 新しい配送先住所
28
+ edit_billing_address: 請求先住所の編集
29
+ edit_shipping_address: 配送先住所の編集
30
+ other_addresses: その他の住所
31
+ new_address: 新しい住所
32
+ successful: 成功しました
33
+ failure: 失敗しました
34
+
35
+ price: &price
36
+ '価格'
37
+ quantity: &quantity
38
+ '個数'
39
+ item_total_price: &item_total_price
40
+ '合計価格'
41
+ item_total_quantity: &item_total_quantity
42
+ '合計商品数'
43
+ soldout: &soldout
44
+ '品切れ'
3
45
  honorific: &honorific
4
46
  '%{name} 様'
5
47
 
48
+ checkout_flow:
49
+ sign_in: ログイン
50
+ address_and_payment: 配送・会計
51
+ confirm: 確認
52
+ complete: 注文完了
53
+
54
+ actions:
55
+ new: 新規作成
56
+ edit: 編集する
57
+ create: 登録する
58
+ update: 更新する
59
+ destroy: 削除
60
+ cancel: キャンセル
61
+ continue: 続ける
62
+
6
63
  errors:
7
64
  messages:
8
- product_soldout: '%{name}は在庫が不足しています。'
9
- products_soldout: 'ご指定の商品は在庫が不足しています。'
65
+ product_soldout: '(%{name})が在庫を超過しています。'
66
+ products_soldout: '在庫を超過する個数の注文が含まれている可能性があります。'
10
67
  product_not_found: '%{name}は存在しないか削除された可能性があります。'
11
68
  products_not_found: 'ご指定の商品は存在しないか削除された可能性があります。'
12
- order_quantity_invalid: '%{name}の注文数が不正です。'
13
69
 
14
70
  carts:
15
- add_product: '1つの商品がカートに入りました'
71
+ added: '1つの商品がカートに入りました'
16
72
  empty: 'カートに商品が入っていません'
17
- update: 'カートの内容が変更されました'
73
+ updated: 'カートの内容が変更されました'
74
+ invalid: 'カートにいくつかのエラーがあります'
75
+ soldout: *soldout
76
+
18
77
  orders:
19
78
  success: '注文が完了しました'
20
79
  failure: '注文に失敗しました。入力項目を見直してください。'
@@ -29,11 +88,181 @@ ja:
29
88
  outroductions: |-
30
89
  またのご利用をお待ちしております。
31
90
  %{store_name}
32
- order: 'ご注文内容'
33
- order_delivery: 'お届け先'
91
+
92
+ admin:
93
+ not_found: レコードが見つかりませんでした。
94
+ general: 一般
95
+ images: 画像
96
+ main_image: メイン画像
97
+ sub_image: サブ画像
98
+ home: ホーム
99
+ product: 商品
100
+ index: 一覧
101
+ search: 検索
102
+ back_to_store: ストアに戻る
103
+ confirmation_to_remove_product: この操作は元に戻せません。商品を削除してもよろしいですか?
104
+ confirmation_to_remove_stock: この操作は元に戻せません。在庫を削除してもよろしいですか?
105
+ you_can_drag_and_drop: ドラッグ&ドロップの操作でツリーを編集できます。
106
+ you_can_right_click: 右クリックでメニューを表示できます。
107
+ link_to_add_new_node: '次のリンクから新しいカテゴリを追加できます: '
108
+ check_this_product_in_frontend: 'この商品をフロントで確認する'
109
+ note: 'NOTE:'
110
+ results: 件
111
+ times: 回
112
+ more: もっと見る
113
+ access_denied: アクセス権がありません
114
+ order_count: 注文数
115
+ new_orders: 新規受注
116
+ new_users: 新規顧客
117
+ sales: 売上
118
+ better_than_last_week: '先週との比較 (%{percentage}%)'
119
+ edit_profile: プロフィールを編集
120
+ please_fill_when_using_sku: SKUを利用する場合はこの項目を記入してください。
121
+ nav:
122
+ dashboard: ダッシュボード
123
+ order: 注文管理
124
+ product: 商品管理
125
+ category: カテゴリ
126
+ customer: ユーザー
127
+ general_settings: 一般設定
128
+ store: ストア設定
129
+ shipment_method: 配送管理
130
+ payment_method: 決済管理
131
+ products:
132
+ detail: 商品詳細
133
+ stock: 在庫管理
134
+ orders:
135
+ detail: 注文明細
136
+ cart: カート情報
137
+ customer: ユーザー詳細
138
+ shipment: 送料
139
+ payment: 支払手数料
140
+ customers:
141
+ detail: ユーザー詳細
142
+ edit: 編集
143
+ new_orders: '最新の注文 (%{count}件)'
144
+ stores:
145
+ edit: 編集
146
+ shipment_methods:
147
+ edit: 編集
148
+ payment_methods:
149
+ edit: 編集
150
+ actions:
151
+ index: 一覧
152
+ new: 新規作成
153
+ edit: 編集する
154
+ update: 変更する
155
+ destroy: 削除する
156
+ cancel: キャンセル
157
+ categories:
158
+ new_node: 新しいカテゴリ
34
159
 
35
160
  activerecord:
161
+ state_machines:
162
+ comable/order:
163
+ state:
164
+ states:
165
+ cart: カート
166
+ orderer: 請求先住所の選択
167
+ delivery: 配送先住所の選択
168
+ shipment: 配送方法の選択
169
+ payment: 決済方法の選択
170
+ confirm: 注文内容を確認
171
+ complete: 注文完了
172
+
36
173
  models:
37
174
  comable/order: ご注文
38
- comable/order_delivery: お届け先
39
175
  comable/order_details: ご注文明細
176
+
177
+ attributes:
178
+ comable/customer:
179
+ id: ID
180
+ email: メールアドレス
181
+ password: パスワード
182
+ password_confirmation: パスワード(確認)
183
+ current_password: 現在のパスワード
184
+ bill_address: 請求先住所
185
+ ship_address: 配送先住所
186
+ bill_full_name: 配送先氏名
187
+ orders: 注文数
188
+ role: 権限
189
+ comable/order:
190
+ code: 注文番号
191
+ email: メールアドレス
192
+ bill_address: ご請求先
193
+ ship_address: お届け先
194
+ payment_method: お支払い方法
195
+ shipment_method: 発送方法
196
+ shipment_fee: 送料
197
+ item_total_price: 商品合計
198
+ total_price: 合計
199
+ order_details: 商品
200
+ completed_at: 注文日時
201
+ state: ステータス
202
+ bill_address: 請求先住所
203
+ ship_address: 配送先住所
204
+ bill_full_name: 配送先氏名
205
+ order_details: 注文明細
206
+ comable/order_detail: &comable_order_detail
207
+ quantity: *quantity
208
+ price: *price
209
+ product: 商品情報
210
+ subtotal_price: 小計
211
+ comable/address: &comable_address
212
+ full_name: お名前
213
+ family_name: 姓
214
+ first_name: 名
215
+ state_name: 都道府県
216
+ zip_code: 郵便番号
217
+ city: 市町村
218
+ detail: その他
219
+ phone_number: 電話番号
220
+ comable/product:
221
+ code: 商品コード
222
+ name: 商品名
223
+ price: 価格
224
+ caption: キャプション
225
+ categories: カテゴリ
226
+ sku_h_item_name: SKU横軸項目名
227
+ sku_v_item_name: SKU縦軸項目名
228
+ comable/stock:
229
+ code: SKU商品コード
230
+ quantity: 在庫
231
+ sku_h_choice_name: SKU横軸選択肢名
232
+ sku_v_choice_name: SKU縦軸選択肢名
233
+ comable/store:
234
+ name: ストア名
235
+ meta_keywords: メタキーワード
236
+ meta_description: メタディスクリプション
237
+ email_sender: 送信元メールアドレス
238
+ email_activate_flag: メール送信を有効にする
239
+ comable/shipment_method:
240
+ name: 配送方法名
241
+ fee: 手数料
242
+ activate_flag: この配送方法を有効にする
243
+ traking_url: トラッキングURL
244
+ comable/payment_method:
245
+ name: 決済方法名
246
+ payment_provider: 決済プロバイダ
247
+ enable_price: 利用可能な価格範囲
248
+ comable/order/order_details:
249
+ <<: *comable_order_detail
250
+ comable/order/bill_address:
251
+ <<: *comable_address
252
+ comable/order/ship_address:
253
+ <<: *comable_address
254
+
255
+ enumerize:
256
+ comable/customer:
257
+ role:
258
+ customer: 顧客
259
+ reporter: 報告者
260
+ admin: 管理者
261
+
262
+ views:
263
+ pagination:
264
+ first: "&laquo; 最初"
265
+ last: "最後 &raquo;"
266
+ next: "次 &rsaquo;"
267
+ previous: "&lsaquo; 前"
268
+ truncate: "&hellip;"
@@ -3,6 +3,7 @@ class CreateComableCustomers < ActiveRecord::Migration
3
3
  create_table :comable_customers do |t|
4
4
  ## Database authenticatable
5
5
  t.string :email, null: false
6
+ t.string :role, null: false
6
7
  t.string :encrypted_password
7
8
 
8
9
  ## Recoverable
@@ -33,10 +34,6 @@ class CreateComableCustomers < ActiveRecord::Migration
33
34
  ## Others
34
35
  t.references :bill_address
35
36
  t.references :ship_address
36
-
37
- # TODO: Remove
38
- t.string :family_name
39
- t.string :first_name
40
37
  end
41
38
 
42
39
  add_index :comable_customers, :email, unique: true
@@ -1,10 +1,9 @@
1
1
  class CreateComableStocks < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :comable_stocks do |t|
4
- t.integer :comable_product_id
5
- t.integer :product_id_num
4
+ t.references :product, null: false
6
5
  t.string :code, null: false
7
- t.integer :quantity
6
+ t.integer :quantity, null: false, default: 0
8
7
  t.string :sku_h_choice_name
9
8
  t.string :sku_v_choice_name
10
9
  end
@@ -1,19 +1,18 @@
1
1
  class CreateComableOrders < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :comable_orders do |t|
4
- t.integer :comable_customer_id
5
- t.integer :comable_payment_id
4
+ t.references :customer
6
5
  t.string :guest_token
7
6
  t.string :code
8
- t.string :family_name
9
- t.string :first_name
10
7
  t.string :email
11
8
  t.integer :shipment_fee, null: false, default: 0
12
9
  t.string :shipment_tracking_number
13
- t.integer :shipment_method_id
10
+ t.references :shipment_method
11
+ t.references :payment_method
14
12
  t.integer :total_price
15
13
  t.references :bill_address
16
14
  t.references :ship_address
15
+ t.string :state
17
16
  t.datetime :completed_at
18
17
  end
19
18
 
@@ -1,8 +1,8 @@
1
1
  class CreateComableOrderDetails < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :comable_order_details do |t|
4
- t.integer :comable_order_delivery_id, null: false
5
- t.integer :comable_stock_id, null: false
4
+ t.references :order, null: false
5
+ t.references :stock, null: false
6
6
  t.string :name, null: false
7
7
  t.string :code, null: false
8
8
  t.integer :price, null: false
@@ -13,6 +13,6 @@ class CreateComableOrderDetails < ActiveRecord::Migration
13
13
  t.integer :quantity, default: 1, null: false
14
14
  end
15
15
 
16
- add_index :comable_order_details, [:comable_order_delivery_id, :comable_stock_id], unique: true, name: :comable_order_details_idx_01
16
+ add_index :comable_order_details, [:order_id, :stock_id], unique: true, name: :comable_order_details_idx_01
17
17
  end
18
18
  end
@@ -0,0 +1,11 @@
1
+ class CreateComablePaymentMethods < ActiveRecord::Migration
2
+ def change
3
+ create_table :comable_payment_methods do |t|
4
+ t.string :name, null: false
5
+ t.string :payment_provider_type, null: false
6
+ t.integer :payment_provider_kind, null: false
7
+ t.integer :enable_price_from
8
+ t.integer :enable_price_to
9
+ end
10
+ end
11
+ end
@@ -2,7 +2,7 @@ class CreateComableStores < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :comable_stores do |t|
4
4
  t.string :name
5
- t.string :meta_keyword
5
+ t.string :meta_keywords
6
6
  t.string :meta_description
7
7
  t.string :email_sender
8
8
  t.boolean :email_activate_flag, null: false, default: true
@@ -1,11 +1,11 @@
1
1
  class CreateComableAddresses < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :comable_addresses do |t|
4
- t.integer :comable_customer_id
4
+ t.references :customer
5
5
  t.string :family_name, null: false
6
6
  t.string :first_name, null: false
7
7
  t.string :zip_code, null: false, limit: 8
8
- t.integer :comable_state_id
8
+ t.references :state
9
9
  t.string :state_name, null: false
10
10
  t.string :city, null: false
11
11
  t.string :detail
@@ -0,0 +1,9 @@
1
+ class CreateComableCategories < ActiveRecord::Migration
2
+ def change
3
+ create_table :comable_categories do |t|
4
+ t.string :name, null: false
5
+ t.string :ancestry, index: true
6
+ t.integer :position
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ class CreateComableProductsCategories < ActiveRecord::Migration
2
+ def change
3
+ create_table :comable_products_categories do |t|
4
+ t.references :product, null: false, index: true
5
+ t.references :category, null: false, index: true
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ class CreateComableImages < ActiveRecord::Migration
2
+ def change
3
+ create_table :comable_images do |t|
4
+ t.references :product, null: false, index: true
5
+ t.string :file, null: false
6
+ end
7
+ end
8
+ end
@@ -5,6 +5,12 @@ module Comable
5
5
  @@devise_strategies = {
6
6
  customer: [:database_authenticatable, :registerable, :recoverable, :rememberable, :trackable]
7
7
  }
8
+
9
+ mattr_accessor :products_per_page
10
+ @@products_per_page = 15
11
+
12
+ mattr_accessor :orders_per_page
13
+ @@orders_per_page = 5
8
14
  end
9
15
  end
10
16
  end
@@ -41,23 +41,35 @@ module Comable
41
41
  module DeviseHelperPrepender
42
42
  def define_helpers(mapping)
43
43
  super.tap do
44
- mapping = mapping.name
45
- return if mapping.to_sym != :customer
46
-
47
- class_eval <<-METHODS, __FILE__, __LINE__ + 1
48
- alias_method :devise_current_#{mapping}, :current_#{mapping}
49
- def current_#{mapping}
50
- @current_#{mapping}_guest ||= Comable::Customer.new
51
- #{mapping} = devise_current_#{mapping} || @current_#{mapping}_guest
52
- #{mapping}.with_cookies(cookies)
53
- end
54
- METHODS
44
+ return if mapping.name.to_sym != :customer
45
+ define_comable_helper
55
46
  end
56
47
  end
48
+
49
+ private
50
+
51
+ def define_comable_helper
52
+ class_eval <<-METHODS, __FILE__, __LINE__ + 1
53
+ alias_method :devise_current_customer, :current_customer
54
+ def current_customer
55
+ resource = current_admin_customer || devise_current_customer || Comable::Customer.new
56
+ resource.with_cookies(cookies)
57
+ end
58
+ METHODS
59
+ end
57
60
  end
58
61
 
59
62
  Devise::Controllers::Helpers.singleton_class.send(:prepend, DeviseHelperPrepender)
60
63
  end
64
+
65
+ initializer 'comable.devise.warden.manager' do
66
+ Warden::Manager.after_set_user except: :fetch do |record, warden, options|
67
+ if record.respond_to?(:after_set_user) && warden.authenticated?(options[:scope])
68
+ record.with_cookies(warden.cookies)
69
+ record.after_set_user
70
+ end
71
+ end
72
+ end
61
73
  end
62
74
  end
63
75
  end
@@ -1,7 +1,4 @@
1
1
  module Comable
2
2
  class InvalidOrder < StandardError
3
3
  end
4
-
5
- class NoStock < StandardError
6
- end
7
4
  end
@@ -1,5 +1,5 @@
1
1
  module Comable
2
- module PaymentMethod
2
+ module PaymentProvider
3
3
  class Base
4
4
  class << self
5
5
  def name_symbol
@@ -1,5 +1,5 @@
1
1
  module Comable
2
- module PaymentMethod
2
+ module PaymentProvider
3
3
  class General < Base
4
4
  class << self
5
5
  def display_name
@@ -1,8 +1,8 @@
1
- require 'comable/payment_method/base'
2
- require 'comable/payment_method/general'
1
+ require 'comable/payment_provider/base'
2
+ require 'comable/payment_provider/general'
3
3
 
4
4
  module Comable
5
- module PaymentMethod
5
+ module PaymentProvider
6
6
  class << self
7
7
  def all
8
8
  (constants - [:Base]).map do |constant_name|
@@ -0,0 +1,16 @@
1
+ # Rails 4.1.0.rc1 and StateMachine don't play nice
2
+ # https://github.com/pluginaweek/state_machine/issues/295
3
+
4
+ require 'state_machine/version'
5
+
6
+ if StateMachine::VERSION != '1.2.0'
7
+ # If you see this message, please test removing this file
8
+ # If it's still required, please bump up the version above
9
+ Rails.logger.warn 'Please remove me, StateMachine version has changed'
10
+ end
11
+
12
+ if Rails.version =~ /^4.1./
13
+ module StateMachine::Integrations::ActiveModel
14
+ public :around_validation
15
+ end
16
+ end
data/lib/comable_core.rb CHANGED
@@ -1,18 +1,28 @@
1
1
  require 'devise'
2
- require 'jquery-rails'
3
2
  require 'enumerize'
3
+ require 'state_machine'
4
+ require 'ancestry'
5
+ require 'acts_as_list'
6
+ require 'carrierwave'
7
+ require 'cancancan'
4
8
 
5
9
  require 'comable/core/configuration'
6
10
  require 'comable/core/engine'
7
11
 
8
12
  require 'comable/errors'
9
- require 'comable/cart_owner'
10
- require 'comable/payment_method'
13
+ require 'comable/payment_provider'
14
+ require 'comable/state_machine_patch'
11
15
 
12
16
  module Comable
13
17
  class << self
14
18
  def setup(&_)
15
19
  yield Comable::Config
16
20
  end
21
+
22
+ def translate(key, options = {})
23
+ I18n.translate("comable.#{key}", options)
24
+ end
25
+
26
+ alias_method :t, :translate
17
27
  end
18
28
  end