comable-core 0.6.0 → 0.7.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/comable/application_controller.rb +4 -0
- data/app/helpers/comable/application_helper.rb +23 -8
- data/app/helpers/comable/products_helper.rb +0 -63
- data/app/models/comable/image.rb +1 -1
- data/app/models/comable/navigation.rb +12 -0
- data/app/models/comable/navigation_item.rb +52 -0
- data/app/models/comable/option_type.rb +19 -0
- data/app/models/comable/option_value.rb +14 -0
- data/app/models/comable/order.rb +1 -0
- data/app/models/comable/order_item/csvable.rb +1 -1
- data/app/models/comable/order_item.rb +38 -7
- data/app/models/comable/page.rb +3 -1
- data/app/models/comable/payment.rb +1 -1
- data/app/models/comable/product/csvable.rb +1 -0
- data/app/models/comable/product.rb +68 -9
- data/app/models/comable/stock/csvable.rb +5 -6
- data/app/models/comable/stock.rb +45 -8
- data/app/models/comable/store.rb +0 -2
- data/app/models/comable/theme.rb +10 -0
- data/app/models/comable/variant.rb +46 -0
- data/app/models/concerns/comable/cart_owner.rb +6 -2
- data/app/models/concerns/comable/checkout.rb +2 -2
- data/app/models/concerns/comable/linkable.rb +46 -0
- data/app/models/concerns/comable/sku_choice.rb +1 -9
- data/app/uploaders/comable/image_uploader.rb +9 -0
- data/config/locales/en.yml +67 -2
- data/config/locales/ja.yml +66 -2
- data/db/migrate/20150701094210_create_comable_navigation.rb +8 -0
- data/db/migrate/20150706085056_create_comable_navigation_item.rb +15 -0
- data/db/migrate/20150805074914_add_published_at_to_comable_products.rb +9 -0
- data/db/migrate/20150823071425_create_comable_variants.rb +10 -0
- data/db/migrate/20150823072622_create_comable_option_types.rb +10 -0
- data/db/migrate/20150823072955_create_comable_option_values.rb +11 -0
- data/db/migrate/20150823073250_create_comable_variants_option_values.rb +8 -0
- data/db/migrate/20150823073809_change_comable_products_and_comable_stocks.rb +82 -0
- data/db/migrate/20150823102819_change_comable_order_items.rb +50 -0
- data/lib/comable/core.rb +1 -0
- data/lib/comable/deprecator.rb +1 -1
- data/lib/comable/errors.rb +7 -0
- metadata +74 -21
- data/app/uploaders/image_uploader.rb +0 -7
@@ -51,18 +51,22 @@ module Comable
|
|
51
51
|
|
52
52
|
private
|
53
53
|
|
54
|
+
# rubocop:disable Metrics/MethodLength
|
54
55
|
def process_cart_item(obj)
|
55
56
|
case obj
|
56
57
|
when Comable::Product
|
57
58
|
yield obj.stocks.first
|
58
59
|
when Comable::Stock
|
59
60
|
yield obj
|
61
|
+
when Comable::Variant
|
62
|
+
yield obj.stock
|
60
63
|
when Array
|
61
64
|
obj.map { |item| yield item }
|
62
65
|
else
|
63
66
|
fail
|
64
67
|
end
|
65
68
|
end
|
69
|
+
# rubocop:enable Metrics/MethodLength
|
66
70
|
|
67
71
|
def add_stock_to_cart(stock, quantity)
|
68
72
|
cart_item = find_cart_item_by(stock)
|
@@ -70,7 +74,7 @@ module Comable
|
|
70
74
|
cart_item.quantity += quantity
|
71
75
|
(cart_item.quantity > 0) ? cart_item.save : cart_item.destroy
|
72
76
|
else
|
73
|
-
cart_items.build(
|
77
|
+
cart_items.build(variant: stock.variant, quantity: quantity).save
|
74
78
|
end
|
75
79
|
end
|
76
80
|
|
@@ -88,7 +92,7 @@ module Comable
|
|
88
92
|
def find_cart_item_by(stock)
|
89
93
|
# TODO: Refactoring
|
90
94
|
fail unless stock.is_a?(Comable::Stock)
|
91
|
-
cart_items.find { |cart_item| cart_item.stock
|
95
|
+
cart_items.find { |cart_item| cart_item.stock == stock }
|
92
96
|
end
|
93
97
|
end
|
94
98
|
end
|
@@ -37,8 +37,8 @@ module Comable
|
|
37
37
|
end
|
38
38
|
|
39
39
|
before_transition to: :completed, do: :complete!
|
40
|
-
|
41
|
-
|
40
|
+
before_transition to: :canceled, do: [:payment_cancel!, :restock!]
|
41
|
+
before_transition to: :resumed, do: [:payment_resume!, :unstock!]
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Comable
|
2
|
+
module Linkable
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
module ClassMethods
|
6
|
+
def linkable_columns_keys(options = {})
|
7
|
+
if options.present?
|
8
|
+
@_linkable_columns = default_columns_key.merge(options.slice(:name, :id))
|
9
|
+
@use_index = options[:use_index]
|
10
|
+
else
|
11
|
+
@_linkable_columns
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def linkable_columns(*key)
|
16
|
+
(@_linkable_columns || default_columns_key).slice(*key).values
|
17
|
+
end
|
18
|
+
|
19
|
+
def linkable_id_options
|
20
|
+
# HACK: Rails3系のpluckでは複数フィールドを指定できないためselectとmapでカラムを取得する
|
21
|
+
# options = pluck(*linkable_columns(:name, :id))
|
22
|
+
columns = linkable_columns(:name, :id)
|
23
|
+
records = select(columns)
|
24
|
+
options = records.map(&columns.first).zip(records.map(&columns.last))
|
25
|
+
@use_index ? options.unshift(index_option) : options
|
26
|
+
end
|
27
|
+
|
28
|
+
def linkable_exists?
|
29
|
+
@use_index || exists?
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def default_columns_key
|
35
|
+
{
|
36
|
+
id: :id,
|
37
|
+
name: :name
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
def index_option
|
42
|
+
[Comable.t('admin.actions.index'), nil]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -5,15 +5,7 @@ module Comable
|
|
5
5
|
#
|
6
6
|
module SkuChoice
|
7
7
|
def name_with_sku
|
8
|
-
|
9
|
-
name + "(#{sku_name})"
|
10
|
-
end
|
11
|
-
|
12
|
-
def sku_name
|
13
|
-
return unless sku?
|
14
|
-
sku_name = sku_h_choice_name
|
15
|
-
sku_name += '/' + sku_v_choice_name if sku_v_choice_name.present?
|
16
|
-
sku_name
|
8
|
+
name
|
17
9
|
end
|
18
10
|
end
|
19
11
|
end
|
data/config/locales/en.yml
CHANGED
@@ -33,6 +33,7 @@ en:
|
|
33
33
|
failure: 'Failure'
|
34
34
|
products: 'Products'
|
35
35
|
pages: 'Pages'
|
36
|
+
navigations: 'Navigations'
|
36
37
|
home: 'Home'
|
37
38
|
support: 'Support'
|
38
39
|
sample_header: 'Sample text'
|
@@ -110,6 +111,7 @@ en:
|
|
110
111
|
confirmation_to_remove_product: 'This operation cannot be undone. Would you like to proceed?'
|
111
112
|
confirmation_to_remove_stock: 'This operation cannot be undone. Would you like to proceed?'
|
112
113
|
confirmation_to_remove_page: 'This operation cannot be undone. Would you like to proceed?'
|
114
|
+
confirmation_to_remove_navigation: 'This operation cannot be undone. Would you like to proceed?'
|
113
115
|
you_can_drag_and_drop: 'Edit the category tree by drag-and-drop.'
|
114
116
|
you_can_right_click: 'Open the context menu by right click.'
|
115
117
|
link_to_add_new_node: 'Add a new category from the following link: '
|
@@ -163,6 +165,11 @@ en:
|
|
163
165
|
please_see_following_page_for_syntax: 'Please see the following page for the syntax:'
|
164
166
|
please_select_file_form_directory_tree_to_edit: 'Please select a file form the directory tree to edit.'
|
165
167
|
here_editor_will_be_displayed_and_you_can_edit_file: 'Here the editor will be displayed, you can edit file.'
|
168
|
+
variants: 'Variants'
|
169
|
+
pricing: 'Pricing'
|
170
|
+
view: 'View'
|
171
|
+
add_variants: 'Add variants'
|
172
|
+
size: 'Size'
|
166
173
|
nav:
|
167
174
|
dashboard: 'Dashboard'
|
168
175
|
order: 'Orders'
|
@@ -170,6 +177,7 @@ en:
|
|
170
177
|
stock: 'Stocks'
|
171
178
|
category: 'Categories'
|
172
179
|
page: 'Pages'
|
180
|
+
navigation: 'Navigations'
|
173
181
|
user: 'Users'
|
174
182
|
general_settings: 'General settings'
|
175
183
|
store: 'Store'
|
@@ -180,6 +188,9 @@ en:
|
|
180
188
|
products:
|
181
189
|
detail: 'Product details'
|
182
190
|
list: 'Product list'
|
191
|
+
visibility: 'publishing/closed'
|
192
|
+
published: 'Published'
|
193
|
+
unpublished: 'Unpublished'
|
183
194
|
orders:
|
184
195
|
detail: 'Order details'
|
185
196
|
cart: 'Cart infomation'
|
@@ -196,6 +207,12 @@ en:
|
|
196
207
|
visibility: 'publishing/closed'
|
197
208
|
published: 'Published'
|
198
209
|
unpublished: 'Unpublished'
|
210
|
+
navigations:
|
211
|
+
general: 'General'
|
212
|
+
navigation_items: 'Navigation items'
|
213
|
+
navigation_items:
|
214
|
+
web_address: 'Web Address'
|
215
|
+
add_link: 'Add Link'
|
199
216
|
stores:
|
200
217
|
edit: 'Editing store'
|
201
218
|
shipment_methods:
|
@@ -264,8 +281,13 @@ en:
|
|
264
281
|
models:
|
265
282
|
comable/order: 'Orders'
|
266
283
|
comable/order_items: 'Order items'
|
284
|
+
comable/navigation: 'Navigation'
|
285
|
+
comable/navigation_item: 'Navigation item'
|
267
286
|
|
268
287
|
attributes:
|
288
|
+
timestamps: ×tamps
|
289
|
+
created_at: 'Created at'
|
290
|
+
updated_at: 'Updated at'
|
269
291
|
comable/user:
|
270
292
|
id: 'ID'
|
271
293
|
email: 'Email address'
|
@@ -282,6 +304,7 @@ en:
|
|
282
304
|
last_sign_in_at: 'Last sign in at'
|
283
305
|
current_sign_in_ip: 'Current sign in ip'
|
284
306
|
last_sign_in_ip: 'Last sign in ip'
|
307
|
+
<<: *timestamps
|
285
308
|
comable/order:
|
286
309
|
id: 'ID'
|
287
310
|
code: 'Order number'
|
@@ -305,6 +328,7 @@ en:
|
|
305
328
|
guest_token: 'Guest token'
|
306
329
|
payment_state: 'Payment state'
|
307
330
|
shipment_state: 'Shipment state'
|
331
|
+
<<: *timestamps
|
308
332
|
comable/order_item: &comable_order_item
|
309
333
|
quantity: *quantity
|
310
334
|
price: *price
|
@@ -317,6 +341,7 @@ en:
|
|
317
341
|
sku_h_choice_name: 'SKU Horizontal choice name'
|
318
342
|
sku_v_choice_name: 'SKU Vertical choice name'
|
319
343
|
order: 'Order'
|
344
|
+
<<: *timestamps
|
320
345
|
comable/address: &comable_address
|
321
346
|
full_name: 'Full name'
|
322
347
|
family_name: 'Last name'
|
@@ -326,6 +351,7 @@ en:
|
|
326
351
|
city: 'City'
|
327
352
|
detail: 'Detail'
|
328
353
|
phone_number: 'Phone number'
|
354
|
+
<<: *timestamps
|
329
355
|
comable/product:
|
330
356
|
id: 'ID'
|
331
357
|
code: 'Code'
|
@@ -335,6 +361,8 @@ en:
|
|
335
361
|
categories: 'Categories'
|
336
362
|
sku_h_item_name: 'SKU Horizontal item name'
|
337
363
|
sku_v_item_name: 'SKU Vertical item name'
|
364
|
+
published_at: 'Published at'
|
365
|
+
<<: *timestamps
|
338
366
|
comable/stock:
|
339
367
|
id: 'ID'
|
340
368
|
code: 'SKU Code'
|
@@ -343,27 +371,34 @@ en:
|
|
343
371
|
sku_v_choice_name: 'SKU Vertical choice name'
|
344
372
|
product: 'Product'
|
345
373
|
product_code: 'Product code'
|
374
|
+
name: 'Product name'
|
375
|
+
sku: 'SKU'
|
376
|
+
<<: *timestamps
|
346
377
|
comable/store:
|
347
378
|
name: 'Name'
|
348
379
|
meta_keywords: 'Meta keywords'
|
349
380
|
meta_description: 'Meta description'
|
350
381
|
email: 'Email'
|
382
|
+
<<: *timestamps
|
351
383
|
comable/shipment_method:
|
352
384
|
name: 'Name'
|
353
385
|
fee: 'Fee'
|
354
386
|
activated_flag: 'Activated'
|
355
387
|
traking_url: 'Tracking URL'
|
388
|
+
<<: *timestamps
|
356
389
|
comable/payment_method:
|
357
390
|
name: 'Name'
|
358
391
|
payment_provider: 'Oayment provider'
|
359
392
|
fee: 'Fee'
|
360
393
|
enable_price: 'Enable price range'
|
394
|
+
<<: *timestamps
|
361
395
|
comable/tracker:
|
362
396
|
activated_flag: 'Activated'
|
363
397
|
name: 'Name'
|
364
398
|
tracker_id: 'Tracker ID'
|
365
399
|
code: 'Code'
|
366
400
|
place: 'Place'
|
401
|
+
<<: *timestamps
|
367
402
|
comable/order/order_items:
|
368
403
|
<<: *comable_order_item
|
369
404
|
comable/order/bill_address:
|
@@ -377,6 +412,7 @@ en:
|
|
377
412
|
fee: 'Fee'
|
378
413
|
state: 'Status'
|
379
414
|
completed_at: 'Completed at'
|
415
|
+
<<: *timestamps
|
380
416
|
comable/shipment:
|
381
417
|
id: 'ID'
|
382
418
|
order_id: 'Order ID'
|
@@ -385,6 +421,7 @@ en:
|
|
385
421
|
state: 'Status'
|
386
422
|
tracking_number: 'Tracking number'
|
387
423
|
completed_at: 'Completed at'
|
424
|
+
<<: *timestamps
|
388
425
|
comable/page:
|
389
426
|
id: 'ID'
|
390
427
|
title: 'Title'
|
@@ -395,8 +432,36 @@ en:
|
|
395
432
|
meta_keywords: 'Meta Keywords'
|
396
433
|
slug: 'Slug'
|
397
434
|
published_at: 'Published at'
|
398
|
-
|
399
|
-
|
435
|
+
<<: *timestamps
|
436
|
+
comable/navigation: &comable_navigation_item
|
437
|
+
id: 'ID'
|
438
|
+
name: 'Name'
|
439
|
+
<<: *timestamps
|
440
|
+
comable/navigation_item:
|
441
|
+
id: 'ID'
|
442
|
+
name: 'Name'
|
443
|
+
linkable_type: 'Link to'
|
444
|
+
linkable_id: ''
|
445
|
+
url: 'Name'
|
446
|
+
<<: *timestamps
|
447
|
+
comable/navigation/navigation_items:
|
448
|
+
<<: *comable_navigation_item
|
449
|
+
comable/variant:
|
450
|
+
id: 'ID'
|
451
|
+
sku: 'SKU'
|
452
|
+
price: 'Price'
|
453
|
+
product: 'Product'
|
454
|
+
quantity: 'Quantity'
|
455
|
+
<<: *timestamps
|
456
|
+
comable/option_type:
|
457
|
+
id: 'ID'
|
458
|
+
name: 'Name'
|
459
|
+
<<: *timestamps
|
460
|
+
comable/option_value:
|
461
|
+
id: 'ID'
|
462
|
+
name: 'Name'
|
463
|
+
<<: *timestamps
|
464
|
+
|
400
465
|
enumerize:
|
401
466
|
comable/user:
|
402
467
|
role:
|
data/config/locales/ja.yml
CHANGED
@@ -33,6 +33,7 @@ ja:
|
|
33
33
|
failure: 失敗しました
|
34
34
|
products: '商品'
|
35
35
|
pages: 'ページ'
|
36
|
+
navigations: 'ナビゲーション'
|
36
37
|
home: 'ホーム'
|
37
38
|
support: 'サポート'
|
38
39
|
sample_header: 'サンプルテキスト'
|
@@ -110,6 +111,7 @@ ja:
|
|
110
111
|
confirmation_to_remove_product: この操作は元に戻せません。商品を削除してもよろしいですか?
|
111
112
|
confirmation_to_remove_stock: この操作は元に戻せません。在庫を削除してもよろしいですか?
|
112
113
|
confirmation_to_remove_page: この操作は元に戻せません。ページを削除してもよろしいですか?
|
114
|
+
confirmation_to_remove_navigation: この操作は元に戻せません。ナビゲーションを削除してもよろしいですか?
|
113
115
|
you_can_drag_and_drop: ドラッグ&ドロップの操作でツリーを編集できます。
|
114
116
|
you_can_right_click: 右クリックでメニューを表示できます。
|
115
117
|
link_to_add_new_node: '次のリンクから新しいカテゴリを追加できます: '
|
@@ -163,6 +165,11 @@ ja:
|
|
163
165
|
please_see_following_page_for_syntax: '構文については次のページを参照してください:'
|
164
166
|
please_select_file_form_directory_tree_to_edit: 'ディレクトリーツリーから編集したいファイルを選択してください。'
|
165
167
|
here_editor_will_be_displayed_and_you_can_edit_file: 'ここにエディタが表示されてファイルの内容を編集できます。'
|
168
|
+
variants: 'バリエーション'
|
169
|
+
pricing: '価格'
|
170
|
+
view: '確認する'
|
171
|
+
add_variants: 'バリエーションを追加する'
|
172
|
+
size: 'サイズ'
|
166
173
|
nav:
|
167
174
|
dashboard: ダッシュボード
|
168
175
|
order: 注文管理
|
@@ -170,6 +177,7 @@ ja:
|
|
170
177
|
stock: 在庫管理
|
171
178
|
category: カテゴリ
|
172
179
|
page: ページ
|
180
|
+
navigation: ナビゲーション
|
173
181
|
user: ユーザー
|
174
182
|
general_settings: 一般設定
|
175
183
|
store: ストア設定
|
@@ -180,6 +188,9 @@ ja:
|
|
180
188
|
products:
|
181
189
|
detail: 商品詳細
|
182
190
|
list: '商品一覧'
|
191
|
+
visibility: 公開/非公開
|
192
|
+
published: 公開
|
193
|
+
unpublished: 非公開
|
183
194
|
orders:
|
184
195
|
detail: 注文明細
|
185
196
|
cart: カート情報
|
@@ -196,6 +207,12 @@ ja:
|
|
196
207
|
visibility: 公開/非公開
|
197
208
|
published: 公開
|
198
209
|
unpublished: 非公開
|
210
|
+
navigations:
|
211
|
+
general: 一般
|
212
|
+
navigation_items: ナビゲーション項目
|
213
|
+
navigation_items:
|
214
|
+
web_address: アドレス入力
|
215
|
+
add_link: リンク追加
|
199
216
|
stores:
|
200
217
|
edit: 編集
|
201
218
|
shipment_methods:
|
@@ -264,8 +281,13 @@ ja:
|
|
264
281
|
models:
|
265
282
|
comable/order: ご注文
|
266
283
|
comable/order_items: ご注文明細
|
284
|
+
comable/navigation: 'ナビゲーション'
|
285
|
+
comable/navigation_item: 'ナビゲーション項目'
|
267
286
|
|
268
287
|
attributes:
|
288
|
+
timestamps: ×tamps
|
289
|
+
created_at: '作成日'
|
290
|
+
updated_at: '更新日'
|
269
291
|
comable/user:
|
270
292
|
id: ID
|
271
293
|
email: メールアドレス
|
@@ -282,6 +304,7 @@ ja:
|
|
282
304
|
last_sign_in_at: 最終ログイン日時
|
283
305
|
current_sign_in_ip: ログインIP
|
284
306
|
last_sign_in_ip: 最終ログインIP
|
307
|
+
<<: *timestamps
|
285
308
|
comable/order:
|
286
309
|
id: ID
|
287
310
|
code: 注文番号
|
@@ -305,6 +328,7 @@ ja:
|
|
305
328
|
guest_token: ゲストトークン
|
306
329
|
payment_state: '決済ステータス'
|
307
330
|
shipment_state: '配送ステータス'
|
331
|
+
<<: *timestamps
|
308
332
|
comable/order_item: &comable_order_item
|
309
333
|
quantity: *quantity
|
310
334
|
price: *price
|
@@ -317,6 +341,7 @@ ja:
|
|
317
341
|
sku_h_choice_name: SKU横軸選択肢名
|
318
342
|
sku_v_choice_name: SKU縦軸選択肢名
|
319
343
|
order: 注文
|
344
|
+
<<: *timestamps
|
320
345
|
comable/address: &comable_address
|
321
346
|
full_name: お名前
|
322
347
|
family_name: 姓
|
@@ -326,6 +351,7 @@ ja:
|
|
326
351
|
city: 市町村
|
327
352
|
detail: その他
|
328
353
|
phone_number: 電話番号
|
354
|
+
<<: *timestamps
|
329
355
|
comable/product:
|
330
356
|
id: ID
|
331
357
|
code: 商品コード
|
@@ -335,6 +361,8 @@ ja:
|
|
335
361
|
categories: カテゴリ
|
336
362
|
sku_h_item_name: SKU横軸項目名
|
337
363
|
sku_v_item_name: SKU縦軸項目名
|
364
|
+
published_at: '公開日'
|
365
|
+
<<: *timestamps
|
338
366
|
comable/stock:
|
339
367
|
id: ID
|
340
368
|
code: SKU商品コード
|
@@ -343,27 +371,34 @@ ja:
|
|
343
371
|
sku_v_choice_name: SKU縦軸選択肢名
|
344
372
|
product: 商品
|
345
373
|
product_code: 商品コード
|
374
|
+
name: '商品名'
|
375
|
+
sku: 'SKUコード'
|
376
|
+
<<: *timestamps
|
346
377
|
comable/store:
|
347
378
|
name: ストア名
|
348
379
|
meta_keywords: メタキーワード
|
349
380
|
meta_description: メタディスクリプション
|
350
381
|
email: メールアドレス
|
382
|
+
<<: *timestamps
|
351
383
|
comable/shipment_method:
|
352
384
|
name: 発送方法名
|
353
385
|
fee: 手数料
|
354
386
|
activated_flag: この発送方法を有効にする
|
355
387
|
traking_url: トラッキングURL
|
388
|
+
<<: *timestamps
|
356
389
|
comable/payment_method:
|
357
390
|
name: 決済方法名
|
358
391
|
payment_provider: 決済プロバイダ
|
359
392
|
fee: '手数料'
|
360
393
|
enable_price: 利用可能な価格範囲
|
394
|
+
<<: *timestamps
|
361
395
|
comable/tracker:
|
362
396
|
activated_flag: 'このトラッキング情報を有効にする'
|
363
397
|
name: 'トラッキング名'
|
364
398
|
tracker_id: 'トラッキングID'
|
365
399
|
code: 'トラッキングコード'
|
366
400
|
place: '設置場所'
|
401
|
+
<<: *timestamps
|
367
402
|
comable/order/order_items:
|
368
403
|
<<: *comable_order_item
|
369
404
|
comable/order/bill_address:
|
@@ -377,6 +412,7 @@ ja:
|
|
377
412
|
fee: '手数料'
|
378
413
|
state: 'ステータス'
|
379
414
|
completed_at: '決済日時'
|
415
|
+
<<: *timestamps
|
380
416
|
comable/shipment:
|
381
417
|
id: 'ID'
|
382
418
|
order_id: '注文ID'
|
@@ -385,6 +421,7 @@ ja:
|
|
385
421
|
state: 'ステータス'
|
386
422
|
tracking_number: 'トラッキング番号'
|
387
423
|
completed_at: '発送日時'
|
424
|
+
<<: *timestamps
|
388
425
|
comable/page:
|
389
426
|
id: ID
|
390
427
|
title: タイトル
|
@@ -395,8 +432,35 @@ ja:
|
|
395
432
|
meta_keywords: メタキーワード
|
396
433
|
slug: スラッグ
|
397
434
|
published_at: 公開日
|
398
|
-
|
399
|
-
|
435
|
+
<<: *timestamps
|
436
|
+
comable/navigation:
|
437
|
+
id: ID
|
438
|
+
name: 名前
|
439
|
+
<<: *timestamps
|
440
|
+
comable/navigation_item: &comable_navigation_item
|
441
|
+
id: ID
|
442
|
+
name: 名前
|
443
|
+
linkable_type: リンク先
|
444
|
+
linkable_id: ''
|
445
|
+
url: URL
|
446
|
+
<<: *timestamps
|
447
|
+
comable/navigation/navigation_items:
|
448
|
+
<<: *comable_navigation_item
|
449
|
+
comable/variant:
|
450
|
+
id: 'ID'
|
451
|
+
sku: 'SKUコード'
|
452
|
+
price: '価格'
|
453
|
+
product: '商品'
|
454
|
+
quantity: '個数'
|
455
|
+
<<: *timestamps
|
456
|
+
comable/option_type:
|
457
|
+
id: 'ID'
|
458
|
+
name: '名称'
|
459
|
+
<<: *timestamps
|
460
|
+
comable/option_value:
|
461
|
+
id: 'ID'
|
462
|
+
name: '名称'
|
463
|
+
<<: *timestamps
|
400
464
|
|
401
465
|
enumerize:
|
402
466
|
comable/user:
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateComableNavigationItem < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :comable_navigation_items do |t|
|
4
|
+
t.references :navigation, null: false
|
5
|
+
t.integer :linkable_id
|
6
|
+
t.string :linkable_type
|
7
|
+
t.integer :position, null: false
|
8
|
+
t.string :name, null: false
|
9
|
+
t.string :url
|
10
|
+
t.timestamps null: false
|
11
|
+
end
|
12
|
+
|
13
|
+
add_index :comable_navigation_items, [:position, :navigation_id]
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class AddPublishedAtToComableProducts < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
change_table :comable_products do |t|
|
4
|
+
t.datetime :published_at
|
5
|
+
end
|
6
|
+
|
7
|
+
Comable::Product.update_all(published_at: (Rails::VERSION::MAJOR == 3) ? Date.today.to_time_in_current_zone : Date.today.in_time_zone) unless reverting?
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class CreateComableOptionValues < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :comable_option_values do |t|
|
4
|
+
t.references :option_type, null: false
|
5
|
+
t.string :name, null: false
|
6
|
+
t.timestamps null: false
|
7
|
+
end
|
8
|
+
|
9
|
+
add_index :comable_option_values, [:option_type_id, :name], unique: true
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
class ChangeComableProductsAndComableStocks < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
reversible do |dir|
|
4
|
+
change_table :comable_stocks do |t|
|
5
|
+
dir.up { t.references :variant }
|
6
|
+
dir.down { t.remove :variant_id }
|
7
|
+
end
|
8
|
+
|
9
|
+
dir.up { up_records }
|
10
|
+
dir.down { down_records }
|
11
|
+
|
12
|
+
dir.up { remove_index :comable_products, :code }
|
13
|
+
dir.down { add_index :comable_products, :code, unique: true }
|
14
|
+
|
15
|
+
change_table :comable_products do |t|
|
16
|
+
dir.up { t.remove :code }
|
17
|
+
dir.down { t.string :code, null: false }
|
18
|
+
|
19
|
+
dir.up { t.remove :price }
|
20
|
+
dir.down { t.string :price, null: false }
|
21
|
+
|
22
|
+
dir.up { t.remove :sku_h_item_name }
|
23
|
+
dir.down { t.string :sku_h_item_name }
|
24
|
+
|
25
|
+
dir.up { t.remove :sku_v_item_name }
|
26
|
+
dir.down { t.string :sku_v_item_name }
|
27
|
+
end
|
28
|
+
|
29
|
+
dir.up { remove_index :comable_stocks, :code }
|
30
|
+
dir.down { add_index :comable_stocks, :code, unique: true }
|
31
|
+
|
32
|
+
change_table :comable_stocks do |t|
|
33
|
+
dir.up { t.remove :product_id }
|
34
|
+
dir.down { t.references :product, null: false }
|
35
|
+
|
36
|
+
dir.up { t.remove :code }
|
37
|
+
dir.down { t.string :code, null: false }
|
38
|
+
|
39
|
+
dir.up { t.remove :sku_h_choice_name }
|
40
|
+
dir.down { t.string :sku_h_choice_name }
|
41
|
+
|
42
|
+
dir.up { t.remove :sku_v_choice_name }
|
43
|
+
dir.down { t.string :sku_v_choice_name }
|
44
|
+
|
45
|
+
dir.up { t.change :quantity, :integer, default: 0 }
|
46
|
+
dir.down { t.change :quantity, :integer, default: nil }
|
47
|
+
|
48
|
+
dir.up { t.change :variant_id, :integer, null: false }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def up_records
|
56
|
+
Comable::Product.all.each do |product|
|
57
|
+
if product[:sku_h_item_name].present? || product[:sku_v_item_name].present?
|
58
|
+
create_variants_for(product)
|
59
|
+
else
|
60
|
+
create_variant_for(product)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def down_records
|
66
|
+
# TODO: Implement
|
67
|
+
end
|
68
|
+
|
69
|
+
def create_variant_for(product)
|
70
|
+
stock = Comable::Stock.find_by(product_id: product.id)
|
71
|
+
product.variants.create!(stock: stock, price: product[:price], sku: product[:code])
|
72
|
+
end
|
73
|
+
|
74
|
+
def create_variants_for(product)
|
75
|
+
Comable::Stock.where(product_id: product.id).each do |stock|
|
76
|
+
options = []
|
77
|
+
options << { name: product[:sku_h_item_name], value: stock[:sku_h_choice_name] } if product[:sku_h_item_name].present?
|
78
|
+
options << { name: product[:sku_v_item_name], value: stock[:sku_v_choice_name] } if product[:sku_v_item_name].present?
|
79
|
+
product.variants.create!(stock: stock, price: product[:price], sku: stock[:code], options: options)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|