kms_catalog 0.4.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 (128) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +37 -0
  4. data/app/assets/javascripts/kms_catalog/application/controllers/categories_controller.coffee +63 -0
  5. data/app/assets/javascripts/kms_catalog/application/controllers/option_types_controller.coffee +68 -0
  6. data/app/assets/javascripts/kms_catalog/application/controllers/option_values_controller.coffee +71 -0
  7. data/app/assets/javascripts/kms_catalog/application/controllers/products_controller.coffee +77 -0
  8. data/app/assets/javascripts/kms_catalog/application/controllers/properties_controller.coffee +38 -0
  9. data/app/assets/javascripts/kms_catalog/application/controllers/variants_controller.coffee +45 -0
  10. data/app/assets/javascripts/kms_catalog/application/routes.coffee.erb +97 -0
  11. data/app/assets/javascripts/kms_catalog/application.js +3 -0
  12. data/app/assets/javascripts/templates/categories/edit.html.slim +5 -0
  13. data/app/assets/javascripts/templates/categories/form.html.slim +32 -0
  14. data/app/assets/javascripts/templates/categories/index.html.slim +21 -0
  15. data/app/assets/javascripts/templates/categories/new.html.slim +5 -0
  16. data/app/assets/javascripts/templates/help/catalog_variables.html.slim +75 -0
  17. data/app/assets/javascripts/templates/products/edit.html.slim +25 -0
  18. data/app/assets/javascripts/templates/products/form.html.slim +34 -0
  19. data/app/assets/javascripts/templates/products/index.html.slim +22 -0
  20. data/app/assets/javascripts/templates/products/new.html.slim +5 -0
  21. data/app/assets/javascripts/templates/products/option_types.html.slim +47 -0
  22. data/app/assets/javascripts/templates/products/properties.html.slim +52 -0
  23. data/app/assets/javascripts/templates/products/variants/edit.html.slim +7 -0
  24. data/app/assets/javascripts/templates/products/variants/form.html.slim +18 -0
  25. data/app/assets/javascripts/templates/products/variants/index.html.slim +22 -0
  26. data/app/assets/javascripts/templates/products/variants/new.html.slim +5 -0
  27. data/app/assets/javascripts/templates/products/variants/option_types.html.slim +39 -0
  28. data/app/controllers/kms/catalog/categories_controller.rb +40 -0
  29. data/app/controllers/kms/catalog/option_types_controller.rb +42 -0
  30. data/app/controllers/kms/catalog/option_values_controller.rb +31 -0
  31. data/app/controllers/kms/catalog/products_controller.rb +40 -0
  32. data/app/controllers/kms/catalog/properties_controller.rb +41 -0
  33. data/app/controllers/kms/catalog/variants_controller.rb +46 -0
  34. data/app/models/kms/category.rb +23 -0
  35. data/app/models/kms/option_type.rb +12 -0
  36. data/app/models/kms/option_value.rb +9 -0
  37. data/app/models/kms/product.rb +20 -0
  38. data/app/models/kms/product_option_type.rb +6 -0
  39. data/app/models/kms/property.rb +6 -0
  40. data/app/models/kms/variant.rb +10 -0
  41. data/app/uploaders/category_logo_uploader.rb +51 -0
  42. data/app/uploaders/product_image_uploader.rb +51 -0
  43. data/config/initializers/ability.rb +4 -0
  44. data/config/initializers/externals.rb +2 -0
  45. data/config/initializers/help.rb +1 -0
  46. data/config/initializers/resources.rb +2 -0
  47. data/config/locales/en.yml +103 -0
  48. data/config/locales/ru.yml +102 -0
  49. data/config/routes.rb +24 -0
  50. data/db/migrate/20141112110053_create_categories.rb +9 -0
  51. data/db/migrate/20141112110205_add_ancestry_to_categories.rb +6 -0
  52. data/db/migrate/20141114085509_create_products.rb +11 -0
  53. data/db/migrate/20141114090047_create_categories_products.rb +11 -0
  54. data/db/migrate/20141115155853_add_slug_to_products.rb +6 -0
  55. data/db/migrate/20141115155858_add_slug_to_categories.rb +6 -0
  56. data/db/migrate/20150211160743_add_description_and_logo_to_categories.rb +6 -0
  57. data/db/migrate/20150212132208_add_preview_image_and_image_to_product.rb +6 -0
  58. data/db/migrate/20150212154511_create_properties.rb +11 -0
  59. data/db/migrate/20150213084534_create_option_types.rb +10 -0
  60. data/db/migrate/20150213084605_create_product_option_types.rb +12 -0
  61. data/db/migrate/20150216070337_create_variants.rb +12 -0
  62. data/db/migrate/20150216070829_create_option_values.rb +13 -0
  63. data/db/migrate/20150306060509_change_price_field_for_products.rb +6 -0
  64. data/db/migrate/20150310144540_add_position_to_category.rb +5 -0
  65. data/db/migrate/20150818073220_add_seo_fields_to_categories.rb +7 -0
  66. data/db/migrate/20150818073725_add_seo_fields_to_products.rb +7 -0
  67. data/db/migrate/20151001065303_add_image_to_variants.rb +5 -0
  68. data/lib/generators/kms_catalog/install/install_generator.rb +17 -0
  69. data/lib/kms/catalog/engine.rb +15 -0
  70. data/lib/kms/catalog/version.rb +5 -0
  71. data/lib/kms/drops/category_drop.rb +16 -0
  72. data/lib/kms/drops/product_drop.rb +35 -0
  73. data/lib/kms/drops/property_drop.rb +6 -0
  74. data/lib/kms/drops/variant_drop.rb +15 -0
  75. data/lib/kms_catalog.rb +6 -0
  76. data/lib/tasks/kms_catalog_tasks.rake +4 -0
  77. data/test/catalog_test.rb +7 -0
  78. data/test/dummy/README.rdoc +28 -0
  79. data/test/dummy/Rakefile +6 -0
  80. data/test/dummy/app/assets/javascripts/application.js +13 -0
  81. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  82. data/test/dummy/app/controllers/application_controller.rb +5 -0
  83. data/test/dummy/app/helpers/application_helper.rb +2 -0
  84. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  85. data/test/dummy/bin/bundle +3 -0
  86. data/test/dummy/bin/rails +4 -0
  87. data/test/dummy/bin/rake +4 -0
  88. data/test/dummy/bin/setup +29 -0
  89. data/test/dummy/config/application.rb +26 -0
  90. data/test/dummy/config/boot.rb +5 -0
  91. data/test/dummy/config/database.yml +25 -0
  92. data/test/dummy/config/environment.rb +5 -0
  93. data/test/dummy/config/environments/development.rb +41 -0
  94. data/test/dummy/config/environments/production.rb +77 -0
  95. data/test/dummy/config/environments/test.rb +42 -0
  96. data/test/dummy/config/initializers/assets.rb +11 -0
  97. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  98. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  99. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  100. data/test/dummy/config/initializers/inflections.rb +16 -0
  101. data/test/dummy/config/initializers/mime_types.rb +4 -0
  102. data/test/dummy/config/initializers/session_store.rb +3 -0
  103. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  104. data/test/dummy/config/locales/en.yml +23 -0
  105. data/test/dummy/config/routes.rb +56 -0
  106. data/test/dummy/config/secrets.yml +22 -0
  107. data/test/dummy/config.ru +4 -0
  108. data/test/dummy/public/404.html +67 -0
  109. data/test/dummy/public/422.html +67 -0
  110. data/test/dummy/public/500.html +66 -0
  111. data/test/dummy/public/favicon.ico +0 -0
  112. data/test/fixtures/categories.yml +7 -0
  113. data/test/fixtures/option_types.yml +9 -0
  114. data/test/fixtures/option_values.yml +9 -0
  115. data/test/fixtures/product_option_types.yml +9 -0
  116. data/test/fixtures/products.yml +11 -0
  117. data/test/fixtures/properties.yml +11 -0
  118. data/test/fixtures/variants.yml +9 -0
  119. data/test/integration/navigation_test.rb +10 -0
  120. data/test/models/category_test.rb +7 -0
  121. data/test/models/option_type_test.rb +7 -0
  122. data/test/models/option_value_test.rb +7 -0
  123. data/test/models/product_option_type_test.rb +7 -0
  124. data/test/models/product_test.rb +7 -0
  125. data/test/models/property_test.rb +7 -0
  126. data/test/models/variant_test.rb +7 -0
  127. data/test/test_helper.rb +16 -0
  128. metadata +306 -0
