spree_category_bullets 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +10 -0
- data/.rspec +1 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +213 -0
- data/LICENSE +26 -0
- data/README.md +46 -0
- data/Rakefile +29 -0
- data/Versionfile +11 -0
- data/app/assets/javascripts/admin/spree_category_bullets.js +1 -0
- data/app/assets/javascripts/store/spree_category_bullets.js +1 -0
- data/app/assets/stylesheets/admin/spree_category_bullets.css +3 -0
- data/app/assets/stylesheets/store/spree_category_bullets.css +3 -0
- data/app/controllers/spree/admin/bullets_controller.rb +53 -0
- data/app/models/spree/bullet.rb +14 -0
- data/app/models/spree/taxon_decorator.rb +4 -0
- data/app/overrides/add_bullets_to_taxons_configurations_menu.rb +12 -0
- data/app/views/spree/admin/bullets/_form.html.erb +24 -0
- data/app/views/spree/admin/bullets/edit.html.erb +10 -0
- data/app/views/spree/admin/bullets/index.html.erb +41 -0
- data/app/views/spree/admin/bullets/new.html.erb +9 -0
- data/app/views/spree/admin/taxons/_to_bullets_index.html.erb +1 -0
- data/app/views/spree/products/_bullets.html.erb +15 -0
- data/app/views/spree/products/_custom_bullets.html.erb +17 -0
- data/config/locales/en.yml +11 -0
- data/config/routes.rb +18 -0
- data/db/migrate/20120424085004_create_category_bullets.rb +21 -0
- data/lib/generators/spree_category_bullets/install/install_generator.rb +29 -0
- data/lib/spree_category_bullets/engine.rb +20 -0
- data/lib/spree_category_bullets.rb +2 -0
- data/script/rails +5 -0
- data/spec/spec_helper.rb +32 -0
- data/spree_category_bullets.gemspec +24 -0
- data/vendor/assets/images/admin/icons/16x16/2.png +0 -0
- data/vendor/assets/images/admin/icons/16x16/4.png +0 -0
- metadata +162 -0
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,213 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
spree-category-bullets (1.0.0)
|
5
|
+
spree_core (~> 1.1.0.rc2)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actionmailer (3.2.3)
|
11
|
+
actionpack (= 3.2.3)
|
12
|
+
mail (~> 2.4.4)
|
13
|
+
actionpack (3.2.3)
|
14
|
+
activemodel (= 3.2.3)
|
15
|
+
activesupport (= 3.2.3)
|
16
|
+
builder (~> 3.0.0)
|
17
|
+
erubis (~> 2.7.0)
|
18
|
+
journey (~> 1.0.1)
|
19
|
+
rack (~> 1.4.0)
|
20
|
+
rack-cache (~> 1.2)
|
21
|
+
rack-test (~> 0.6.1)
|
22
|
+
sprockets (~> 2.1.2)
|
23
|
+
active_utils (1.0.3)
|
24
|
+
activesupport (>= 2.3.11)
|
25
|
+
i18n
|
26
|
+
activemerchant (1.20.4)
|
27
|
+
active_utils (>= 1.0.2)
|
28
|
+
activesupport (>= 2.3.11)
|
29
|
+
braintree (>= 2.0.0)
|
30
|
+
builder (>= 2.0.0)
|
31
|
+
i18n
|
32
|
+
json (>= 1.5.1)
|
33
|
+
money (<= 3.7.1)
|
34
|
+
activemodel (3.2.3)
|
35
|
+
activesupport (= 3.2.3)
|
36
|
+
builder (~> 3.0.0)
|
37
|
+
activerecord (3.2.3)
|
38
|
+
activemodel (= 3.2.3)
|
39
|
+
activesupport (= 3.2.3)
|
40
|
+
arel (~> 3.0.2)
|
41
|
+
tzinfo (~> 0.3.29)
|
42
|
+
activeresource (3.2.3)
|
43
|
+
activemodel (= 3.2.3)
|
44
|
+
activesupport (= 3.2.3)
|
45
|
+
activesupport (3.2.3)
|
46
|
+
i18n (~> 0.6)
|
47
|
+
multi_json (~> 1.0)
|
48
|
+
acts_as_list (0.1.4)
|
49
|
+
addressable (2.2.7)
|
50
|
+
arel (3.0.2)
|
51
|
+
aws-sdk (1.3.9)
|
52
|
+
httparty (~> 0.7)
|
53
|
+
json (~> 1.4)
|
54
|
+
nokogiri (>= 1.4.4)
|
55
|
+
uuidtools (~> 2.1)
|
56
|
+
braintree (2.16.0)
|
57
|
+
builder (>= 2.0.0)
|
58
|
+
builder (3.0.0)
|
59
|
+
capybara (1.0.1)
|
60
|
+
mime-types (>= 1.16)
|
61
|
+
nokogiri (>= 1.3.3)
|
62
|
+
rack (>= 1.0.0)
|
63
|
+
rack-test (>= 0.5.4)
|
64
|
+
selenium-webdriver (~> 2.0)
|
65
|
+
xpath (~> 0.1.4)
|
66
|
+
childprocess (0.3.2)
|
67
|
+
ffi (~> 1.0.6)
|
68
|
+
cocaine (0.2.1)
|
69
|
+
columnize (0.3.6)
|
70
|
+
deface (0.8.0)
|
71
|
+
nokogiri (~> 1.5.0)
|
72
|
+
rails (>= 3.0.9)
|
73
|
+
diff-lcs (1.1.3)
|
74
|
+
erubis (2.7.0)
|
75
|
+
ffaker (1.12.1)
|
76
|
+
ffi (1.0.11)
|
77
|
+
highline (1.6.11)
|
78
|
+
hike (1.2.1)
|
79
|
+
httparty (0.8.3)
|
80
|
+
multi_json (~> 1.0)
|
81
|
+
multi_xml
|
82
|
+
i18n (0.6.0)
|
83
|
+
journey (1.0.3)
|
84
|
+
jquery-rails (2.0.2)
|
85
|
+
railties (>= 3.2.0, < 5.0)
|
86
|
+
thor (~> 0.14)
|
87
|
+
json (1.6.6)
|
88
|
+
kaminari (0.13.0)
|
89
|
+
actionpack (>= 3.0.0)
|
90
|
+
activesupport (>= 3.0.0)
|
91
|
+
railties (>= 3.0.0)
|
92
|
+
libwebsocket (0.1.3)
|
93
|
+
addressable
|
94
|
+
linecache (0.46)
|
95
|
+
rbx-require-relative (> 0.0.4)
|
96
|
+
mail (2.4.4)
|
97
|
+
i18n (>= 0.4.0)
|
98
|
+
mime-types (~> 1.16)
|
99
|
+
treetop (~> 1.4.8)
|
100
|
+
mime-types (1.18)
|
101
|
+
money (3.7.1)
|
102
|
+
i18n (~> 0.4)
|
103
|
+
multi_json (1.3.2)
|
104
|
+
multi_xml (0.4.4)
|
105
|
+
nested_set (1.7.0)
|
106
|
+
activerecord (>= 3.0.0)
|
107
|
+
railties (>= 3.0.0)
|
108
|
+
nokogiri (1.5.2)
|
109
|
+
paperclip (2.7.0)
|
110
|
+
activerecord (>= 2.3.0)
|
111
|
+
activesupport (>= 2.3.2)
|
112
|
+
cocaine (>= 0.0.2)
|
113
|
+
mime-types
|
114
|
+
polyamorous (0.5.0)
|
115
|
+
activerecord (~> 3.0)
|
116
|
+
polyglot (0.3.3)
|
117
|
+
rack (1.4.1)
|
118
|
+
rack-cache (1.2)
|
119
|
+
rack (>= 0.4)
|
120
|
+
rack-ssl (1.3.2)
|
121
|
+
rack
|
122
|
+
rack-test (0.6.1)
|
123
|
+
rack (>= 1.0)
|
124
|
+
rails (3.2.3)
|
125
|
+
actionmailer (= 3.2.3)
|
126
|
+
actionpack (= 3.2.3)
|
127
|
+
activerecord (= 3.2.3)
|
128
|
+
activeresource (= 3.2.3)
|
129
|
+
activesupport (= 3.2.3)
|
130
|
+
bundler (~> 1.0)
|
131
|
+
railties (= 3.2.3)
|
132
|
+
railties (3.2.3)
|
133
|
+
actionpack (= 3.2.3)
|
134
|
+
activesupport (= 3.2.3)
|
135
|
+
rack-ssl (~> 1.3.2)
|
136
|
+
rake (>= 0.8.7)
|
137
|
+
rdoc (~> 3.4)
|
138
|
+
thor (~> 0.14.6)
|
139
|
+
rake (0.9.2.2)
|
140
|
+
ransack (0.6.0)
|
141
|
+
actionpack (~> 3.0)
|
142
|
+
activerecord (~> 3.0)
|
143
|
+
polyamorous (~> 0.5.0)
|
144
|
+
rbx-require-relative (0.0.9)
|
145
|
+
rdoc (3.12)
|
146
|
+
json (~> 1.4)
|
147
|
+
rspec (2.9.0)
|
148
|
+
rspec-core (~> 2.9.0)
|
149
|
+
rspec-expectations (~> 2.9.0)
|
150
|
+
rspec-mocks (~> 2.9.0)
|
151
|
+
rspec-core (2.9.0)
|
152
|
+
rspec-expectations (2.9.1)
|
153
|
+
diff-lcs (~> 1.1.3)
|
154
|
+
rspec-mocks (2.9.0)
|
155
|
+
rspec-rails (2.9.0)
|
156
|
+
actionpack (>= 3.0)
|
157
|
+
activesupport (>= 3.0)
|
158
|
+
railties (>= 3.0)
|
159
|
+
rspec (~> 2.9.0)
|
160
|
+
ruby-debug (0.10.4)
|
161
|
+
columnize (>= 0.1)
|
162
|
+
ruby-debug-base (~> 0.10.4.0)
|
163
|
+
ruby-debug-base (0.10.4)
|
164
|
+
linecache (>= 0.3)
|
165
|
+
rubyzip (0.9.7)
|
166
|
+
selenium-webdriver (2.21.2)
|
167
|
+
childprocess (>= 0.2.5)
|
168
|
+
ffi (~> 1.0)
|
169
|
+
libwebsocket (~> 0.1.3)
|
170
|
+
multi_json (~> 1.0)
|
171
|
+
rubyzip
|
172
|
+
spree_core (1.1.0.rc2)
|
173
|
+
activemerchant (= 1.20.4)
|
174
|
+
acts_as_list (= 0.1.4)
|
175
|
+
aws-sdk (~> 1.3.4)
|
176
|
+
deface (>= 0.8.0)
|
177
|
+
ffaker (~> 1.12.0)
|
178
|
+
highline (= 1.6.11)
|
179
|
+
jquery-rails (~> 2.0.0)
|
180
|
+
kaminari (>= 0.13.0)
|
181
|
+
nested_set (= 1.7.0)
|
182
|
+
paperclip (~> 2.7)
|
183
|
+
rails (>= 3.2.2, <= 3.2.3)
|
184
|
+
ransack (~> 0.6.0)
|
185
|
+
state_machine (= 1.1.2)
|
186
|
+
stringex (~> 1.3.2)
|
187
|
+
sprockets (2.1.2)
|
188
|
+
hike (~> 1.2)
|
189
|
+
rack (~> 1.0)
|
190
|
+
tilt (~> 1.1, != 1.3.0)
|
191
|
+
sqlite3 (1.3.6)
|
192
|
+
state_machine (1.1.2)
|
193
|
+
stringex (1.3.3)
|
194
|
+
thor (0.14.6)
|
195
|
+
tilt (1.3.3)
|
196
|
+
treetop (1.4.10)
|
197
|
+
polyglot
|
198
|
+
polyglot (>= 0.3.1)
|
199
|
+
tzinfo (0.3.33)
|
200
|
+
uuidtools (2.1.2)
|
201
|
+
xpath (0.1.4)
|
202
|
+
nokogiri (~> 1.3)
|
203
|
+
|
204
|
+
PLATFORMS
|
205
|
+
ruby
|
206
|
+
|
207
|
+
DEPENDENCIES
|
208
|
+
capybara (= 1.0.1)
|
209
|
+
ffaker
|
210
|
+
rspec-rails
|
211
|
+
ruby-debug
|
212
|
+
spree-category-bullets!
|
213
|
+
sqlite3
|
data/LICENSE
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Copyright (c) 2012 [name of plugin creator]
|
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,46 @@
|
|
1
|
+
Spree Category Bullets
|
2
|
+
====================
|
3
|
+
|
4
|
+
With this extension you can attach bullets (text chunks) on the categories.
|
5
|
+
Then all the products in this category will have those bullets displayed in the single item view.
|
6
|
+
|
7
|
+
Every bullet will have sort order, active flag and description.
|
8
|
+
|
9
|
+
One special case is when you have close products in the same category which differs by some of the bullets.
|
10
|
+
Then you can use the image_code to group the simillar bullets in the category.
|
11
|
+
|
12
|
+
To make this work you have to add a property 'image_code' in the products.
|
13
|
+
|
14
|
+
Here is an example of the most complicated usage of the bullets
|
15
|
+
|
16
|
+
|
17
|
+
Important!!!
|
18
|
+
If one product belongs to multiple taxon's this extension uses the bullets attached to the first taxon.
|
19
|
+
The attributes from the parent taxons are not displayed!
|
20
|
+
|
21
|
+
|
22
|
+
Installation
|
23
|
+
------------
|
24
|
+
|
25
|
+
Add to `Gemfile`:
|
26
|
+
|
27
|
+
gem 'spree_category_bullets', :git => 'git://github.com/gudata/spree_category_bullets.git'
|
28
|
+
|
29
|
+
Run:
|
30
|
+
|
31
|
+
$ bundle
|
32
|
+
$ bundle exec rails g spree_category_bullets:install
|
33
|
+
|
34
|
+
|
35
|
+
Testing
|
36
|
+
-------
|
37
|
+
|
38
|
+
No need for tests right now.
|
39
|
+
|
40
|
+
Be sure to bundle your dependencies and then create a dummy test app for the specs to run against.
|
41
|
+
|
42
|
+
$ bundle
|
43
|
+
$ bundle exec rake test_app
|
44
|
+
$ bundle exec rspec spec
|
45
|
+
|
46
|
+
Copyright (c) 2012 Gudasoft, released under the New BSD License
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/packagetask'
|
4
|
+
require 'rubygems/package_task'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
require 'spree/core/testing_support/common_rake'
|
7
|
+
|
8
|
+
RSpec::Core::RakeTask.new
|
9
|
+
|
10
|
+
task :default => [:spec]
|
11
|
+
|
12
|
+
spec = eval(File.read('spree_category_bullets.gemspec'))
|
13
|
+
|
14
|
+
Gem::PackageTask.new(spec) do |p|
|
15
|
+
p.gem_spec = spec
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Release to gemcutter"
|
19
|
+
task :release => :package do
|
20
|
+
require 'rake/gemcutter'
|
21
|
+
Rake::Gemcutter::Tasks.new(spec).define
|
22
|
+
Rake::Task['gem:push'].invoke
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Generates a dummy app for testing"
|
26
|
+
task :test_app do
|
27
|
+
ENV['LIB_NAME'] = 'spree_category_bullets'
|
28
|
+
Rake::Task['common:test_app'].invoke
|
29
|
+
end
|
data/Versionfile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# This file is used to designate compatibilty with different versions of Spree
|
2
|
+
# Please see http://spreecommerce.com/documentation/extensions.html#versionfile for details
|
3
|
+
|
4
|
+
|
5
|
+
# Examples
|
6
|
+
#
|
7
|
+
# "0.70.x" => { :branch => "master"}
|
8
|
+
# "0.60.x" => { :branch => "0-60-stable" }
|
9
|
+
# "0.0.1" => { :tag => "v1.0.0", :version => "1.0.0" }
|
10
|
+
|
11
|
+
"0.0.1" => { :branch => "1-1-stable"}
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require admin/spree_core
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require store/spree_core
|
@@ -0,0 +1,53 @@
|
|
1
|
+
class Spree::Admin::BulletsController < Spree::Admin::BaseController
|
2
|
+
respond_to :html
|
3
|
+
|
4
|
+
before_filter :load_parent
|
5
|
+
|
6
|
+
def index
|
7
|
+
@bullets = Spree::Bullet.sorted_by_image_code.where(:taxon_id => @taxon.id)
|
8
|
+
respond_with(:admin, @taxonomy, @taxon)
|
9
|
+
end
|
10
|
+
|
11
|
+
def new
|
12
|
+
@bullet = Spree::Bullet.new(:taxon_id => @taxon.id, :is_active => true)
|
13
|
+
end
|
14
|
+
|
15
|
+
def create
|
16
|
+
@bullet = Spree::Bullet.new(params[:bullet].merge(:taxon_id => @taxon.id))
|
17
|
+
|
18
|
+
if @bullet.save
|
19
|
+
flash[:notice] = t(:successfully_created_bullet)
|
20
|
+
redirect_to admin_taxonomy_taxon_bullets_url(@taxonomy, @taxon)
|
21
|
+
else
|
22
|
+
respond_with(@bullet)
|
23
|
+
flash[:error] = t(:error_creating)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
def update
|
29
|
+
if @bullet.update_attributes(params[:bullet])
|
30
|
+
flash.notice = t(:successfully_updated_bullet)
|
31
|
+
redirect_to admin_taxonomy_taxon_bullets_url(@taxonomy, @taxon)
|
32
|
+
else
|
33
|
+
respond_with(@bullet)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
def destroy
|
39
|
+
if @bullet.destroy
|
40
|
+
flash[:notice] = t(:successfully_removed_bullet)
|
41
|
+
else
|
42
|
+
flash[:error] = t(:error_deleting)
|
43
|
+
end
|
44
|
+
redirect_to admin_taxonomy_taxon_bullets_url(@taxonomy, @taxon)
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
def load_parent
|
49
|
+
@taxonomy = Spree::Taxonomy.find(params[:taxonomy_id])
|
50
|
+
@taxon = @taxonomy.taxons.find(params[:taxon_id])
|
51
|
+
@bullet = Spree::Bullet.find(params[:id]) if params[:id]
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class Spree::Bullet < ActiveRecord::Base
|
2
|
+
belongs_to :taxon
|
3
|
+
has_many :products
|
4
|
+
|
5
|
+
attr_accessible :taxon, :taxon_id, :image_code, :description, :line_number, :is_active
|
6
|
+
|
7
|
+
validates :description, :presence => true
|
8
|
+
|
9
|
+
scope :active, where(:is_active => true)
|
10
|
+
scope :sorted, order("line_number asc")
|
11
|
+
scope :sorted_by_image_code, order("image_code asc, line_number asc")
|
12
|
+
scope :image_code, lambda{|image_code| where(:image_code => image_code)}
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Deface::Override.new(:virtual_path => 'spree/admin/taxons/edit',
|
2
|
+
:name => 'add bullet editing to taxon edit screen',
|
3
|
+
:insert_before => "[data-hook='buttons']",
|
4
|
+
:partial => 'spree/admin/taxons/to_bullets_index')
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
Deface::Override.new(:virtual_path => 'spree/products/show',
|
9
|
+
:name => 'display_bullets',
|
10
|
+
:insert_before => "[data-hook='product_properties']",
|
11
|
+
:partial => 'spree/products/bullets' # spree/products/custom_bullets if you want the image_code restriction to be active
|
12
|
+
)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<%= f.field_container :description do %>
|
2
|
+
<%= f.label :description, t(:description) %><br />
|
3
|
+
<%= f.text_area :description, {:cols => 60, :rows => 4, :class => 'fullwidth'} %>
|
4
|
+
<% end %>
|
5
|
+
|
6
|
+
<%= f.field_container :image_code do %>
|
7
|
+
<%= f.label :image_code, t(:image_code) %><br />
|
8
|
+
<%= f.text_field :image_code %>
|
9
|
+
<p>
|
10
|
+
Hint: This could be a property of the product. This way you can 'tie' different bullets to the products based on the image code.
|
11
|
+
For example in a category all the products with the same image code will have the same bullets.
|
12
|
+
You have to create the image_code propery by your own. And use the right partial in the store (it is included in the extension)
|
13
|
+
</p>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<%= f.field_container :line_number do %>
|
17
|
+
<%= f.label :line_number, t(:line_number) %><br />
|
18
|
+
<%= f.text_field :line_number %>
|
19
|
+
<% end %>
|
20
|
+
|
21
|
+
<%= f.field_container :is_active do %>
|
22
|
+
<%= f.label :is_active, t(:active), :for=> 'bullet_is_active_1' %><%= f.radio_button(:is_active, "1") %>
|
23
|
+
<%= f.label :is_active, t(:not_active), :for=> 'bullet_is_active_0' %><%= f.radio_button(:is_active, "0") %>
|
24
|
+
<% end %>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<%= render :partial => 'spree/admin/shared/configuration_menu' %>
|
2
|
+
|
3
|
+
<h1>Editing Bullet</h1>
|
4
|
+
|
5
|
+
<%= render 'spree/shared/error_messages', :target => @bullet %>
|
6
|
+
|
7
|
+
<%= form_for [:admin, @taxonomy, @taxon, @bullet], :html => { :multipart => true } do |f| %>
|
8
|
+
<%= render :partial => 'form', :locals => { :f => f } %>
|
9
|
+
<p class="form-buttons" data-hook="buttons"><%= button t(:save) %></p>
|
10
|
+
<% end %>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<%= render :partial => 'spree/admin/shared/configuration_menu' %>
|
2
|
+
|
3
|
+
<div class="toolbar" data-hook="toolbar">
|
4
|
+
<ul class="actions">
|
5
|
+
<li>
|
6
|
+
<p><%= button_link_to t(:'new'), new_admin_taxonomy_taxon_bullet_url( @taxonomy, @taxon), :icon => 'add' %></p>
|
7
|
+
</li>
|
8
|
+
</ul>
|
9
|
+
<br class="clear" />
|
10
|
+
</div>
|
11
|
+
|
12
|
+
<h1>Bullets</h1>
|
13
|
+
<h2><%= @taxonomy.name %> / <%= @taxon.name %></h2>
|
14
|
+
|
15
|
+
<table class="index" id="listing_bullets" data-hook="table-bullets">
|
16
|
+
<thead>
|
17
|
+
<tr data-hook="admin_bullets_index_headers">
|
18
|
+
<th><%= t(:value) %></th>
|
19
|
+
<th><%= t(:image_code) %></th>
|
20
|
+
<th><%= t(:sort) %></th>
|
21
|
+
<th><%= t(:active) %></th>
|
22
|
+
<th data-hook="admin_bullets_index_header_actions"></th>
|
23
|
+
</tr>
|
24
|
+
</thead>
|
25
|
+
<tbody>
|
26
|
+
<% @bullets.each do |bullet|%>
|
27
|
+
<tr data-hook="admin_bullets_index_rows">
|
28
|
+
<td><%= link_to truncate(bullet.description, :length => 100), edit_admin_taxonomy_taxon_bullet_url(@taxonomy, @taxon, bullet), :class => 'edit' %></td>
|
29
|
+
<td><%= bullet.image_code %>
|
30
|
+
<td><%= bullet.line_number %>
|
31
|
+
<td><%= bullet.is_active == 1 ? image_tag('admin/icons/16x16/4.png') : image_tag('admin/icons/16x16/2.png') %>
|
32
|
+
<td data-hook="admin_bullets_index_row_actions">
|
33
|
+
<%= link_to t('edit'), edit_admin_taxonomy_taxon_bullet_url(@taxonomy, @taxon, bullet), :class => 'edit' %>
|
34
|
+
<%= link_to t('delete'), [:admin, @taxonomy, @taxon, bullet], :confirm => "Are you sure?", :method=>:delete %>
|
35
|
+
</td>
|
36
|
+
</tr>
|
37
|
+
<% end %>
|
38
|
+
</tbody>
|
39
|
+
</table>
|
40
|
+
|
41
|
+
<p><%= link_to t(:'Back'), edit_admin_taxonomy_url( @taxonomy ) %></p>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<%= render :partial => 'spree/admin/shared/configuration_menu' %>
|
2
|
+
|
3
|
+
<h1>New Bullet</h1>
|
4
|
+
<%= render 'spree/shared/error_messages', :target => @bullet %>
|
5
|
+
|
6
|
+
<%= form_for [:admin, @taxonomy, @taxon, @bullet], :html => { :multipart => true } do |f| %>
|
7
|
+
<%= render :partial => 'form', :locals => { :f => f } %>
|
8
|
+
<p class="form-buttons" data-hook="buttons"><%= button t(:create) %></p>
|
9
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= link_to t(:attached_bullets), admin_taxonomy_taxon_bullets_path(@taxonomy, @taxon) %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%
|
2
|
+
show_bullets_for_taxon = @product.taxons.first
|
3
|
+
|
4
|
+
bullets = show_bullets_for_taxon.bullets.active.sorted
|
5
|
+
|
6
|
+
unless !(@product or bullets.empty?) %>
|
7
|
+
<section id="bullets">
|
8
|
+
<ul>
|
9
|
+
<%
|
10
|
+
bullets.each do |bullet| %>
|
11
|
+
<%= content_tag :li, bullet.description %>
|
12
|
+
<% end %>
|
13
|
+
</ul>
|
14
|
+
</section>
|
15
|
+
<% end %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<%
|
2
|
+
show_bullets_for_taxon = @product.taxons.first
|
3
|
+
|
4
|
+
image_code_property_id = @product.product_properties.where(:property_id => Gator::Application::PRODUCT_PROPERTIES[:image_code] ).first.value
|
5
|
+
|
6
|
+
bullets = show_bullets_for_taxon.bullets.image_code(image_code_property_id).active.sorted
|
7
|
+
|
8
|
+
unless !(@product or bullets.empty?) %>
|
9
|
+
<section id="bullets">
|
10
|
+
<ul>
|
11
|
+
<%
|
12
|
+
bullets.each do |bullet| %>
|
13
|
+
<%= content_tag :li, bullet.description %>
|
14
|
+
<% end %>
|
15
|
+
</ul>
|
16
|
+
</section>
|
17
|
+
<% end %>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Sample localization file for English. Add more files in this directory for other locales.
|
2
|
+
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
|
3
|
+
|
4
|
+
en:
|
5
|
+
error_creating: Error creating
|
6
|
+
successfully_created_bullet: Successfully Created Bullet
|
7
|
+
successfully_removed_bullet: Successfully Removed
|
8
|
+
successfully_updated_bullet: Successfully Updated
|
9
|
+
active: Active
|
10
|
+
not_active: Not Active
|
11
|
+
save: Save
|
data/config/routes.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Spree::Core::Engine.routes.draw do
|
2
|
+
namespace :admin do
|
3
|
+
resources :taxonomies do
|
4
|
+
resources :taxons do
|
5
|
+
resources :bullets
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
# admin_taxon_bullets GET /admin/taxons/:taxon_id/bullets(.:format) spree/admin/bullets#index
|
12
|
+
# POST /admin/taxons/:taxon_id/bullets(.:format) spree/admin/bullets#create
|
13
|
+
# new_admin_taxon_bullet GET /admin/taxons/:taxon_id/bullets/new(.:format) spree/admin/bullets#new
|
14
|
+
# edit_admin_taxon_bullet GET /admin/taxons/:taxon_id/bullets/:id/edit(.:format) spree/admin/bullets#edit
|
15
|
+
# admin_taxon_bullet GET /admin/taxons/:taxon_id/bullets/:id(.:format) spree/admin/bullets#show
|
16
|
+
# PUT /admin/taxons/:taxon_id/bullets/:id(.:format) spree/admin/bullets#update
|
17
|
+
# DELETE /admin/taxons/:taxon_id/bullets/:id(.:format) spree/admin/bullets#destroy
|
18
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# This migration comes from spree_category_bullets (originally 20120424085004)
|
2
|
+
class CreateCategoryBullets < ActiveRecord::Migration
|
3
|
+
def self.up
|
4
|
+
create_table :spree_bullets do |t|
|
5
|
+
t.references :taxon
|
6
|
+
t.integer :image_code
|
7
|
+
t.text :description
|
8
|
+
t.integer :line_number
|
9
|
+
t.integer :is_active
|
10
|
+
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
|
14
|
+
add_index :spree_bullets_taxons, [:taxon_id], :name => 'index_bullets_taxon'
|
15
|
+
add_index :spree_bullets_taxons, [:taxon_id, :image_code], :name => 'index_bullets_taxon_image_code'
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.down
|
19
|
+
drop_table :spree_bullets
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module SpreeCategoryBullets
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
|
5
|
+
def add_javascripts
|
6
|
+
append_file "app/assets/javascripts/store/all.js", "\n//= require store/spree_category_bullets\n"
|
7
|
+
append_file "app/assets/javascripts/admin/all.js", "\n//= require admin/spree_category_bullets\n"
|
8
|
+
end
|
9
|
+
|
10
|
+
def add_stylesheets
|
11
|
+
inject_into_file "app/assets/stylesheets/store/all.css", "\n *= require store/spree_category_bullets\n", :before => /\*\//, :verbose => true
|
12
|
+
inject_into_file "app/assets/stylesheets/admin/all.css", "\n *= require admin/spree_category_bullets\n", :before => /\*\//, :verbose => true
|
13
|
+
end
|
14
|
+
|
15
|
+
def add_migrations
|
16
|
+
run 'bundle exec rake railties:install:migrations FROM=spree_category_bullets'
|
17
|
+
end
|
18
|
+
|
19
|
+
def run_migrations
|
20
|
+
res = ask "Would you like to run the migrations now? [Y/n]"
|
21
|
+
if res == "" || res.downcase == "y"
|
22
|
+
run 'bundle exec rake db:migrate'
|
23
|
+
else
|
24
|
+
puts "Skiping rake db:migrate, don't forget to run it!"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module SpreeCategoryBullets
|
2
|
+
class Engine < Rails::Engine
|
3
|
+
engine_name 'spree_category_bullets'
|
4
|
+
|
5
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
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
|
data/script/rails
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
2
|
+
|
3
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
4
|
+
require File.expand_path('../../config/boot', __FILE__)
|
5
|
+
require 'rails/commands'
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
+
|
6
|
+
require 'rspec/rails'
|
7
|
+
|
8
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
9
|
+
# in spec/support/ and its subdirectories.
|
10
|
+
Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each {|f| require f }
|
11
|
+
|
12
|
+
# Requires factories defined in spree_core
|
13
|
+
require 'spree/core/testing_support/factories'
|
14
|
+
|
15
|
+
RSpec.configure do |config|
|
16
|
+
# == Mock Framework
|
17
|
+
#
|
18
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
19
|
+
#
|
20
|
+
# config.mock_with :mocha
|
21
|
+
# config.mock_with :flexmock
|
22
|
+
# config.mock_with :rr
|
23
|
+
config.mock_with :rspec
|
24
|
+
|
25
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
26
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
27
|
+
|
28
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
29
|
+
# examples within a transaction, remove the following line or assign false
|
30
|
+
# instead of true.
|
31
|
+
config.use_transactional_fixtures = true
|
32
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
Gem::Specification.new do |s|
|
3
|
+
s.platform = Gem::Platform::RUBY
|
4
|
+
s.name = 'spree_category_bullets'
|
5
|
+
s.version = '0.0.1'
|
6
|
+
s.summary = 'Add sorted bullets/properties on categories.'
|
7
|
+
s.description = 'Each category can have orederd list of properties. Those properties are displayed on all the products'
|
8
|
+
s.required_ruby_version = '>= 1.8.7'
|
9
|
+
|
10
|
+
s.author = 'Gudata'
|
11
|
+
s.email = 'i.bardarov@gmail.com'
|
12
|
+
s.homepage = 'http://www.gudasoft.com'
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.require_path = 'lib'
|
17
|
+
s.requirements << 'none'
|
18
|
+
|
19
|
+
s.add_dependency 'spree_core', '~> 1.1.0.rc2'
|
20
|
+
|
21
|
+
s.add_development_dependency 'capybara', '1.0.1'
|
22
|
+
s.add_development_dependency 'rspec-rails', '~> 2.7'
|
23
|
+
s.add_development_dependency 'sqlite3'
|
24
|
+
end
|
Binary file
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,162 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spree_category_bullets
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Gudata
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-04-27 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: spree_core
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 15424033
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 1
|
32
|
+
- 0
|
33
|
+
- rc
|
34
|
+
- 2
|
35
|
+
version: 1.1.0.rc2
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id001
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: capybara
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - "="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
hash: 21
|
47
|
+
segments:
|
48
|
+
- 1
|
49
|
+
- 0
|
50
|
+
- 1
|
51
|
+
version: 1.0.1
|
52
|
+
type: :development
|
53
|
+
version_requirements: *id002
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: rspec-rails
|
56
|
+
prerelease: false
|
57
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
hash: 13
|
63
|
+
segments:
|
64
|
+
- 2
|
65
|
+
- 7
|
66
|
+
version: "2.7"
|
67
|
+
type: :development
|
68
|
+
version_requirements: *id003
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sqlite3
|
71
|
+
prerelease: false
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
hash: 3
|
78
|
+
segments:
|
79
|
+
- 0
|
80
|
+
version: "0"
|
81
|
+
type: :development
|
82
|
+
version_requirements: *id004
|
83
|
+
description: Each category can have orederd list of properties. Those properties are displayed on all the products
|
84
|
+
email: i.bardarov@gmail.com
|
85
|
+
executables: []
|
86
|
+
|
87
|
+
extensions: []
|
88
|
+
|
89
|
+
extra_rdoc_files: []
|
90
|
+
|
91
|
+
files:
|
92
|
+
- .gitignore
|
93
|
+
- .rspec
|
94
|
+
- Gemfile
|
95
|
+
- Gemfile.lock
|
96
|
+
- LICENSE
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- Versionfile
|
100
|
+
- app/assets/javascripts/admin/spree_category_bullets.js
|
101
|
+
- app/assets/javascripts/store/spree_category_bullets.js
|
102
|
+
- app/assets/stylesheets/admin/spree_category_bullets.css
|
103
|
+
- app/assets/stylesheets/store/spree_category_bullets.css
|
104
|
+
- app/controllers/spree/admin/bullets_controller.rb
|
105
|
+
- app/models/spree/bullet.rb
|
106
|
+
- app/models/spree/taxon_decorator.rb
|
107
|
+
- app/overrides/add_bullets_to_taxons_configurations_menu.rb
|
108
|
+
- app/views/spree/admin/bullets/_form.html.erb
|
109
|
+
- app/views/spree/admin/bullets/edit.html.erb
|
110
|
+
- app/views/spree/admin/bullets/index.html.erb
|
111
|
+
- app/views/spree/admin/bullets/new.html.erb
|
112
|
+
- app/views/spree/admin/taxons/_to_bullets_index.html.erb
|
113
|
+
- app/views/spree/products/_bullets.html.erb
|
114
|
+
- app/views/spree/products/_custom_bullets.html.erb
|
115
|
+
- config/locales/en.yml
|
116
|
+
- config/routes.rb
|
117
|
+
- db/migrate/20120424085004_create_category_bullets.rb
|
118
|
+
- lib/generators/spree_category_bullets/install/install_generator.rb
|
119
|
+
- lib/spree_category_bullets.rb
|
120
|
+
- lib/spree_category_bullets/engine.rb
|
121
|
+
- script/rails
|
122
|
+
- spec/spec_helper.rb
|
123
|
+
- spree_category_bullets.gemspec
|
124
|
+
- vendor/assets/images/admin/icons/16x16/2.png
|
125
|
+
- vendor/assets/images/admin/icons/16x16/4.png
|
126
|
+
homepage: http://www.gudasoft.com
|
127
|
+
licenses: []
|
128
|
+
|
129
|
+
post_install_message:
|
130
|
+
rdoc_options: []
|
131
|
+
|
132
|
+
require_paths:
|
133
|
+
- lib
|
134
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
135
|
+
none: false
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
hash: 57
|
140
|
+
segments:
|
141
|
+
- 1
|
142
|
+
- 8
|
143
|
+
- 7
|
144
|
+
version: 1.8.7
|
145
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
+
none: false
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
hash: 3
|
151
|
+
segments:
|
152
|
+
- 0
|
153
|
+
version: "0"
|
154
|
+
requirements:
|
155
|
+
- none
|
156
|
+
rubyforge_project:
|
157
|
+
rubygems_version: 1.8.23
|
158
|
+
signing_key:
|
159
|
+
specification_version: 3
|
160
|
+
summary: Add sorted bullets/properties on categories.
|
161
|
+
test_files: []
|
162
|
+
|