padrino-admin 0.10.6.c → 0.10.6.d

Sign up to get free protection for your applications and to get access to all the features.
@@ -59,6 +59,7 @@ module Padrino
59
59
  directory "templates/assets", destination_root("public", "admin")
60
60
  template "templates/app.rb.tt", destination_root("admin/app.rb")
61
61
  append_file destination_root("config/apps.rb"), "\nPadrino.mount(\"Admin\").to(\"/admin\")"
62
+ insert_middleware 'ActiveRecord::ConnectionAdapters::ConnectionManagement', 'admin' if [:mini_record, :activerecord].include?(orm)
62
63
 
63
64
  account_params = [
64
65
  options[:admin_model].underscore, "name:string", "surname:string", "email:string", "crypted_password:string", "role:string",
@@ -103,10 +104,13 @@ module Padrino
103
104
  template "templates/#{ext}/app/layouts/application.#{ext}.tt", destination_root("admin/views/layouts/application.#{ext}")
104
105
  template "templates/#{ext}/app/sessions/new.#{ext}.tt", destination_root("admin/views/sessions/new.#{ext}")
105
106
 
106
- add_project_module :accounts
107
+ model_singular = options[:admin_model].underscore
108
+ model_plural = model_singular.pluralize
109
+
110
+ add_project_module model_plural
107
111
  require_dependencies('bcrypt-ruby', :require => 'bcrypt')
108
- gsub_file destination_root("admin/views/accounts/_form.#{ext}"), "f.text_field :role, :class => :text_field", "f.select :role, :options => access_control.roles"
109
- gsub_file destination_root("admin/controllers/accounts.rb"), "if account.destroy", "if account != current_account && account.destroy"
112
+ gsub_file destination_root("admin/views/#{model_plural}/_form.#{ext}"), "f.text_field :role, :class => :text_field", "f.select :role, :options => access_control.roles"
113
+ gsub_file destination_root("admin/controllers/#{model_plural}.rb"), "if #{model_singular}.destroy", "if #{model_singular} != current_account && #{model_singular}.destroy"
110
114
  return if self.behavior == :revoke
111
115
 
112
116
  instructions = []
@@ -25,6 +25,13 @@ module Padrino
25
25
  raise OrmError, "Model '#{klass_name}' could not be found!" if @columns.nil? && @klass.nil?
26
26
  end
27
27
 
28
+ def activerecord?
29
+ case orm
30
+ when :activerecord, :mini_record then true
31
+ else false
32
+ end
33
+ end
34
+
28
35
  def field_type(type)
29
36
  type = :string if type.nil? # couchrest-Hack to avoid the next line to fail
30
37
  type = type.to_s.demodulize.downcase.to_sym unless type.is_a?(Symbol)
@@ -41,7 +41,7 @@ module Padrino
41
41
  # @return [String] The translated attribute name for the current locale.
42
42
  #
43
43
  # @example
44
- # # => t("models.account.email", :default => "Email")
44
+ # # => t("models.account.attributes.email", :default => "Email")
45
45
  # mat(:account, :email)
46
46
  #
47
47
  def model_attribute_translate(model, attribute)
@@ -158,6 +158,24 @@ describe "AdminAppGenerator" do
158
158
  assert_match_in_file 'button_to pat(:logout)', "#{@apptmp}/sample_project/admin/views/layouts/application.haml"
159
159
  end
160
160
 
161
+ should 'not add activerecord middleware for #datamapper' do
162
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=datamapper', '-e=haml') }
163
+ capture_io { generate(:admin_app,"-a=/admin", "--root=#{@apptmp}/sample_project") }
164
+ assert_no_match_in_file(/ use ActiveRecord::ConnectionAdapters::ConnectionManagemen/m, "#{@apptmp}/sample_project/admin/app.rb")
165
+ end
166
+
167
+ should 'add activerecord middleware for #activerecord' do
168
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=activerecord', '-e=haml') }
169
+ capture_io { generate(:admin_app,"-a=/admin", "--root=#{@apptmp}/sample_project") }
170
+ assert_match_in_file(/ use ActiveRecord::ConnectionAdapters::ConnectionManagemen/m, "#{@apptmp}/sample_project/admin/app.rb")
171
+ end
172
+
173
+ should 'add activerecord middleware for #mini_record' do
174
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=mini_record', '-e=haml') }
175
+ capture_io { generate(:admin_app,"-a=/admin", "--root=#{@apptmp}/sample_project") }
176
+ assert_match_in_file(/ use ActiveRecord::ConnectionAdapters::ConnectionManagemen/m, "#{@apptmp}/sample_project/admin/app.rb")
177
+ end
178
+
161
179
  should 'not conflict with existing seeds file' do
162
180
  capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=activerecord', '-e=erb') }
163
181
 
metadata CHANGED
@@ -1,16 +1,10 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: padrino-admin
3
- version: !ruby/object:Gem::Version
4
- hash: 96
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.10.6.d
5
5
  prerelease: 7
6
- segments:
7
- - 0
8
- - 10
9
- - 6
10
- - c
11
- version: 0.10.6.c
12
6
  platform: ruby
13
- authors:
7
+ authors:
14
8
  - Padrino Team
15
9
  - Nathan Esquenazi
16
10
  - Davide D'Agostino
@@ -18,53 +12,37 @@ authors:
18
12
  autorequire:
19
13
  bindir: bin
20
14
  cert_chain: []
21
-
22
- date: 2012-01-25 00:00:00 -08:00
23
- default_executable:
24
- dependencies:
25
- - !ruby/object:Gem::Dependency
15
+ date: 2012-02-23 00:00:00.000000000 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
26
18
  name: padrino-core
27
- prerelease: false
28
- requirement: &id001 !ruby/object:Gem::Requirement
19
+ requirement: &70263874865080 !ruby/object:Gem::Requirement
29
20
  none: false
30
- requirements:
31
- - - "="
32
- - !ruby/object:Gem::Version
33
- hash: 96
34
- segments:
35
- - 0
36
- - 10
37
- - 6
38
- - c
39
- version: 0.10.6.c
21
+ requirements:
22
+ - - =
23
+ - !ruby/object:Gem::Version
24
+ version: 0.10.6.d
40
25
  type: :runtime
41
- version_requirements: *id001
42
- - !ruby/object:Gem::Dependency
43
- name: padrino-helpers
44
26
  prerelease: false
45
- requirement: &id002 !ruby/object:Gem::Requirement
27
+ version_requirements: *70263874865080
28
+ - !ruby/object:Gem::Dependency
29
+ name: padrino-helpers
30
+ requirement: &70263874863700 !ruby/object:Gem::Requirement
46
31
  none: false
47
- requirements:
48
- - - "="
49
- - !ruby/object:Gem::Version
50
- hash: 96
51
- segments:
52
- - 0
53
- - 10
54
- - 6
55
- - c
56
- version: 0.10.6.c
32
+ requirements:
33
+ - - =
34
+ - !ruby/object:Gem::Version
35
+ version: 0.10.6.d
57
36
  type: :runtime
58
- version_requirements: *id002
37
+ prerelease: false
38
+ version_requirements: *70263874863700
59
39
  description: Admin View for Padrino applications
60
40
  email: padrinorb@gmail.com
61
41
  executables: []
62
-
63
42
  extensions: []
64
-
65
- extra_rdoc_files:
43
+ extra_rdoc_files:
66
44
  - README.rdoc
67
- files:
45
+ files:
68
46
  - .document
69
47
  - .gitignore
70
48
  - .yardopts
@@ -175,43 +153,32 @@ files:
175
153
  - test/helper.rb
176
154
  - test/test_admin_application.rb
177
155
  - test/test_locale.rb
178
- has_rdoc: true
179
156
  homepage: http://www.padrinorb.com
180
157
  licenses: []
181
-
182
158
  post_install_message:
183
- rdoc_options:
159
+ rdoc_options:
184
160
  - --charset=UTF-8
185
- require_paths:
161
+ require_paths:
186
162
  - lib
187
- required_ruby_version: !ruby/object:Gem::Requirement
163
+ required_ruby_version: !ruby/object:Gem::Requirement
188
164
  none: false
189
- requirements:
190
- - - ">="
191
- - !ruby/object:Gem::Version
192
- hash: 3
193
- segments:
194
- - 0
195
- version: "0"
196
- required_rubygems_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ! '>='
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ required_rubygems_version: !ruby/object:Gem::Requirement
197
170
  none: false
198
- requirements:
199
- - - ">"
200
- - !ruby/object:Gem::Version
201
- hash: 25
202
- segments:
203
- - 1
204
- - 3
205
- - 1
171
+ requirements:
172
+ - - ! '>'
173
+ - !ruby/object:Gem::Version
206
174
  version: 1.3.1
207
175
  requirements: []
208
-
209
176
  rubyforge_project: padrino-admin
210
- rubygems_version: 1.6.2
177
+ rubygems_version: 1.8.17
211
178
  signing_key:
212
179
  specification_version: 3
213
180
  summary: Admin Dashboard for Padrino
214
- test_files:
181
+ test_files:
215
182
  - test/fixtures/data_mapper.rb
216
183
  - test/generators/test_account_model_generator.rb
217
184
  - test/generators/test_admin_app_generator.rb
@@ -219,3 +186,4 @@ test_files:
219
186
  - test/helper.rb
220
187
  - test/test_admin_application.rb
221
188
  - test/test_locale.rb
189
+ has_rdoc: