solidus_catalog_mode 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f3014cba432defc54fe3ceb22dbafac65bf686bf
4
+ data.tar.gz: 69639addc38836d0e49dfdc4f7483a56004ead50
5
+ SHA512:
6
+ metadata.gz: c9aa98e5b70b461a94d2f20657e942b27ee357ebaf38a42576bc1890e2c74e1570822432e554415a5dd1e074db516ee42edc3e5d20b2ec68dec41b0e10996c4a
7
+ data.tar.gz: e964bfa77bfb3f50ecd237d6a28008f0a1df6d24781e0fcc8b4280a8afdaf5d13d891e12c2c7db5ddb9fe2b1aaabd837415135c643501cba112da971b8e8934b
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2017 Antonio Facciolo
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Spree nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ SolidusCatalogMode
2
+ ==================
3
+
4
+ This extension allow the user to set products not for online sale.
5
+ In this way we could use Solidus to show only the catalog of our products,
6
+ without the online store functionality.
7
+
8
+ Installation
9
+ ------------
10
+
11
+ Add solidus_catalog_mode to your Gemfile:
12
+
13
+ ```ruby
14
+ gem 'solidus_catalog_mode'
15
+ ```
16
+
17
+ Bundle your dependencies and run the installation generator:
18
+
19
+ ```shell
20
+ bundle
21
+ bundle exec rails g solidus_catalog_mode:install
22
+ ```
23
+
24
+ Usage
25
+ -------
26
+
27
+ This gem adds a boolean field to the products and to the stores.
28
+ In this way you could set a single product or the complete store to be in "catalog mode".
29
+ Then in your store frontend you can use this information to disable the link to the cart,
30
+ the price and the cart form in the product page.
31
+
32
+ Dependencies
33
+ -------
34
+ If you want to be able to set the flag for the stores in the backend, it requires the [solidus_multi_domain](https://github.com/solidusio/solidus_multi_domain) gem.
35
+
36
+ Testing
37
+ -------
38
+
39
+ First bundle your dependencies, then run `rake`. `rake` will default to building the dummy app if it does not exist, then it will run specs, and [Rubocop](https://github.com/bbatsov/rubocop) static code analysis. The dummy app can be regenerated by using `rake test_app`.
40
+
41
+ ```shell
42
+ bundle
43
+ bundle exec rake
44
+ ```
45
+
46
+ When testing your applications integration with this extension you may use it's factories.
47
+ Simply add this require statement to your spec_helper:
48
+
49
+ ```ruby
50
+ require 'solidus_catalog_mode/factories'
51
+ ```
52
+
53
+ Copyright (c) 2017 Antonio Facciolo, released under the New BSD License
data/Rakefile ADDED
@@ -0,0 +1,30 @@
1
+ require 'bundler'
2
+
3
+ Bundler::GemHelper.install_tasks
4
+
5
+ begin
6
+ require 'spree/testing_support/extension_rake'
7
+ require 'rubocop/rake_task'
8
+ require 'rspec/core/rake_task'
9
+
10
+ RSpec::Core::RakeTask.new(:spec)
11
+
12
+ RuboCop::RakeTask.new
13
+
14
+ task default: %i(first_run rubocop spec)
15
+ rescue LoadError
16
+ # no rspec available
17
+ end
18
+
19
+ task :first_run do
20
+ if Dir['spec/dummy'].empty?
21
+ Rake::Task[:test_app].invoke
22
+ Dir.chdir('../../')
23
+ end
24
+ end
25
+
26
+ desc 'Generates a dummy app for testing'
27
+ task :test_app do
28
+ ENV['LIB_NAME'] = 'solidus_catalog_mode'
29
+ Rake::Task['extension:test_app'].invoke
30
+ end
@@ -0,0 +1,2 @@
1
+ // Placeholder manifest file.
2
+ // the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/backend/all.js'
@@ -0,0 +1,2 @@
1
+ // Placeholder manifest file.
2
+ // the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/frontend/all.js'
@@ -0,0 +1,4 @@
1
+ /*
2
+ Placeholder manifest file.
3
+ the installer will append this file to the app vendored assets here: 'vendor/assets/stylesheets/spree/backend/all.css'
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Placeholder manifest file.
3
+ the installer will append this file to the app vendored assets here: 'vendor/assets/stylesheets/spree/frontend/all.css'
4
+ */
@@ -0,0 +1,9 @@
1
+ module SolidusCatalogMode::LineItemConcerns
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ delegate :catalog_mode, to: :product
6
+
7
+ validates :catalog_mode, inclusion: { in: [false], message: :should_be_false }
8
+ end
9
+ end
@@ -0,0 +1 @@
1
+ Spree::LineItem.include(SolidusCatalogMode::LineItemConcerns)
@@ -0,0 +1,9 @@
1
+ module Spree
2
+ module OrderDecorator
3
+ def checkout_allowed?
4
+ super && !store.catalog_mode? && line_items.none? { |l| l.variant.product.catalog_mode? }
5
+ end
6
+ end
7
+ end
8
+
9
+ Spree::Order.prepend Spree::OrderDecorator
@@ -0,0 +1,7 @@
1
+ Deface::Override.new(
2
+ virtual_path: "spree/admin/products/_form",
3
+ name: "catalog_mode_admin_product_form",
4
+ insert_after: "[data-hook='admin_product_form_promotionable']",
5
+ partial: "spree/admin/products/catalog_mode",
6
+ disabled: false
7
+ )
@@ -0,0 +1,7 @@
1
+ Deface::Override.new(
2
+ virtual_path: "spree/admin/stores/_form",
3
+ name: "catalog_mode_admin_store_form",
4
+ insert_bottom: "[data-hook='admin_store_form_fields']",
5
+ partial: "spree/admin/stores/catalog_mode",
6
+ disabled: false
7
+ )
@@ -0,0 +1,8 @@
1
+ <div data-hook="admin_product_form_catalog_mode">
2
+ <%= f.field_container :catalog_mode do %>
3
+ <%= f.label :catalog_mode do %>
4
+ <%= f.check_box :catalog_mode %> <%= Spree::Product.human_attribute_name(:catalog_mode) %>
5
+ <% end %>
6
+ <%= f.field_hint :catalog_mode %>
7
+ <% end %>
8
+ </div>
@@ -0,0 +1,12 @@
1
+ <div data-hook="admin_store_form_catalog_mode">
2
+ <div class="row">
3
+ <div class="four columns">
4
+ <%= f.field_container :catalog_mode do %>
5
+ <%= f.label :catalog_mode do %>
6
+ <%= f.check_box :catalog_mode %> <%= Spree::Store.human_attribute_name(:catalog_mode) %>
7
+ <% end %>
8
+ <%= f.field_hint :catalog_mode %>
9
+ <% end %>
10
+ </div>
11
+ </div>
12
+ </div>
@@ -0,0 +1,9 @@
1
+ de:
2
+ activerecord:
3
+ errors:
4
+ models:
5
+ spree/line_item:
6
+ attributes:
7
+ catalog_mode:
8
+ should_be_false: "sollte false sein"
9
+
@@ -0,0 +1,15 @@
1
+ en:
2
+ activerecord:
3
+ errors:
4
+ models:
5
+ spree/line_item:
6
+ attributes:
7
+ catalog_mode:
8
+ should_be_false: "should be false"
9
+ spree:
10
+ hints:
11
+ spree/product:
12
+ catalog_mode: "This determines whether or not for this product the catalog mode is enabled (the online sale is disabled).<br/>Default: Not Checked"
13
+ spree/store:
14
+ catalog_mode: "This determines whether or not for this store the catalog mode is enabled (the online sale is disabled).<br/>Default: Not Checked"
15
+
@@ -0,0 +1,14 @@
1
+ it:
2
+ activerecord:
3
+ errors:
4
+ models:
5
+ spree/line_item:
6
+ attributes:
7
+ catalog_mode:
8
+ should_be_false: "deve essere false"
9
+ spree:
10
+ hints:
11
+ spree/product:
12
+ catalog_mode: "Determina se per questo prodotto è abilitata la modalità catalogo (la vendita nello store online è disabilitata).<br/>Default: Non spuntato"
13
+ spree/store:
14
+ catalog_mode: "Determina se per questo negozio è abilitata la modalità catalogo (la vendita nello store online è disabilitata).<br/>Default: Non spuntato"
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Spree::Core::Engine.routes.draw do
2
+ # Add your extension routes here
3
+ end
@@ -0,0 +1,5 @@
1
+ class AddCatalogModeToSpreeProducts < ActiveRecord::Migration[5.1]
2
+ def change
3
+ add_column :spree_products, :catalog_mode, :boolean, default: false
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddCatalogModeToSpreeStores < ActiveRecord::Migration[5.1]
2
+ def change
3
+ add_column :spree_stores, :catalog_mode, :boolean, default: false
4
+ end
5
+ end
@@ -0,0 +1,20 @@
1
+ module SolidusCatalogMode
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ class_option :auto_run_migrations, type: :boolean, default: false
5
+
6
+ def add_migrations
7
+ run 'bundle exec rake railties:install:migrations FROM=solidus_catalog_mode'
8
+ end
9
+
10
+ def run_migrations
11
+ run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]'))
12
+ if run_migrations
13
+ run 'bundle exec rake db:migrate'
14
+ else
15
+ puts 'Skipping rake db:migrate, don\'t forget to run it!'
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module SolidusCatalogMode
2
+ class Engine < Rails::Engine
3
+ require 'spree/core'
4
+ isolate_namespace Spree
5
+ engine_name 'solidus_catalog_mode'
6
+
7
+ # use rspec for tests
8
+ config.generators do |g|
9
+ g.test_framework :rspec
10
+ end
11
+
12
+ def self.activate
13
+ Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
14
+ Rails.configuration.cache_classes ? require(c) : load(c)
15
+ end
16
+ end
17
+
18
+ config.to_prepare(&method(:activate).to_proc)
19
+ end
20
+ end
@@ -0,0 +1,6 @@
1
+ FactoryGirl.define do
2
+ # Define your Spree extensions Factories within this file to enable applications, and other extensions to use and override them.
3
+ #
4
+ # Example adding this to your spec_helper will load these Factories for use:
5
+ # require 'solidus_catalog_mode/factories'
6
+ end
@@ -0,0 +1,3 @@
1
+ module SolidusCatalogMode
2
+ VERSION = '0.2.0'
3
+ end
@@ -0,0 +1,2 @@
1
+ require 'solidus_core'
2
+ require 'solidus_catalog_mode/engine'
metadata ADDED
@@ -0,0 +1,237 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: solidus_catalog_mode
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Antonio Facciolo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-11-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: solidus_core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: capybara
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: poltergeist
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: coffee-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sass-rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: database_cleaner
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: factory_girl
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec-rails
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 0.37.2
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 0.37.2
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop-rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '='
144
+ - !ruby/object:Gem::Version
145
+ version: 1.4.0
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '='
151
+ - !ruby/object:Gem::Version
152
+ version: 1.4.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: simplecov
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: sqlite3
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ description: Allow to set products only to show, but not for online sale (catalog
182
+ mode)
183
+ email: afdev82@gmail.com
184
+ executables: []
185
+ extensions: []
186
+ extra_rdoc_files: []
187
+ files:
188
+ - LICENSE
189
+ - README.md
190
+ - Rakefile
191
+ - app/assets/javascripts/spree/backend/solidus_catalog_mode.js
192
+ - app/assets/javascripts/spree/frontend/solidus_catalog_mode.js
193
+ - app/assets/stylesheets/spree/backend/solidus_catalog_mode.css
194
+ - app/assets/stylesheets/spree/frontend/solidus_catalog_mode.css
195
+ - app/models/solidus_catalog_mode/line_item_concerns.rb
196
+ - app/models/spree/line_item_decorator.rb
197
+ - app/models/spree/order_decorator.rb
198
+ - app/overrides/decorate_admin_products_form.rb
199
+ - app/overrides/decorate_admin_stores_form.rb
200
+ - app/views/spree/admin/products/_catalog_mode.html.erb
201
+ - app/views/spree/admin/stores/_catalog_mode.html.erb
202
+ - config/locales/de.yml
203
+ - config/locales/en.yml
204
+ - config/locales/it.yml
205
+ - config/routes.rb
206
+ - db/migrate/20171102143731_add_catalog_mode_to_spree_products.rb
207
+ - db/migrate/20171103083640_add_catalog_mode_to_spree_stores.rb
208
+ - lib/generators/solidus_catalog_mode/install/install_generator.rb
209
+ - lib/solidus_catalog_mode.rb
210
+ - lib/solidus_catalog_mode/engine.rb
211
+ - lib/solidus_catalog_mode/factories.rb
212
+ - lib/solidus_catalog_mode/version.rb
213
+ homepage:
214
+ licenses:
215
+ - BSD-3-Clause
216
+ metadata: {}
217
+ post_install_message:
218
+ rdoc_options: []
219
+ require_paths:
220
+ - lib
221
+ required_ruby_version: !ruby/object:Gem::Requirement
222
+ requirements:
223
+ - - ">="
224
+ - !ruby/object:Gem::Version
225
+ version: '0'
226
+ required_rubygems_version: !ruby/object:Gem::Requirement
227
+ requirements:
228
+ - - ">="
229
+ - !ruby/object:Gem::Version
230
+ version: '0'
231
+ requirements: []
232
+ rubyforge_project:
233
+ rubygems_version: 2.6.8
234
+ signing_key:
235
+ specification_version: 4
236
+ summary: Allow to set products to not for online sale
237
+ test_files: []