@@ -0,0 +1,20 @@
1
+ module Kms
2
+ class Product < ActiveRecord::Base
3
+ include Liquor::Dropable
4
+ extend FriendlyId
5
+ include Kms::Permalinkable
6
+ include Kms::CompileTemplates
7
+ has_and_belongs_to_many :categories
8
+ has_many :properties, dependent: :destroy
9
+
10
+ has_many :product_option_types, dependent: :destroy
11
+ has_many :option_types, through: :product_option_types
12
+
13
+ has_many :variants, dependent: :destroy
14
+
15
+ friendly_id :name, use: :slugged
16
+
17
+ mount_uploader :image, ProductImageUploader
18
+ mount_uploader :preview_image, ProductImageUploader
19
+ end
20
+ end
@@ -0,0 +1,6 @@
1
+ module Kms
2
+ class ProductOptionType < ActiveRecord::Base
3
+ belongs_to :product
4
+ belongs_to :option_type
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Kms
2
+ class Property < ActiveRecord::Base
3
+ include Liquor::Dropable
4
+ belongs_to :product
5
+ end
6
+ end
@@ -0,0 +1,10 @@
1
+ module Kms
2
+ class Variant < ActiveRecord::Base
3
+ include Liquor::Dropable
4
+ belongs_to :product
5
+ has_many :option_values, dependent: :destroy
6
+ has_many :option_types, through: :option_values
7
+
8
+ mount_uploader :image, ProductImageUploader
9
+ end
10
+ end
@@ -0,0 +1,51 @@
1
+ # encoding: utf-8
2
+
3
+ class CategoryLogoUploader < CarrierWave::Uploader::Base
4
+
5
+ # Include RMagick or MiniMagick support:
6
+ # include CarrierWave::RMagick
7
+ # include CarrierWave::MiniMagick
8
+
9
+ # Choose what kind of storage to use for this uploader:
10
+ storage :file
11
+ # storage :fog
12
+
13
+ # Override the directory where uploaded files will be stored.
14
+ # This is a sensible default for uploaders that are meant to be mounted:
15
+ def store_dir
16
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
17
+ end
18
+
19
+ # Provide a default URL as a default if there hasn't been a file uploaded:
20
+ # def default_url
21
+ # # For Rails 3.1+ asset pipeline compatibility:
22
+ # # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
23
+ #
24
+ # "/images/fallback/" + [version_name, "default.png"].compact.join('_')
25
+ # end
26
+
27
+ # Process files as they are uploaded:
28
+ # process :scale => [200, 300]
29
+ #
30
+ # def scale(width, height)
31
+ # # do something
32
+ # end
33
+
34
+ # Create different versions of your uploaded files:
35
+ # version :thumb do
36
+ # process :resize_to_fit => [50, 50]
37
+ # end
38
+
39
+ # Add a white list of extensions which are allowed to be uploaded.
40
+ # For images you might use something like this:
41
+ # def extension_white_list
42
+ # %w(jpg jpeg gif png)
43
+ # end
44
+
45
+ # Override the filename of the uploaded files:
46
+ # Avoid using model.id or version_name here, see uploader/store.rb for details.
47
+ # def filename
48
+ # "something.jpg" if original_filename
49
+ # end
50
+
51
+ end
@@ -0,0 +1,51 @@
1
+ # encoding: utf-8
2
+
3
+ class ProductImageUploader < CarrierWave::Uploader::Base
4
+
5
+ # Include RMagick or MiniMagick support:
6
+ # include CarrierWave::RMagick
7
+ # include CarrierWave::MiniMagick
8
+
9
+ # Choose what kind of storage to use for this uploader:
10
+ storage :file
11
+ # storage :fog
12
+
13
+ # Override the directory where uploaded files will be stored.
14
+ # This is a sensible default for uploaders that are meant to be mounted:
15
+ def store_dir
16
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
17
+ end
18
+
19
+ # Provide a default URL as a default if there hasn't been a file uploaded:
20
+ # def default_url
21
+ # # For Rails 3.1+ asset pipeline compatibility:
22
+ # # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
23
+ #
24
+ # "/images/fallback/" + [version_name, "default.png"].compact.join('_')
25
+ # end
26
+
27
+ # Process files as they are uploaded:
28
+ # process :scale => [200, 300]
29
+ #
30
+ # def scale(width, height)
31
+ # # do something
32
+ # end
33
+
34
+ # Create different versions of your uploaded files:
35
+ # version :thumb do
36
+ # process :resize_to_fit => [50, 50]
37
+ # end
38
+
39
+ # Add a white list of extensions which are allowed to be uploaded.
40
+ # For images you might use something like this:
41
+ # def extension_white_list
42
+ # %w(jpg jpeg gif png)
43
+ # end
44
+
45
+ # Override the filename of the uploaded files:
46
+ # Avoid using model.id or version_name here, see uploader/store.rb for details.
47
+ # def filename
48
+ # "something.jpg" if original_filename
49
+ # end
50
+
51
+ end
@@ -0,0 +1,4 @@
1
+ Kms::AbilityService.register do
2
+ can :manage, Kms::Category
3
+ can :manage, Kms::Product
4
+ end
@@ -0,0 +1,2 @@
1
+ Kms::ExternalsRegistry.register(:categories) {|_,_| Kms::Category.order('position asc').all.to_drop }
2
+ Kms::ExternalsRegistry.register(:products) {|_,_| Kms::Product.all.to_drop }
@@ -0,0 +1 @@
1
+ Kms::HelpService.register_templates Kms::Catalog::Engine, 'help/catalog_variables.html'
@@ -0,0 +1,2 @@
1
+ Kms::ResourceService.register(:catalog, Kms::Category, "fa-list")
2
+ Kms::ResourceService.register(:catalog, Kms::Product, "fa-barcode")
@@ -0,0 +1,103 @@
1
+ en:
2
+ catalog: "Catalog"
3
+ new_category: "New Category"
4
+ add_category: "Add Category"
5
+ update_category: "Update Category"
6
+ new_product: "New Product"
7
+ add_product: "Add Product"
8
+ update_product: "Update Product"
9
+ create_property: "Create Property"
10
+ create_option_type: "Create Option Type"
11
+ new_variant: "New Variant"
12
+ add_variant: "Add Variant"
13
+ update_variant: "Update Variant"
14
+ add_option_value: "Add Option Value"
15
+ type_group_name_for_options_placeholder: "Type group/tag name for grouping option types..."
16
+ type_group_name_for_properties_placeholder: "Type group/tag name for grouping properties..."
17
+ or_select_from_list_placeholder: "... or select from list"
18
+ select_option_type_from_list_placeholder: "Select option type from list"
19
+ liquor_help:
20
+ variables:
21
+ categories:
22
+ main_description: '"categories" returns collection of categories created in "Categories" section:&nbsp;'
23
+ properties:
24
+ name: 'Category name'
25
+ permalink: 'Permalink for generating link to category page'
26
+ description: 'Description'
27
+ logo_url: 'Logo URL'
28
+ children: 'Child categories'
29
+ parent: 'Parent category'
30
+ products: 'Products'
31
+ products:
32
+ main_description: '"products" returns collection of products created in "Products" section:&nbsp;'
33
+ properties:
34
+ name: 'Product name'
35
+ price: 'Price'
36
+ permalink: 'Permalink for generating link to product page'
37
+ description: 'Description'
38
+ image_url: 'Image URL'
39
+ preview_image_url: 'Preview Image URL'
40
+ categories: 'Categories'
41
+ variants: 'Variants'
42
+ properties: 'Properties'
43
+
44
+ activerecord:
45
+ models:
46
+ kms/category:
47
+ one: "Category"
48
+ few: "Categories"
49
+ many: "Categories"
50
+ other: "Categories"
51
+ kms/product:
52
+ one: "Product"
53
+ few: "Products"
54
+ many: "Products"
55
+ other: "Products"
56
+ kms/property:
57
+ one: "Property"
58
+ few: "Properties"
59
+ many: "Properties"
60
+ other: "Properties"
61
+ kms/option_type:
62
+ one: "Option Type"
63
+ few: "Option Types"
64
+ many: "Option Types"
65
+ other: "Option Types"
66
+ kms/variant:
67
+ one: "Variant"
68
+ few: "Variants"
69
+ many: "Variants"
70
+ other: "Variants"
71
+ attributes:
72
+ kms/category:
73
+ name: "Name"
74
+ parent: "Parent category"
75
+ description: "Description"
76
+ logo: "Logo"
77
+ seo_title: "Title"
78
+ seo_keywords: "Meta Keywords"
79
+ seo_description: "Meta Description"
80
+ kms/product:
81
+ name: "Name"
82
+ description: "Description"
83
+ price: "Price"
84
+ categories: "Categories"
85
+ preview_image: "Preview image"
86
+ image: "Main image"
87
+ seo_title: "Title"
88
+ seo_keywords: "Meta Keywords"
89
+ seo_description: "Meta Description"
90
+ kms/property:
91
+ tag: "Group/Tag"
92
+ name: "Name"
93
+ value: "Value"
94
+ kms/option_type:
95
+ tag: "Group/Tag"
96
+ name: "Name"
97
+ kms/variant:
98
+ name: "Name"
99
+ price: "Price"
100
+ image: "Image"
101
+ kms/option_value:
102
+ option_type: "Option Type"
103
+ value: "Value"
@@ -0,0 +1,102 @@
1
+ ru:
2
+ catalog: "Каталог"
3
+ new_category: "Новая Категория"
4
+ add_category: "Добавить категорию"
5
+ update_category: "Обновить категорию"
6
+ new_product: "Новый Продукт"
7
+ add_product: "Добавить продукт"
8
+ update_product: "Обновить продукт"
9
+ create_property: "Создать свойство"
10
+ create_option_type: "Создать товарную опцию"
11
+ new_variant: "Новый Вариант"
12
+ add_variant: "Добавить вариант"
13
+ update_variant: "Обновить вариант"
14
+ add_option_value: "Добавить значение товарное опции"
15
+ type_group_name_for_options_placeholder: "Введите название группы для группировки товарных опций..."
16
+ type_group_name_for_properties_placeholder: "Введите название группы для группировки свойств..."
17
+ or_select_from_list_placeholder: "... или выберите из списка"
18
+ select_option_type_from_list_placeholder: "Выберите из списка товарную опцию"
19
+ liquor_help:
20
+ variables:
21
+ categories:
22
+ main_description: '"categories" возвращает коллекцию категорий, созданных в разделе "Категории":&nbsp;'
23
+ properties:
24
+ name: 'Название'
25
+ permalink: 'Ссылка'
26
+ description: 'Описание'
27
+ logo_url: 'URL лого'
28
+ children: 'Дочерние категории'
29
+ parent: 'Родительская категория'
30
+ products: 'Продукты'
31
+ products:
32
+ main_description: '"products" возвращает коллекцию товаров, созданных в разделе "Продукты":&nbsp;'
33
+ properties:
34
+ name: 'Название'
35
+ price: 'Цена'
36
+ permalink: 'Ссылка'
37
+ description: 'Описание'
38
+ image_url: 'URL изображения'
39
+ preview_image_url: 'URL изображения-превью'
40
+ categories: 'Категории'
41
+ variants: 'Варианты'
42
+ properties: 'Свойства'
43
+ activerecord:
44
+ models:
45
+ kms/category:
46
+ one: "Категория"
47
+ few: "Категории"
48
+ many: "Категорий"
49
+ other: "Категории"
50
+ kms/product:
51
+ one: "Продукт"
52
+ few: "Продукта"
53
+ many: "Продуктов"
54
+ other: "Продукты"
55
+ kms/property:
56
+ one: "Свойство"
57
+ few: "Свойства"
58
+ many: "Свойств"
59
+ other: "Свойства"
60
+ kms/option_type:
61
+ one: "Товарная опция"
62
+ few: "Товарные опции"
63
+ many: "Товарных опций"
64
+ other: "Товарные опции"
65
+ kms/variant:
66
+ one: "Вариант"
67
+ few: "Варианта"
68
+ many: "Вариантов"
69
+ other: "Варианты"
70
+ attributes:
71
+ kms/category:
72
+ name: "Название"
73
+ parent: "Родительская категория"
74
+ description: "Описание"
75
+ logo: "Логотип"
76
+ seo_title: "Title"
77
+ seo_keywords: "Meta Keywords"
78
+ seo_description: "Meta Description"
79
+ kms/product:
80
+ name: "Название"
81
+ description: "Описание"
82
+ price: "Цена"
83
+ categories: "Категории"
84
+ preview_image: "Превью"
85
+ image: "Основное изображение"
86
+ seo_title: "Title"
87
+ seo_keywords: "Meta Keywords"
88
+ seo_description: "Meta Description"
89
+ kms/property:
90
+ tag: "Группа/Тэг"
91
+ name: "Название"
92
+ value: "Значение"
93
+ kms/option_type:
94
+ tag: "Группа/Тэг"
95
+ name: "Наименование"
96
+ kms/variant:
97
+ name: "Название"
98
+ price: "Цена"
99
+ image: "Изображение"
100
+ kms/option_value:
101
+ option_type: "Товарная опция"
102
+ value: "Значение"
data/config/routes.rb ADDED
@@ -0,0 +1,24 @@
1
+ Kms::Catalog::Engine.routes.draw do
2
+ constraints(format: "json") do
3
+ resources :categories, format: true do
4
+ member do
5
+ post '' => 'categories#update'
6
+ end
7
+ end
8
+ resources :products, format: true do
9
+ member do
10
+ post '' => 'products#update'
11
+ end
12
+ resources :properties, format: true, only: [:index, :create, :update, :destroy]
13
+ resources :option_types, format: true, only: [:index, :create, :destroy]
14
+ resources :variants, format: true do
15
+ resources :option_values, format: true
16
+ member do
17
+ get 'available_option_types'
18
+ post '' => 'variants#update'
19
+ end
20
+ end
21
+ end
22
+ resources :option_types, format: true, only: :index
23
+ end
24
+ end
@@ -0,0 +1,9 @@
1
+ class CreateCategories < ActiveRecord::Migration
2
+ def change
3
+ create_table :kms_categories do |t|
4
+ t.string :name
5
+
6
+ t.timestamps null: false
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,6 @@
1
+ class AddAncestryToCategories < ActiveRecord::Migration
2
+ def change
3
+ add_column :kms_categories, :ancestry, :string
4
+ add_index :kms_categories, :ancestry
5
+ end
6
+ end
@@ -0,0 +1,11 @@
1
+ class CreateProducts < ActiveRecord::Migration
2
+ def change
3
+ create_table :kms_products do |t|
4
+ t.string :name
5
+ t.text :description
6
+ t.decimal :price, precision: 8, scale: 2
7
+
8
+ t.timestamps null: false
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class CreateCategoriesProducts < ActiveRecord::Migration
2
+ def change
3
+ create_table :kms_categories_products, id: false do |t|
4
+ t.integer :category_id
5
+ t.integer :product_id
6
+ end
7
+
8
+ add_index :kms_categories_products, :category_id
9
+ add_index :kms_categories_products, :product_id
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ class AddSlugToProducts < ActiveRecord::Migration
2
+ def change
3
+ add_column :kms_products, :slug, :string
4
+ add_index :kms_products, :slug, :unique => true
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class AddSlugToCategories < ActiveRecord::Migration
2
+ def change
3
+ add_column :kms_categories, :slug, :string
4
+ add_index :kms_categories, :slug, :unique => true
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class AddDescriptionAndLogoToCategories < ActiveRecord::Migration
2
+ def change
3
+ add_column :kms_categories, :description, :text
4
+ add_column :kms_categories, :logo, :string
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class AddPreviewImageAndImageToProduct < ActiveRecord::Migration
2
+ def change
3
+ add_column :kms_products, :image, :string
4
+ add_column :kms_products, :preview_image, :string
5
+ end
6
+ end
@@ -0,0 +1,11 @@
1
+ class CreateProperties < ActiveRecord::Migration
2
+ def change
3
+ create_table :kms_properties do |t|
4
+ t.string :name
5
+ t.string :value
6
+ t.string :tag
7
+ t.references :product
8
+ t.timestamps null: false
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,10 @@
1
+ class CreateOptionTypes < ActiveRecord::Migration
2
+ def change
3
+ create_table :kms_option_types do |t|
4
+ t.string :tag
5
+ t.string :name
6
+
7
+ t.timestamps null: false
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,12 @@
1
+ class CreateProductOptionTypes < ActiveRecord::Migration
2
+ def change
3
+ create_table :kms_product_option_types do |t|
4
+ t.references :product, index: true
5
+ t.references :option_type, index: true
6
+
7
+ t.timestamps null: false
8
+ end
9
+ add_foreign_key :kms_product_option_types, :products if respond_to?(:add_foreign_key)
10
+ add_foreign_key :kms_product_option_types, :option_types if respond_to?(:add_foreign_key)
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ class CreateVariants < ActiveRecord::Migration
2
+ def change
3
+ create_table :kms_variants do |t|
4
+ t.string :name
5
+ t.decimal :price, precision: 8, scale: 2
6
+ t.references :product, index: true
7
+
8
+ t.timestamps null: false
9
+ end
10
+ add_foreign_key :kms_variants, :kms_products if respond_to?(:add_foreign_key)
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ class CreateOptionValues < ActiveRecord::Migration
2
+ def change
3
+ create_table :kms_option_values do |t|
4
+ t.references :option_type, index: true
5
+ t.references :variant, index: true
6
+ t.string :value
7
+
8
+ t.timestamps null: false
9
+ end
10
+ add_foreign_key :kms_option_values, :kms_option_types if respond_to?(:add_foreign_key)
11
+ add_foreign_key :kms_option_values, :kms_variants if respond_to?(:add_foreign_key)
12
+ end
13
+ end
@@ -0,0 +1,6 @@
1
+ class ChangePriceFieldForProducts < ActiveRecord::Migration
2
+ def change
3
+ change_column :kms_products, :price, :decimal, precision: 12, scale: 2
4
+ change_column :kms_variants, :price, :decimal, precision: 12, scale: 2
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ class AddPositionToCategory < ActiveRecord::Migration
2
+ def change
3
+ add_column :kms_categories, :position, :integer, default: 0, null: false
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ class AddSeoFieldsToCategories < ActiveRecord::Migration
2
+ def change
3
+ add_column :kms_categories, :seo_title, :string
4
+ add_column :kms_categories, :seo_keywords, :string
5
+ add_column :kms_categories, :seo_description, :string
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ class AddSeoFieldsToProducts < ActiveRecord::Migration
2
+ def change
3
+ add_column :kms_products, :seo_title, :string
4
+ add_column :kms_products, :seo_keywords, :string
5
+ add_column :kms_products, :seo_description, :string
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ class AddImageToVariants < ActiveRecord::Migration
2
+ def change
3
+ add_column :kms_variants, :image, :string
4
+ end
5
+ end
@@ -0,0 +1,17 @@
1
+ module KmsCatalog
2
+ class InstallGenerator < Rails::Generators::Base
3
+
4
+ source_root File.expand_path('../../../../../', __FILE__)
5
+
6
+ def insert_engine_routes
7
+ route %(
8
+ mount Kms::Catalog::Engine => '/kms'
9
+ )
10
+ end
11
+
12
+ def insert_javascript
13
+ append_file "app/assets/javascripts/application.js", "//= require kms_catalog/application\n"
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ require "friendly_id"
2
+ module Kms
3
+ module Catalog
4
+ class Engine < ::Rails::Engine
5
+ engine_name 'kms_catalog'
6
+ isolate_namespace Kms::Catalog
7
+ config.eager_load_paths += Dir["#{config.root}/lib/**/"]
8
+ config.to_prepare do
9
+ Dir.glob(Rails.root + "**/*_decorator*.rb").each do |c|
10
+ require_dependency(c)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ module Kms
2
+ module Catalog
3
+ VERSION = "0.4.0"
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ module Kms
2
+ class CategoryDrop < Liquor::Drop
3
+ include Kms::Catalog::Engine.routes.url_helpers
4
+ attributes :name, :permalink, :description
5
+ has_many :children
6
+ has_many :products
7
+ belongs_to :parent
8
+
9
+ export :logo_url
10
+ scopes :order
11
+
12
+ def logo_url
13
+ source.logo.url
14
+ end
15
+ end
16
+ end