padrino-admin 0.6.3 → 0.6.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +16 -0
- data/VERSION +1 -1
- data/lib/padrino-admin.rb +24 -5
- data/lib/padrino-admin/access_control.rb +75 -29
- data/lib/padrino-admin/{ext_js/column_store.rb → column_store.rb} +31 -15
- data/lib/padrino-admin/config.rb +36 -0
- data/lib/padrino-admin/generators/actions.rb +62 -7
- data/lib/padrino-admin/generators/admin_app.rb +27 -26
- data/lib/padrino-admin/generators/admin_page.rb +20 -18
- data/lib/padrino-admin/generators/admin_uploader.rb +83 -0
- data/lib/padrino-admin/generators/app/app.rb.tt +1 -3
- data/lib/padrino-admin/generators/app/controllers/accounts.rb +1 -1
- data/lib/padrino-admin/generators/app/public/flash/swfupload.swf +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/back.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/background.png +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/bg-content.png +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/bg-hd-slate.png +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/bg-hd.png +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/bg-intro.png +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/bg-login.png +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/bg-menu-slate.png +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/bg-menu.png +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/bg.png +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/btn-login.png +0 -0
- data/lib/padrino-admin/generators/app/public/images/admin/cancel.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/categories.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/admin/close.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/admin/close.png +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/delete.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/download.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/duplicate.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/edit.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/export.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/hd-bg.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/image.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/loader.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/logo-loader.png +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/logo-small.png +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/new.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/no-image.png +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/preview.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/print.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/save.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/{backend → admin}/support.gif +0 -0
- data/lib/padrino-admin/generators/app/public/images/admin/up.gif +0 -0
- data/lib/padrino-admin/generators/app/public/javascripts/ext.js +4 -1
- data/lib/padrino-admin/generators/app/public/javascripts/swfupload.js +4 -0
- data/lib/padrino-admin/generators/app/public/stylesheets/admin.css +25 -43
- data/lib/padrino-admin/generators/app/public/stylesheets/login.css +3 -3
- data/lib/padrino-admin/generators/app/public/stylesheets/standard.css +53 -52
- data/lib/padrino-admin/generators/app/views/accounts/_form.haml +1 -0
- data/lib/padrino-admin/generators/app/views/base/index.haml +5 -7
- data/lib/padrino-admin/generators/app/views/javascripts/admin.js.erb +217 -297
- data/lib/padrino-admin/generators/app/views/sessions/new.haml +1 -1
- data/lib/padrino-admin/generators/templates/{controller.rb.tt → page/controller.rb.tt} +1 -1
- data/lib/padrino-admin/generators/templates/{db → page/db}/seeds.rb.tt +0 -0
- data/lib/padrino-admin/generators/templates/{views → page/views}/_form.haml.tt +0 -0
- data/lib/padrino-admin/generators/templates/{views → page/views}/edit.haml.tt +0 -0
- data/lib/padrino-admin/generators/templates/{views → page/views}/grid.js.erb.tt +1 -1
- data/lib/padrino-admin/generators/templates/{views → page/views}/new.haml.tt +0 -0
- data/lib/padrino-admin/generators/templates/{views → page/views}/store.jml.tt +0 -0
- data/lib/padrino-admin/generators/templates/uploader/controller.rb +24 -0
- data/lib/padrino-admin/generators/templates/uploader/lib/uploader.rb +54 -0
- data/lib/padrino-admin/generators/templates/uploader/views/grid.js.erb +56 -0
- data/lib/padrino-admin/generators/templates/uploader/views/store.jml +10 -0
- data/lib/padrino-admin/helpers/authentication.rb +30 -19
- data/lib/padrino-admin/helpers/view.rb +172 -35
- data/lib/padrino-admin/locale/admin/en.yml +1 -0
- data/lib/padrino-admin/middleware/flash_middleware.rb +36 -0
- data/lib/padrino-admin/orm.rb +33 -0
- data/lib/padrino-admin/orm/abstract.rb +94 -0
- data/lib/padrino-admin/{adapters/ar.rb → orm/activerecord.rb} +69 -36
- data/lib/padrino-admin/orm/datamapper.rb +214 -0
- data/lib/padrino-admin/{adapters/mm.rb → orm/mongomapper.rb} +36 -20
- data/lib/padrino-admin/utils/literal.rb +1 -1
- data/padrino-admin.gemspec +62 -51
- data/test/fixtures/active_record.rb +14 -2
- data/test/fixtures/data_mapper.rb +2 -1
- data/test/fixtures/mongo_mapper.rb +1 -1
- data/test/fixtures/test_column_store.jml +1 -0
- data/test/helper.rb +3 -2
- data/test/test_access_control.rb +1 -1
- data/test/test_active_record.rb +56 -1
- data/test/test_column_store.rb +56 -10
- data/test/test_data_mapper.rb +67 -1
- metadata +58 -47
- data/lib/padrino-admin/adapters.rb +0 -108
- data/lib/padrino-admin/adapters/dm.rb +0 -147
- data/lib/padrino-admin/ext_js/config.rb +0 -186
- data/test/fixtures/test_generic.jml +0 -7
- data/test/fixtures/test_javascript.jml +0 -81
@@ -1,29 +1,44 @@
|
|
1
1
|
module Padrino
|
2
2
|
module Admin
|
3
|
-
module
|
4
|
-
module
|
5
|
-
|
3
|
+
module Orm
|
4
|
+
module MongoMapper
|
5
|
+
##
|
6
6
|
# Here basic functions for interact with MongoMapper
|
7
|
+
#
|
7
8
|
module Base
|
8
|
-
|
9
|
-
|
9
|
+
|
10
|
+
def self.included(base) #:nodoc:
|
11
|
+
base.send :include, Padrino::Admin::Orm::Abstract::Base
|
10
12
|
base.send :include, InstanceMethods
|
11
13
|
base.extend ClassMethods
|
12
14
|
end
|
13
|
-
|
15
|
+
|
14
16
|
module InstanceMethods
|
15
|
-
end
|
16
|
-
|
17
|
+
end # InstanceMethods
|
18
|
+
|
17
19
|
module ClassMethods
|
18
|
-
|
19
|
-
|
20
|
+
##
|
21
|
+
# Return :activerecord
|
22
|
+
#
|
23
|
+
def orm
|
24
|
+
:mongomapper
|
25
|
+
end
|
26
|
+
end # ClassMethods
|
27
|
+
end # Base
|
20
28
|
|
21
|
-
|
29
|
+
##
|
30
|
+
# Here extension for Account for MongoMapper
|
31
|
+
#
|
32
|
+
# Basically we need only to perform:
|
33
|
+
#
|
34
|
+
# * Validations (email, password, role)
|
35
|
+
# * Generate crypted_password on save
|
36
|
+
#
|
22
37
|
module Account
|
23
|
-
|
24
|
-
def self.included(base)
|
38
|
+
|
39
|
+
def self.included(base) #:nodoc:
|
25
40
|
super
|
26
|
-
base.send :include, Padrino::Admin::
|
41
|
+
base.send :include, Padrino::Admin::Orm::Abstract::Account
|
27
42
|
base.send :attr_accessor, :password, :password_confirmation
|
28
43
|
# Properties
|
29
44
|
base.key :email, String
|
@@ -31,7 +46,7 @@ module Padrino
|
|
31
46
|
base.key :salt, String
|
32
47
|
base.key :role, String
|
33
48
|
# Validations
|
34
|
-
base.validates_presence_of :email
|
49
|
+
base.validates_presence_of :email, :role
|
35
50
|
base.validates_presence_of :password, :if => :password_required
|
36
51
|
base.validates_presence_of :password_confirmation, :if => :password_required
|
37
52
|
base.validates_length_of :password, :within => 4..40, :if => :password_required
|
@@ -39,11 +54,12 @@ module Padrino
|
|
39
54
|
base.validates_length_of :email, :within => 3..100
|
40
55
|
base.validates_uniqueness_of :email, :case_sensitive => false
|
41
56
|
base.validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
|
57
|
+
base.validates_format_of :role, :with => /[A-Za-z]/
|
42
58
|
# Callbacks
|
43
59
|
base.before_save :generate_password
|
44
60
|
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
61
|
+
end # Account
|
62
|
+
end # MongoMapper
|
63
|
+
end # Orm
|
64
|
+
end # Admin
|
65
|
+
end # Padrino
|
data/padrino-admin.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{padrino-admin}
|
8
|
-
s.version = "0.6.
|
8
|
+
s.version = "0.6.7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Padrino Team", "Nathan Esquenazi", "Davide D'Agostino", "Arthur Chiu"]
|
12
|
-
s.date = %q{2010-01-
|
12
|
+
s.date = %q{2010-01-26}
|
13
13
|
s.description = %q{Admin View for Padrino applications}
|
14
14
|
s.email = %q{nesquena@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -24,15 +24,12 @@ Gem::Specification.new do |s|
|
|
24
24
|
"VERSION",
|
25
25
|
"lib/padrino-admin.rb",
|
26
26
|
"lib/padrino-admin/access_control.rb",
|
27
|
-
"lib/padrino-admin/
|
28
|
-
"lib/padrino-admin/
|
29
|
-
"lib/padrino-admin/adapters/dm.rb",
|
30
|
-
"lib/padrino-admin/adapters/mm.rb",
|
31
|
-
"lib/padrino-admin/ext_js/column_store.rb",
|
32
|
-
"lib/padrino-admin/ext_js/config.rb",
|
27
|
+
"lib/padrino-admin/column_store.rb",
|
28
|
+
"lib/padrino-admin/config.rb",
|
33
29
|
"lib/padrino-admin/generators/actions.rb",
|
34
30
|
"lib/padrino-admin/generators/admin_app.rb",
|
35
31
|
"lib/padrino-admin/generators/admin_page.rb",
|
32
|
+
"lib/padrino-admin/generators/admin_uploader.rb",
|
36
33
|
"lib/padrino-admin/generators/app/app.rb.tt",
|
37
34
|
"lib/padrino-admin/generators/app/controllers/accounts.rb",
|
38
35
|
"lib/padrino-admin/generators/app/controllers/base.rb",
|
@@ -41,34 +38,39 @@ Gem::Specification.new do |s|
|
|
41
38
|
"lib/padrino-admin/generators/app/public/flash/charts.swf",
|
42
39
|
"lib/padrino-admin/generators/app/public/flash/clippy.swf",
|
43
40
|
"lib/padrino-admin/generators/app/public/flash/expressinstall.swf",
|
44
|
-
"lib/padrino-admin/generators/app/public/
|
45
|
-
"lib/padrino-admin/generators/app/public/images/
|
46
|
-
"lib/padrino-admin/generators/app/public/images/
|
47
|
-
"lib/padrino-admin/generators/app/public/images/
|
48
|
-
"lib/padrino-admin/generators/app/public/images/
|
49
|
-
"lib/padrino-admin/generators/app/public/images/
|
50
|
-
"lib/padrino-admin/generators/app/public/images/
|
51
|
-
"lib/padrino-admin/generators/app/public/images/
|
52
|
-
"lib/padrino-admin/generators/app/public/images/
|
53
|
-
"lib/padrino-admin/generators/app/public/images/
|
54
|
-
"lib/padrino-admin/generators/app/public/images/
|
55
|
-
"lib/padrino-admin/generators/app/public/images/
|
56
|
-
"lib/padrino-admin/generators/app/public/images/
|
57
|
-
"lib/padrino-admin/generators/app/public/images/
|
58
|
-
"lib/padrino-admin/generators/app/public/images/
|
59
|
-
"lib/padrino-admin/generators/app/public/images/
|
60
|
-
"lib/padrino-admin/generators/app/public/images/
|
61
|
-
"lib/padrino-admin/generators/app/public/images/
|
62
|
-
"lib/padrino-admin/generators/app/public/images/
|
63
|
-
"lib/padrino-admin/generators/app/public/images/
|
64
|
-
"lib/padrino-admin/generators/app/public/images/
|
65
|
-
"lib/padrino-admin/generators/app/public/images/
|
66
|
-
"lib/padrino-admin/generators/app/public/images/
|
67
|
-
"lib/padrino-admin/generators/app/public/images/
|
68
|
-
"lib/padrino-admin/generators/app/public/images/
|
69
|
-
"lib/padrino-admin/generators/app/public/images/
|
70
|
-
"lib/padrino-admin/generators/app/public/images/
|
71
|
-
"lib/padrino-admin/generators/app/public/images/
|
41
|
+
"lib/padrino-admin/generators/app/public/flash/swfupload.swf",
|
42
|
+
"lib/padrino-admin/generators/app/public/images/admin/back.gif",
|
43
|
+
"lib/padrino-admin/generators/app/public/images/admin/background.png",
|
44
|
+
"lib/padrino-admin/generators/app/public/images/admin/bg-content.png",
|
45
|
+
"lib/padrino-admin/generators/app/public/images/admin/bg-hd-slate.png",
|
46
|
+
"lib/padrino-admin/generators/app/public/images/admin/bg-hd.png",
|
47
|
+
"lib/padrino-admin/generators/app/public/images/admin/bg-intro.png",
|
48
|
+
"lib/padrino-admin/generators/app/public/images/admin/bg-login.png",
|
49
|
+
"lib/padrino-admin/generators/app/public/images/admin/bg-menu-slate.png",
|
50
|
+
"lib/padrino-admin/generators/app/public/images/admin/bg-menu.png",
|
51
|
+
"lib/padrino-admin/generators/app/public/images/admin/bg.png",
|
52
|
+
"lib/padrino-admin/generators/app/public/images/admin/btn-login.png",
|
53
|
+
"lib/padrino-admin/generators/app/public/images/admin/cancel.gif",
|
54
|
+
"lib/padrino-admin/generators/app/public/images/admin/categories.gif",
|
55
|
+
"lib/padrino-admin/generators/app/public/images/admin/close.gif",
|
56
|
+
"lib/padrino-admin/generators/app/public/images/admin/close.png",
|
57
|
+
"lib/padrino-admin/generators/app/public/images/admin/delete.gif",
|
58
|
+
"lib/padrino-admin/generators/app/public/images/admin/download.gif",
|
59
|
+
"lib/padrino-admin/generators/app/public/images/admin/duplicate.gif",
|
60
|
+
"lib/padrino-admin/generators/app/public/images/admin/edit.gif",
|
61
|
+
"lib/padrino-admin/generators/app/public/images/admin/export.gif",
|
62
|
+
"lib/padrino-admin/generators/app/public/images/admin/hd-bg.gif",
|
63
|
+
"lib/padrino-admin/generators/app/public/images/admin/image.gif",
|
64
|
+
"lib/padrino-admin/generators/app/public/images/admin/loader.gif",
|
65
|
+
"lib/padrino-admin/generators/app/public/images/admin/logo-loader.png",
|
66
|
+
"lib/padrino-admin/generators/app/public/images/admin/logo-small.png",
|
67
|
+
"lib/padrino-admin/generators/app/public/images/admin/new.gif",
|
68
|
+
"lib/padrino-admin/generators/app/public/images/admin/no-image.png",
|
69
|
+
"lib/padrino-admin/generators/app/public/images/admin/preview.gif",
|
70
|
+
"lib/padrino-admin/generators/app/public/images/admin/print.gif",
|
71
|
+
"lib/padrino-admin/generators/app/public/images/admin/save.gif",
|
72
|
+
"lib/padrino-admin/generators/app/public/images/admin/support.gif",
|
73
|
+
"lib/padrino-admin/generators/app/public/images/admin/up.gif",
|
72
74
|
"lib/padrino-admin/generators/app/public/images/ext/default/box/corners-blue.gif",
|
73
75
|
"lib/padrino-admin/generators/app/public/images/ext/default/box/corners.gif",
|
74
76
|
"lib/padrino-admin/generators/app/public/images/ext/default/box/l-blue.gif",
|
@@ -290,6 +292,7 @@ Gem::Specification.new do |s|
|
|
290
292
|
"lib/padrino-admin/generators/app/public/javascripts/effects.js",
|
291
293
|
"lib/padrino-admin/generators/app/public/javascripts/ext.js",
|
292
294
|
"lib/padrino-admin/generators/app/public/javascripts/prototype.js",
|
295
|
+
"lib/padrino-admin/generators/app/public/javascripts/swfupload.js",
|
293
296
|
"lib/padrino-admin/generators/app/public/stylesheets/admin.css",
|
294
297
|
"lib/padrino-admin/generators/app/public/stylesheets/ext.css",
|
295
298
|
"lib/padrino-admin/generators/app/public/stylesheets/login.css",
|
@@ -304,17 +307,27 @@ Gem::Specification.new do |s|
|
|
304
307
|
"lib/padrino-admin/generators/app/views/javascripts/admin.js.erb",
|
305
308
|
"lib/padrino-admin/generators/app/views/javascripts/locale.js.erb",
|
306
309
|
"lib/padrino-admin/generators/app/views/sessions/new.haml",
|
307
|
-
"lib/padrino-admin/generators/templates/controller.rb.tt",
|
308
|
-
"lib/padrino-admin/generators/templates/db/seeds.rb.tt",
|
309
|
-
"lib/padrino-admin/generators/templates/views/_form.haml.tt",
|
310
|
-
"lib/padrino-admin/generators/templates/views/edit.haml.tt",
|
311
|
-
"lib/padrino-admin/generators/templates/views/grid.js.erb.tt",
|
312
|
-
"lib/padrino-admin/generators/templates/views/new.haml.tt",
|
313
|
-
"lib/padrino-admin/generators/templates/views/store.jml.tt",
|
310
|
+
"lib/padrino-admin/generators/templates/page/controller.rb.tt",
|
311
|
+
"lib/padrino-admin/generators/templates/page/db/seeds.rb.tt",
|
312
|
+
"lib/padrino-admin/generators/templates/page/views/_form.haml.tt",
|
313
|
+
"lib/padrino-admin/generators/templates/page/views/edit.haml.tt",
|
314
|
+
"lib/padrino-admin/generators/templates/page/views/grid.js.erb.tt",
|
315
|
+
"lib/padrino-admin/generators/templates/page/views/new.haml.tt",
|
316
|
+
"lib/padrino-admin/generators/templates/page/views/store.jml.tt",
|
317
|
+
"lib/padrino-admin/generators/templates/uploader/controller.rb",
|
318
|
+
"lib/padrino-admin/generators/templates/uploader/lib/uploader.rb",
|
319
|
+
"lib/padrino-admin/generators/templates/uploader/views/grid.js.erb",
|
320
|
+
"lib/padrino-admin/generators/templates/uploader/views/store.jml",
|
314
321
|
"lib/padrino-admin/helpers/authentication.rb",
|
315
322
|
"lib/padrino-admin/helpers/view.rb",
|
316
323
|
"lib/padrino-admin/locale/admin/en.yml",
|
317
324
|
"lib/padrino-admin/locale/extjs/en.yml",
|
325
|
+
"lib/padrino-admin/middleware/flash_middleware.rb",
|
326
|
+
"lib/padrino-admin/orm.rb",
|
327
|
+
"lib/padrino-admin/orm/abstract.rb",
|
328
|
+
"lib/padrino-admin/orm/activerecord.rb",
|
329
|
+
"lib/padrino-admin/orm/datamapper.rb",
|
330
|
+
"lib/padrino-admin/orm/mongomapper.rb",
|
318
331
|
"lib/padrino-admin/utils/crypt.rb",
|
319
332
|
"lib/padrino-admin/utils/literal.rb",
|
320
333
|
"padrino-admin.gemspec",
|
@@ -322,8 +335,6 @@ Gem::Specification.new do |s|
|
|
322
335
|
"test/fixtures/data_mapper.rb",
|
323
336
|
"test/fixtures/mongo_mapper.rb",
|
324
337
|
"test/fixtures/test_column_store.jml",
|
325
|
-
"test/fixtures/test_generic.jml",
|
326
|
-
"test/fixtures/test_javascript.jml",
|
327
338
|
"test/helper.rb",
|
328
339
|
"test/test_access_control.rb",
|
329
340
|
"test/test_active_record.rb",
|
@@ -344,8 +355,8 @@ Gem::Specification.new do |s|
|
|
344
355
|
|
345
356
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
346
357
|
s.add_runtime_dependency(%q<json_pure>, [">= 1.2.0"])
|
347
|
-
s.add_runtime_dependency(%q<padrino-core>, ["= 0.6.
|
348
|
-
s.add_runtime_dependency(%q<padrino-gen>, ["= 0.6.
|
358
|
+
s.add_runtime_dependency(%q<padrino-core>, ["= 0.6.7"])
|
359
|
+
s.add_runtime_dependency(%q<padrino-gen>, ["= 0.6.7"])
|
349
360
|
s.add_runtime_dependency(%q<tilt>, [">= 0.4"])
|
350
361
|
s.add_development_dependency(%q<haml>, [">= 2.2.1"])
|
351
362
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
@@ -354,8 +365,8 @@ Gem::Specification.new do |s|
|
|
354
365
|
s.add_development_dependency(%q<webrat>, [">= 0.5.1"])
|
355
366
|
else
|
356
367
|
s.add_dependency(%q<json_pure>, [">= 1.2.0"])
|
357
|
-
s.add_dependency(%q<padrino-core>, ["= 0.6.
|
358
|
-
s.add_dependency(%q<padrino-gen>, ["= 0.6.
|
368
|
+
s.add_dependency(%q<padrino-core>, ["= 0.6.7"])
|
369
|
+
s.add_dependency(%q<padrino-gen>, ["= 0.6.7"])
|
359
370
|
s.add_dependency(%q<tilt>, [">= 0.4"])
|
360
371
|
s.add_dependency(%q<haml>, [">= 2.2.1"])
|
361
372
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
@@ -365,8 +376,8 @@ Gem::Specification.new do |s|
|
|
365
376
|
end
|
366
377
|
else
|
367
378
|
s.add_dependency(%q<json_pure>, [">= 1.2.0"])
|
368
|
-
s.add_dependency(%q<padrino-core>, ["= 0.6.
|
369
|
-
s.add_dependency(%q<padrino-gen>, ["= 0.6.
|
379
|
+
s.add_dependency(%q<padrino-core>, ["= 0.6.7"])
|
380
|
+
s.add_dependency(%q<padrino-gen>, ["= 0.6.7"])
|
370
381
|
s.add_dependency(%q<tilt>, [">= 0.4"])
|
371
382
|
s.add_dependency(%q<haml>, [">= 2.2.1"])
|
372
383
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
@@ -11,7 +11,19 @@ ActiveRecord::Schema.define do
|
|
11
11
|
t.column :salt, :string
|
12
12
|
t.column :email, :string
|
13
13
|
end
|
14
|
+
|
15
|
+
create_table :categories, :force => true do |t|
|
16
|
+
t.column :name, :string
|
17
|
+
t.column :account_id, :integer
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class Account < ActiveRecord::Base
|
22
|
+
has_many :categories
|
23
|
+
end
|
24
|
+
|
25
|
+
class Category < ActiveRecord::Base
|
26
|
+
belongs_to :account
|
14
27
|
end
|
15
28
|
|
16
|
-
|
17
|
-
Padrino::Admin::Adapters.register(:activerecord)
|
29
|
+
Padrino::Admin::Orm.register!
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'dm-core'
|
2
2
|
require 'dm-validations'
|
3
|
+
require 'dm-aggregates'
|
3
4
|
|
4
5
|
DataMapper.setup(:default, 'sqlite3::memory:')
|
5
6
|
|
@@ -21,7 +22,7 @@ class Account
|
|
21
22
|
def self.editor; first(:role => "Editor"); end
|
22
23
|
end
|
23
24
|
|
24
|
-
Padrino::Admin::
|
25
|
+
Padrino::Admin::Orm.register!
|
25
26
|
DataMapper.auto_migrate!
|
26
27
|
|
27
28
|
# We build some fake accounts
|
data/test/helper.rb
CHANGED
@@ -10,7 +10,7 @@ require 'shoulda'
|
|
10
10
|
# We try to load the vendored padrino-core if exist
|
11
11
|
%w(core gen).each do |gem|
|
12
12
|
if File.exist?(File.dirname(__FILE__) + "/../../padrino-#{gem}/lib")
|
13
|
-
|
13
|
+
$:.unshift File.dirname(__FILE__) + "/../../padrino-#{gem}/lib"
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -29,7 +29,8 @@ module Kernel
|
|
29
29
|
alias :silence_stdout :silence_logger
|
30
30
|
|
31
31
|
def load_fixture(file)
|
32
|
-
Object.send(:remove_const, :Account)
|
32
|
+
Object.send(:remove_const, :Account) if defined?(Account)
|
33
|
+
Object.send(:remove_const, :Category) if defined?(Category)
|
33
34
|
file += ".rb" if file !~ /.rb$/
|
34
35
|
silence_stdout { load File.join(File.dirname(__FILE__), "fixtures", file) }
|
35
36
|
end
|
data/test/test_access_control.rb
CHANGED
@@ -91,7 +91,7 @@ class TestAccessControl < Test::Unit::TestCase
|
|
91
91
|
end
|
92
92
|
|
93
93
|
should 'check config handlers' do
|
94
|
-
assert_kind_of Padrino::
|
94
|
+
assert_kind_of Padrino::Admin::Config::Variable, @access.auths(Account.editor).project_modules.collect(&:config).first[:menu].first[:handler]
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
data/test/test_active_record.rb
CHANGED
@@ -6,7 +6,7 @@ class TestActiveRecord < Test::Unit::TestCase
|
|
6
6
|
load_fixture 'active_record'
|
7
7
|
end
|
8
8
|
|
9
|
-
context 'for activerecord functionality' do
|
9
|
+
context 'for activerecord account functionality' do
|
10
10
|
|
11
11
|
should 'check required fields' do
|
12
12
|
account = Account.create
|
@@ -25,4 +25,59 @@ class TestActiveRecord < Test::Unit::TestCase
|
|
25
25
|
assert_equal account_r, account
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
29
|
+
context 'for activerecord functionality' do
|
30
|
+
|
31
|
+
should 'have some standard methods' do
|
32
|
+
account = Account.new
|
33
|
+
assert_respond_to account, :new_record?
|
34
|
+
assert_respond_to account, :to_param
|
35
|
+
assert_respond_to account, :update_attributes
|
36
|
+
assert_respond_to Account, :count
|
37
|
+
end
|
38
|
+
|
39
|
+
should 'have errors_keys' do
|
40
|
+
account = Account.new
|
41
|
+
account.valid?
|
42
|
+
assert_equal [:email, :role, :password, :password_confirmation], account.errors_keys
|
43
|
+
end
|
44
|
+
|
45
|
+
should 'have table name' do
|
46
|
+
assert_equal "accounts", Account.table_name
|
47
|
+
end
|
48
|
+
|
49
|
+
should 'have orm defined' do
|
50
|
+
assert_equal :activerecord, Account.orm
|
51
|
+
end
|
52
|
+
|
53
|
+
should 'search correctly fields' do
|
54
|
+
accounts, categories = {}, {}
|
55
|
+
|
56
|
+
%w(gino paoli mario venuti franco).each do |name|
|
57
|
+
accounts[name] = Account.create(:email => "#{name}@foo.com", :role => name, :password => "some", :password_confirmation => "some")
|
58
|
+
assert_equal [accounts[name]], Account.ext_search(:query => name, :fields => "email,role").records
|
59
|
+
accounts
|
60
|
+
end
|
61
|
+
|
62
|
+
%w(rock soul classic rap jazz).each_with_index do |name, i|
|
63
|
+
categories[name] = Category.create(:name => name, :account_id => i+1)
|
64
|
+
assert_equal [categories[name]], Category.ext_search(:query => name, :fields => "name").records
|
65
|
+
accounts
|
66
|
+
end
|
67
|
+
|
68
|
+
# Make sure that our builtin count is correct
|
69
|
+
assert_equal 5, Account.ext_search({}).count
|
70
|
+
assert_equal 5, Account.ext_search({}).count
|
71
|
+
|
72
|
+
# Perform some search
|
73
|
+
assert_equal [accounts["venuti"]], Account.ext_search(:query => "en", :fields => "email,role").records
|
74
|
+
assert_equal [accounts["gino"], accounts["venuti"], accounts["franco"]], Account.ext_search(:query => "n", :fields => "email,role").records
|
75
|
+
assert_equal [accounts["venuti"], accounts["franco"]], Account.ext_search(:start => 3, :limit => 2).records
|
76
|
+
assert_equal [accounts["paoli"], accounts["venuti"]], Account.ext_search(:start => 3, :limit => 2, :sort => "role", :dir => "asc").records
|
77
|
+
|
78
|
+
# Perform some extended search
|
79
|
+
assert_equal [accounts["venuti"]], Account.ext_search({ :query => "rap", :fields => "categories.name" }, :joins => :categories).records
|
80
|
+
assert_equal [accounts["franco"], accounts["mario"]], Account.ext_search({:start => 3, :limit => 2, :sort => "categories.name", :dir => "desc"}, :joins => :categories).records
|
81
|
+
end
|
82
|
+
end
|
28
83
|
end
|
data/test/test_column_store.rb
CHANGED
@@ -11,31 +11,77 @@ class TestController < Test::Unit::TestCase
|
|
11
11
|
dataIndex: name
|
12
12
|
- method: surname
|
13
13
|
- method: category.name
|
14
|
+
dataIndex: categories.name
|
14
15
|
- method: email
|
15
16
|
header: E-mail
|
16
17
|
sortable: false
|
17
18
|
- method: role
|
18
19
|
YAML
|
19
|
-
@column_store = Padrino::
|
20
|
+
@column_store = Padrino::Admin::ColumnStore.new(Account, config)
|
20
21
|
@column_store_direct = Account.column_store("test/fixtures/test_column_store.jml")
|
21
22
|
end
|
22
23
|
|
23
24
|
should 'have correct column fileds' do
|
24
|
-
result =
|
25
|
-
|
26
|
-
|
25
|
+
result = [
|
26
|
+
{"name"=>"account[name]",
|
27
|
+
"header"=>"Name upcase",
|
28
|
+
"sortable"=>true,
|
29
|
+
"id"=>"account_name",
|
30
|
+
"dataIndex"=>"accounts.name"},
|
31
|
+
{"name"=>"account[surname]",
|
32
|
+
"header"=>"Surname",
|
33
|
+
"sortable"=>true,
|
34
|
+
"id"=>"account_surname",
|
35
|
+
"dataIndex"=>"accounts.surname"},
|
36
|
+
{"name"=>"category[name]",
|
37
|
+
"header"=>"Category.name",
|
38
|
+
"sortable"=>true,
|
39
|
+
"id"=>"category_name",
|
40
|
+
"dataIndex"=>"categories.name"},
|
41
|
+
{"name"=>"account[email]",
|
42
|
+
"header"=>"E-mail",
|
43
|
+
"sortable"=>false,
|
44
|
+
"id"=>"account_email",
|
45
|
+
"dataIndex"=>"accounts.email"},
|
46
|
+
{"name"=>"account[role]",
|
47
|
+
"header"=>"Role",
|
48
|
+
"sortable"=>true,
|
49
|
+
"id"=>"account_role",
|
50
|
+
"dataIndex"=>"accounts.role"}
|
51
|
+
]
|
52
|
+
assert_equal result, @column_store.column_fields(false)
|
53
|
+
assert_equal result, @column_store_direct.column_fields(false)
|
27
54
|
end
|
28
55
|
|
29
56
|
should 'have correct store fields' do
|
30
|
-
result =
|
31
|
-
|
32
|
-
|
57
|
+
result = [
|
58
|
+
{:mapping=>"account_name", :name=>"accounts.name"},
|
59
|
+
{:mapping=>"account_surname", :name=>"accounts.surname"},
|
60
|
+
{:mapping=>"category_name", :name=>"categories.name"},
|
61
|
+
{:mapping=>"account_email", :name=>"accounts.email"},
|
62
|
+
{:mapping=>"account_role", :name=>"accounts.role"}
|
63
|
+
]
|
64
|
+
assert_equal result, @column_store.store_fields(false)
|
65
|
+
assert_equal result, @column_store_direct.store_fields(false)
|
33
66
|
end
|
34
67
|
|
35
68
|
should 'store data' do
|
36
|
-
result =
|
37
|
-
|
38
|
-
|
69
|
+
result = {:results=>[
|
70
|
+
{"account_surname"=>"Not found",
|
71
|
+
"account_email"=>"d.dagostino@lipsiasoft.com",
|
72
|
+
"category_name"=>"Not found",
|
73
|
+
"id"=>1,
|
74
|
+
"account_role"=>"Admin",
|
75
|
+
"account_name"=>"DADDYE"},
|
76
|
+
{"account_surname"=>"Not found",
|
77
|
+
"account_email"=>"editor@lipsiasoft.com",
|
78
|
+
"category_name"=>"Not found",
|
79
|
+
"id"=>2,
|
80
|
+
"account_role"=>"Editor",
|
81
|
+
"account_name"=>"DEXTER"}
|
82
|
+
], :count=>2}
|
83
|
+
assert_equal result, @column_store.store_data(:json => false, :fields => "name,role", :query => "d", :sort => :name, :dir => :asc, :limit => 2, :offset => 0)
|
84
|
+
assert_equal result, @column_store_direct.store_data(:json => false, :fields => "name,role", :query => "d", :sort => :name, :dir => :asc, :limit => 2, :offset => 0)
|
39
85
|
end
|
40
86
|
|
41
87
|
end
|