spree_essentials 0.1.4 → 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.
- data/LICENSE +21 -17
- data/README.md +11 -4
- data/lib/spree_essentials/version.rb +1 -1
- data/lib/spree_essentials.rb +0 -1
- metadata +22 -63
- data/CHANGELOG.md +0 -64
- data/app/controllers/admin/resource_controller.rb +0 -230
- data/lib/dummy_hooks/after_migrate.rb +0 -1
- data/lib/dummy_hooks/after_migrate.rb.sample +0 -1
- data/lib/dummy_hooks/before_migrate.rb +0 -11
- data/lib/dummy_hooks/templates/test.pdf +0 -0
- data/lib/dummy_hooks/templates/test.zip +0 -0
- data/lib/spree_core/action_callbacks.rb +0 -26
data/LICENSE
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
Copyright (c) 2011 Spencer Steffen and Citrus Media Group.
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
|
2
5
|
are permitted provided that the following conditions are met:
|
|
3
6
|
|
|
4
|
-
* Redistributions of source code must retain the above copyright notice,
|
|
7
|
+
* Redistributions of source code must retain the above copyright notice,
|
|
5
8
|
this list of conditions and the following disclaimer.
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
|
|
10
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
|
8
12
|
and/or other materials provided with the distribution.
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
|
|
14
|
+
* Neither the name of Citrus Media Group nor the names of its
|
|
15
|
+
contributors may be used to endorse or promote products derived from this
|
|
11
16
|
software without specific prior written permission.
|
|
12
17
|
|
|
13
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
19
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
20
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
21
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
22
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
23
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
24
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
25
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
26
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
27
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
CHANGED
|
@@ -25,15 +25,14 @@ Installation
|
|
|
25
25
|
|
|
26
26
|
If you don't already have an existing Spree site, [click here](https://gist.github.com/946719) then come back later... You can also read the Spree docs [here](http://spreecommerce.com/documentation/getting_started.html)...
|
|
27
27
|
|
|
28
|
-
Spree Essentials
|
|
28
|
+
Spree Essentials can be installed by itself by adding the following to your Gemfile:
|
|
29
29
|
|
|
30
|
-
gem 'spree_essentials',
|
|
30
|
+
gem 'spree_essentials', '0.2.0'
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
This isn't necessary if you're using spree_essentials based extensions. If that's the case, just include the extensions normally:
|
|
33
33
|
|
|
34
34
|
gem 'spree_essential_cms', :git => 'git://github.com/citrus/spree_essential_cms.git'
|
|
35
35
|
gem 'spree_essential_blog', :git => 'git://github.com/citrus/spree_essential_blog.git'
|
|
36
|
-
|
|
37
36
|
|
|
38
37
|
|
|
39
38
|
Then run:
|
|
@@ -161,6 +160,14 @@ To Do
|
|
|
161
160
|
Change Log
|
|
162
161
|
----------
|
|
163
162
|
|
|
163
|
+
**0.2.0 - 2011/7/14**
|
|
164
|
+
|
|
165
|
+
* Depend on Spree 0.60.x and above
|
|
166
|
+
* Remove spree_auth dependency
|
|
167
|
+
* Removed `app/controllers/admin/resource_controller.rb` in favor of the Spree Default one
|
|
168
|
+
* Updated development gems to most recent versions
|
|
169
|
+
|
|
170
|
+
|
|
164
171
|
**0.1.4 - 2011/6/10**
|
|
165
172
|
|
|
166
173
|
* Removed console.log from jquery.autodate.js
|
data/lib/spree_essentials.rb
CHANGED
metadata
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: spree_essentials
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease:
|
|
5
|
-
version: 0.
|
|
5
|
+
version: 0.2.0
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- Spencer Steffen
|
|
@@ -10,7 +10,7 @@ autorequire:
|
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
12
|
|
|
13
|
-
date: 2011-
|
|
13
|
+
date: 2011-07-14 00:00:00 -07:00
|
|
14
14
|
default_executable:
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
@@ -20,123 +20,90 @@ dependencies:
|
|
|
20
20
|
requirements:
|
|
21
21
|
- - ">="
|
|
22
22
|
- !ruby/object:Gem::Version
|
|
23
|
-
version: 0.
|
|
23
|
+
version: 0.60.0
|
|
24
24
|
type: :runtime
|
|
25
25
|
prerelease: false
|
|
26
26
|
version_requirements: *id001
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
28
|
+
name: rdiscount
|
|
29
29
|
requirement: &id002 !ruby/object:Gem::Requirement
|
|
30
30
|
none: false
|
|
31
31
|
requirements:
|
|
32
32
|
- - ">="
|
|
33
33
|
- !ruby/object:Gem::Version
|
|
34
|
-
version: 1.
|
|
34
|
+
version: 1.6.8
|
|
35
35
|
type: :runtime
|
|
36
36
|
prerelease: false
|
|
37
37
|
version_requirements: *id002
|
|
38
38
|
- !ruby/object:Gem::Dependency
|
|
39
|
-
name:
|
|
39
|
+
name: shoulda
|
|
40
40
|
requirement: &id003 !ruby/object:Gem::Requirement
|
|
41
41
|
none: false
|
|
42
42
|
requirements:
|
|
43
43
|
- - ">="
|
|
44
44
|
- !ruby/object:Gem::Version
|
|
45
|
-
version:
|
|
46
|
-
type: :
|
|
45
|
+
version: 2.11.3
|
|
46
|
+
type: :development
|
|
47
47
|
prerelease: false
|
|
48
48
|
version_requirements: *id003
|
|
49
49
|
- !ruby/object:Gem::Dependency
|
|
50
|
-
name:
|
|
50
|
+
name: dummier
|
|
51
51
|
requirement: &id004 !ruby/object:Gem::Requirement
|
|
52
52
|
none: false
|
|
53
53
|
requirements:
|
|
54
54
|
- - ">="
|
|
55
55
|
- !ruby/object:Gem::Version
|
|
56
|
-
version: 2.
|
|
56
|
+
version: 0.2.0
|
|
57
57
|
type: :development
|
|
58
58
|
prerelease: false
|
|
59
59
|
version_requirements: *id004
|
|
60
60
|
- !ruby/object:Gem::Dependency
|
|
61
|
-
name:
|
|
61
|
+
name: factory_girl
|
|
62
62
|
requirement: &id005 !ruby/object:Gem::Requirement
|
|
63
63
|
none: false
|
|
64
64
|
requirements:
|
|
65
65
|
- - ">="
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: 0.
|
|
67
|
+
version: 2.0.0.beta4
|
|
68
68
|
type: :development
|
|
69
69
|
prerelease: false
|
|
70
70
|
version_requirements: *id005
|
|
71
71
|
- !ruby/object:Gem::Dependency
|
|
72
|
-
name:
|
|
72
|
+
name: capybara
|
|
73
73
|
requirement: &id006 !ruby/object:Gem::Requirement
|
|
74
74
|
none: false
|
|
75
75
|
requirements:
|
|
76
76
|
- - ">="
|
|
77
77
|
- !ruby/object:Gem::Version
|
|
78
|
-
version:
|
|
78
|
+
version: 1.0.0
|
|
79
79
|
type: :development
|
|
80
80
|
prerelease: false
|
|
81
81
|
version_requirements: *id006
|
|
82
82
|
- !ruby/object:Gem::Dependency
|
|
83
|
-
name:
|
|
83
|
+
name: sqlite3
|
|
84
84
|
requirement: &id007 !ruby/object:Gem::Requirement
|
|
85
85
|
none: false
|
|
86
86
|
requirements:
|
|
87
87
|
- - ">="
|
|
88
88
|
- !ruby/object:Gem::Version
|
|
89
|
-
version:
|
|
89
|
+
version: 1.3.3
|
|
90
90
|
type: :development
|
|
91
91
|
prerelease: false
|
|
92
92
|
version_requirements: *id007
|
|
93
93
|
- !ruby/object:Gem::Dependency
|
|
94
|
-
name:
|
|
94
|
+
name: spork
|
|
95
95
|
requirement: &id008 !ruby/object:Gem::Requirement
|
|
96
96
|
none: false
|
|
97
97
|
requirements:
|
|
98
98
|
- - ">="
|
|
99
99
|
- !ruby/object:Gem::Version
|
|
100
|
-
version: 0.
|
|
100
|
+
version: 0.9.0.rc9
|
|
101
101
|
type: :development
|
|
102
102
|
prerelease: false
|
|
103
103
|
version_requirements: *id008
|
|
104
|
-
- !ruby/object:Gem::Dependency
|
|
105
|
-
name: selenium-webdriver
|
|
106
|
-
requirement: &id009 !ruby/object:Gem::Requirement
|
|
107
|
-
none: false
|
|
108
|
-
requirements:
|
|
109
|
-
- - ">="
|
|
110
|
-
- !ruby/object:Gem::Version
|
|
111
|
-
version: 0.1.3
|
|
112
|
-
type: :development
|
|
113
|
-
prerelease: false
|
|
114
|
-
version_requirements: *id009
|
|
115
|
-
- !ruby/object:Gem::Dependency
|
|
116
|
-
name: sqlite3
|
|
117
|
-
requirement: &id010 !ruby/object:Gem::Requirement
|
|
118
|
-
none: false
|
|
119
|
-
requirements:
|
|
120
|
-
- - ">="
|
|
121
|
-
- !ruby/object:Gem::Version
|
|
122
|
-
version: 1.3.3
|
|
123
|
-
type: :development
|
|
124
|
-
prerelease: false
|
|
125
|
-
version_requirements: *id010
|
|
126
|
-
- !ruby/object:Gem::Dependency
|
|
127
|
-
name: spork
|
|
128
|
-
requirement: &id011 !ruby/object:Gem::Requirement
|
|
129
|
-
none: false
|
|
130
|
-
requirements:
|
|
131
|
-
- - ">="
|
|
132
|
-
- !ruby/object:Gem::Version
|
|
133
|
-
version: 0.9.0.rc8
|
|
134
|
-
type: :development
|
|
135
|
-
prerelease: false
|
|
136
|
-
version_requirements: *id011
|
|
137
104
|
- !ruby/object:Gem::Dependency
|
|
138
105
|
name: spork-testunit
|
|
139
|
-
requirement: &
|
|
106
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
|
140
107
|
none: false
|
|
141
108
|
requirements:
|
|
142
109
|
- - ">="
|
|
@@ -144,7 +111,7 @@ dependencies:
|
|
|
144
111
|
version: 0.0.5
|
|
145
112
|
type: :development
|
|
146
113
|
prerelease: false
|
|
147
|
-
version_requirements: *
|
|
114
|
+
version_requirements: *id009
|
|
148
115
|
description: Spree Essentials provides a base for several other Spree Commerce extensions. The idea is to provide other extensions with common functionality such as an asset-upload interface, a markdown editor, and a common admin-navigation tab.
|
|
149
116
|
email:
|
|
150
117
|
- spencer@citrusme.com
|
|
@@ -155,25 +122,17 @@ extensions: []
|
|
|
155
122
|
extra_rdoc_files: []
|
|
156
123
|
|
|
157
124
|
files:
|
|
158
|
-
- CHANGELOG.md
|
|
159
125
|
- README.md
|
|
160
126
|
- LICENSE
|
|
161
127
|
- config/locales/en.yml
|
|
162
128
|
- config/routes.rb
|
|
163
|
-
- lib/dummy_hooks/after_migrate.rb
|
|
164
|
-
- lib/dummy_hooks/after_migrate.rb.sample
|
|
165
|
-
- lib/dummy_hooks/before_migrate.rb
|
|
166
|
-
- lib/dummy_hooks/templates/test.pdf
|
|
167
|
-
- lib/dummy_hooks/templates/test.zip
|
|
168
129
|
- lib/generators/essentials_base.rb
|
|
169
130
|
- lib/generators/spree_essentials/install_generator.rb
|
|
170
131
|
- lib/generators/templates/db/migrate/add_attachment_file_size_to_assets.rb
|
|
171
|
-
- lib/spree_core/action_callbacks.rb
|
|
172
132
|
- lib/spree_essentials/test_helper.rb
|
|
173
133
|
- lib/spree_essentials/version.rb
|
|
174
134
|
- lib/spree_essentials.rb
|
|
175
135
|
- app/controllers/admin/markdown_controller.rb
|
|
176
|
-
- app/controllers/admin/resource_controller.rb
|
|
177
136
|
- app/controllers/admin/uploads_controller.rb
|
|
178
137
|
- app/helpers/admin/base_helper_decorator.rb
|
|
179
138
|
- app/models/image_decorator.rb
|
|
@@ -231,7 +190,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
231
190
|
requirements:
|
|
232
191
|
- - ">="
|
|
233
192
|
- !ruby/object:Gem::Version
|
|
234
|
-
hash:
|
|
193
|
+
hash: -1301760498595422613
|
|
235
194
|
segments:
|
|
236
195
|
- 0
|
|
237
196
|
version: "0"
|
|
@@ -240,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
240
199
|
requirements:
|
|
241
200
|
- - ">="
|
|
242
201
|
- !ruby/object:Gem::Version
|
|
243
|
-
hash:
|
|
202
|
+
hash: -1301760498595422613
|
|
244
203
|
segments:
|
|
245
204
|
- 0
|
|
246
205
|
version: "0"
|
data/CHANGELOG.md
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
Change Log
|
|
2
|
-
----------
|
|
3
|
-
|
|
4
|
-
**0.1.4 - 2011/6/10**
|
|
5
|
-
|
|
6
|
-
* Removed console.log from jquery.autodate.js
|
|
7
|
-
* Updated resource controller with better flash message handling
|
|
8
|
-
* Added faker.lorem.words to en.yml to prevent NoMethodError in integration tests
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
**0.1.3 - 2011/6/8**
|
|
12
|
-
|
|
13
|
-
* Added test in teardown to check for missing translations
|
|
14
|
-
* Removed some old bits of CMS code
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
**0.1.2 - 2011/6/7**
|
|
18
|
-
|
|
19
|
-
* Added missing translation
|
|
20
|
-
* Cleanup
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
**0.1.1 - 2011/6/7**
|
|
24
|
-
|
|
25
|
-
* Released 0.1.1
|
|
26
|
-
* Updated resource_controller.rb to Spree 0.60.0's and added `translated_object_name` method. ([pull request #419](https://github.com/spree/spree/pull/419) on Spree)
|
|
27
|
-
* Added upload integration test
|
|
28
|
-
* Cleaned up en.yml
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
**2011/6/6**
|
|
32
|
-
|
|
33
|
-
* Removed `spree_auth` requirement
|
|
34
|
-
* Added a few test helpers
|
|
35
|
-
* Updated readme
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
**0.1.0 2011/6/1**
|
|
39
|
-
|
|
40
|
-
* Added [dummier](https://github.com/citrus/dummier)
|
|
41
|
-
* Removed some remaining CMS bits
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
**2011/4/26**
|
|
45
|
-
|
|
46
|
-
* Modularized CMS. It can now be found [here](https://github.com/citrus/spree_essential_cms)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
**2011/4/12**
|
|
50
|
-
|
|
51
|
-
* Added content contexts for multiple contents per page
|
|
52
|
-
* Namespaced posts into blog/posts
|
|
53
|
-
* Added `<!-- more -->` tag to posts
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
**2011/4/4**
|
|
57
|
-
|
|
58
|
-
* Added Page Images and starting to remove resource_controller.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
**2011/4/3**
|
|
62
|
-
|
|
63
|
-
* Automatically adds [Heroku](http://heroku.com) support when you include [spree_heroku](https://github.com/paxer/spree-heroku) in your Gemfile. Check the [spree_heroku readme](https://github.com/paxer/spree-heroku#readme) for full installation instructions.
|
|
64
|
-
* Creates default content when you create a new page.
|
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
require 'spree_core/action_callbacks'
|
|
2
|
-
class Admin::ResourceController < Admin::BaseController
|
|
3
|
-
helper_method :new_object_url, :edit_object_url, :object_url, :collection_url
|
|
4
|
-
before_filter :load_resource
|
|
5
|
-
|
|
6
|
-
respond_to :html
|
|
7
|
-
respond_to :js, :except => [:show, :index]
|
|
8
|
-
|
|
9
|
-
def flash_message_for(object, event_sym)
|
|
10
|
-
resource_desc = object.class.model_name.human
|
|
11
|
-
resource_desc += " \"#{object.name}\"" if object.respond_to?(:name)
|
|
12
|
-
I18n.t(event_sym, :resource => resource_desc)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def new
|
|
16
|
-
respond_with(@object) do |format|
|
|
17
|
-
format.html { render :layout => !request.xhr? }
|
|
18
|
-
format.js { render :layout => false }
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def edit
|
|
23
|
-
respond_with(@object) do |format|
|
|
24
|
-
format.html { render :layout => !request.xhr? }
|
|
25
|
-
format.js { render :layout => false }
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def update
|
|
30
|
-
invoke_callbacks(:update, :before)
|
|
31
|
-
if @object.update_attributes(params[object_name])
|
|
32
|
-
invoke_callbacks(:update, :after)
|
|
33
|
-
flash[:notice] = flash_message_for(@object, :successfully_updated)
|
|
34
|
-
respond_with(@object) do |format|
|
|
35
|
-
format.html { redirect_to location_after_save }
|
|
36
|
-
format.js { render :layout => false }
|
|
37
|
-
end
|
|
38
|
-
else
|
|
39
|
-
invoke_callbacks(:update, :fails)
|
|
40
|
-
respond_with(@object)
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def create
|
|
45
|
-
invoke_callbacks(:create, :before)
|
|
46
|
-
if @object.save
|
|
47
|
-
invoke_callbacks(:create, :after)
|
|
48
|
-
flash[:notice] = flash_message_for(@object, :successfully_created)
|
|
49
|
-
respond_with(@object) do |format|
|
|
50
|
-
format.html { redirect_to location_after_save }
|
|
51
|
-
format.js { render :layout => false }
|
|
52
|
-
end
|
|
53
|
-
else
|
|
54
|
-
invoke_callbacks(:create, :fails)
|
|
55
|
-
respond_with(@object)
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def destroy
|
|
60
|
-
invoke_callbacks(:destroy, :before)
|
|
61
|
-
if @object.destroy
|
|
62
|
-
invoke_callbacks(:destroy, :after)
|
|
63
|
-
flash[:notice] = flash_message_for(@object, :successfully_removed)
|
|
64
|
-
respond_with(@object) do |format|
|
|
65
|
-
format.html { redirect_to collection_url }
|
|
66
|
-
format.js { render :partial => "/admin/shared/destroy" }
|
|
67
|
-
end
|
|
68
|
-
else
|
|
69
|
-
invoke_callbacks(:destroy, :fails)
|
|
70
|
-
respond_with(@object) do |format|
|
|
71
|
-
format.html { redirect_to collection_url }
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
protected
|
|
77
|
-
|
|
78
|
-
class << self
|
|
79
|
-
attr_accessor :parent_data
|
|
80
|
-
attr_accessor :callbacks
|
|
81
|
-
|
|
82
|
-
def belongs_to(model_name, options = {})
|
|
83
|
-
@parent_data ||= {}
|
|
84
|
-
@parent_data[:model_name] = model_name
|
|
85
|
-
@parent_data[:model_class] = model_name.to_s.classify.constantize
|
|
86
|
-
@parent_data[:find_by] = options[:find_by] || :id
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
def create
|
|
90
|
-
@callbacks ||= {}
|
|
91
|
-
@callbacks[:create] ||= Spree::ActionCallbacks.new
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def update
|
|
95
|
-
@callbacks ||= {}
|
|
96
|
-
@callbacks[:update] ||= Spree::ActionCallbacks.new
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
def destroy
|
|
100
|
-
@callbacks ||= {}
|
|
101
|
-
@callbacks[:destroy] ||= Spree::ActionCallbacks.new
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
def model_class
|
|
106
|
-
controller_name.classify.constantize
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def object_name
|
|
110
|
-
controller_name.singularize
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
def load_resource
|
|
114
|
-
if member_action?
|
|
115
|
-
@object ||= load_resource_instance
|
|
116
|
-
instance_variable_set("@#{object_name}", @object)
|
|
117
|
-
else
|
|
118
|
-
@collection ||= collection
|
|
119
|
-
instance_variable_set("@#{controller_name}", @collection)
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
def load_resource_instance
|
|
124
|
-
if new_actions.include?(params[:action].to_sym)
|
|
125
|
-
build_resource
|
|
126
|
-
elsif params[:id]
|
|
127
|
-
find_resource
|
|
128
|
-
end
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
def parent_data
|
|
132
|
-
self.class.parent_data
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
def parent
|
|
136
|
-
if parent_data.present?
|
|
137
|
-
@parent ||= parent_data[:model_class].where(parent_data[:find_by] => params["#{parent_data[:model_name]}_id"]).first
|
|
138
|
-
instance_variable_set("@#{parent_data[:model_name]}", @parent)
|
|
139
|
-
else
|
|
140
|
-
nil
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
def find_resource
|
|
145
|
-
if parent_data.present?
|
|
146
|
-
parent.send(controller_name).find(params[:id])
|
|
147
|
-
else
|
|
148
|
-
model_class.find(params[:id])
|
|
149
|
-
end
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
def build_resource
|
|
153
|
-
if parent_data.present?
|
|
154
|
-
parent.send(controller_name).build(params[object_name])
|
|
155
|
-
else
|
|
156
|
-
model_class.new(params[object_name])
|
|
157
|
-
end
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
def collection
|
|
161
|
-
return parent.send(controller_name) if parent_data.present?
|
|
162
|
-
|
|
163
|
-
if model_class.respond_to?(:accessible_by) && !current_ability.has_block?(params[:action], model_class)
|
|
164
|
-
model_class.accessible_by(current_ability)
|
|
165
|
-
else
|
|
166
|
-
model_class.scoped
|
|
167
|
-
end
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
def location_after_save
|
|
171
|
-
collection_url
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
def invoke_callbacks(action, callback_type)
|
|
175
|
-
callbacks = self.class.callbacks || {}
|
|
176
|
-
return if callbacks[action].nil?
|
|
177
|
-
case callback_type.to_sym
|
|
178
|
-
when :before then callbacks[action].before_methods.each {|method| send method }
|
|
179
|
-
when :after then callbacks[action].after_methods.each {|method| send method }
|
|
180
|
-
when :fails then callbacks[action].fails_methods.each {|method| send method }
|
|
181
|
-
end
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
# URL helpers
|
|
185
|
-
|
|
186
|
-
def new_object_url(options = {})
|
|
187
|
-
if parent_data.present?
|
|
188
|
-
new_polymorphic_url([:admin, parent, model_class], options)
|
|
189
|
-
else
|
|
190
|
-
new_polymorphic_url([:admin, model_class], options)
|
|
191
|
-
end
|
|
192
|
-
end
|
|
193
|
-
|
|
194
|
-
def edit_object_url(object, options = {})
|
|
195
|
-
if parent_data.present?
|
|
196
|
-
send "edit_admin_#{parent_data[:model_name]}_#{object_name}_url", parent, object, options
|
|
197
|
-
else
|
|
198
|
-
send "edit_admin_#{object_name}_url", object, options
|
|
199
|
-
end
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
def object_url(object = nil, options = {})
|
|
203
|
-
target = object ? object : @object
|
|
204
|
-
if parent_data.present?
|
|
205
|
-
send "admin_#{parent_data[:model_name]}_#{object_name}_url", parent, target, options
|
|
206
|
-
else
|
|
207
|
-
send "admin_#{object_name}_url", target, options
|
|
208
|
-
end
|
|
209
|
-
end
|
|
210
|
-
|
|
211
|
-
def collection_url(options = {})
|
|
212
|
-
if parent_data.present?
|
|
213
|
-
polymorphic_url([:admin, parent, model_class], options)
|
|
214
|
-
else
|
|
215
|
-
polymorphic_url([:admin, model_class], options)
|
|
216
|
-
end
|
|
217
|
-
end
|
|
218
|
-
|
|
219
|
-
def collection_actions
|
|
220
|
-
[:index]
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
def member_action?
|
|
224
|
-
!collection_actions.include? params[:action].to_sym
|
|
225
|
-
end
|
|
226
|
-
|
|
227
|
-
def new_actions
|
|
228
|
-
[:new, :create]
|
|
229
|
-
end
|
|
230
|
-
end
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
rake "db:migrate db:seed db:sample", :env => "development"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
rake "db:migrate db:seed db:sample", :env => "development"
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# install spree and migrate db
|
|
2
|
-
|
|
3
|
-
say_status "installing", "spree_core, spree_auth"
|
|
4
|
-
|
|
5
|
-
run "rake spree_core:install spree_auth:install"
|
|
6
|
-
|
|
7
|
-
say_status "installing", "spree_essentials"
|
|
8
|
-
run "rails g spree_essentials:install"
|
|
9
|
-
|
|
10
|
-
copy_file "test.pdf", "public/test.pdf"
|
|
11
|
-
copy_file "test.zip", "public/test.zip"
|
|
Binary file
|
|
Binary file
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
module Spree
|
|
2
|
-
class ActionCallbacks
|
|
3
|
-
attr_reader :before_methods
|
|
4
|
-
attr_reader :after_methods
|
|
5
|
-
attr_reader :fails_methods
|
|
6
|
-
|
|
7
|
-
def initialize
|
|
8
|
-
@before_methods = []
|
|
9
|
-
@after_methods = []
|
|
10
|
-
@fails_methods = []
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def before(method)
|
|
14
|
-
@before_methods << method
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def after(method)
|
|
18
|
-
@after_methods << method
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def fails(method)
|
|
22
|
-
@fails_methods << method
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
end
|