typus 3.0.8 → 3.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +8 -1
- data/README.md +2 -2
- data/Rakefile +6 -14
- data/app/controllers/admin/base_controller.rb +1 -1
- data/app/controllers/admin/dashboard_controller.rb +0 -1
- data/app/controllers/admin/resources_controller.rb +8 -11
- data/app/controllers/admin/session_controller.rb +5 -4
- data/app/helpers/admin/base_helper.rb +9 -2
- data/app/helpers/admin/dashboard_helper.rb +0 -6
- data/app/helpers/admin/display_helper.rb +1 -0
- data/app/helpers/admin/file_preview_helper.rb +0 -2
- data/app/helpers/admin/filters_helper.rb +6 -3
- data/app/helpers/admin/form_helper.rb +2 -4
- data/app/helpers/admin/list_helper.rb +1 -3
- data/app/helpers/admin/relationships_helper.rb +2 -4
- data/app/helpers/admin/resources_helper.rb +0 -2
- data/app/helpers/admin/search_helper.rb +0 -2
- data/app/helpers/admin/sidebar_helper.rb +0 -2
- data/app/helpers/admin/table_helper.rb +3 -6
- data/app/views/admin/account/forgot_password.html.erb +2 -2
- data/app/views/admin/account/new.html.erb +3 -7
- data/app/views/admin/{helpers/dashboard → dashboard}/_applications.html.erb +0 -0
- data/app/views/admin/dashboard/_sidebar.html.erb +1 -1
- data/app/views/admin/dashboard/show.html.erb +7 -1
- data/app/views/admin/helpers/base/_apps.html.erb +1 -1
- data/app/views/admin/helpers/base/_login_info.html.erb +2 -2
- data/app/views/admin/helpers/filters/_filters.html.erb +3 -1
- data/app/views/admin/resources/_form.html.erb +5 -2
- data/app/views/admin/resources/edit.html.erb +1 -1
- data/app/views/admin/resources/index.html.erb +1 -1
- data/app/views/admin/resources/show.html.erb +2 -2
- data/app/views/admin/session/new.html.erb +3 -7
- data/app/views/admin/templates/_belongs_to.html.erb +8 -1
- data/app/views/admin/templates/_belongs_to_with_autocomplete.html.erb +1 -1
- data/app/views/admin/templates/_relate_form.html.erb +1 -1
- data/app/views/admin/templates/_relate_form_with_autocomplete.html.erb +3 -1
- data/app/views/admin/templates/_string.html.erb +1 -1
- data/app/views/admin/templates/_text.html.erb +1 -1
- data/app/views/layouts/admin/base.html.erb +2 -0
- data/app/views/layouts/admin/headless.html.erb +2 -0
- data/app/views/layouts/admin/session.html.erb +6 -0
- data/config/routes.rb +4 -1
- data/lib/support/active_record.rb +0 -10
- data/lib/support/fake_user.rb +4 -6
- data/lib/support/object.rb +4 -0
- data/lib/support/string.rb +0 -8
- data/lib/typus.rb +2 -3
- data/lib/typus/authentication/base.rb +0 -1
- data/lib/typus/authentication/session.rb +22 -29
- data/lib/typus/orm/active_record.rb +5 -5
- data/lib/typus/orm/active_record/admin_user_v1.rb +93 -0
- data/lib/typus/orm/active_record/admin_user_v2.rb +49 -0
- data/lib/typus/orm/active_record/class_methods.rb +23 -143
- data/lib/typus/orm/active_record/user/instance_methods.rb +64 -0
- data/lib/typus/orm/base.rb +170 -0
- data/lib/typus/orm/mongo/class_methods.rb +11 -0
- data/lib/typus/resources.rb +2 -1
- data/lib/typus/version.rb +1 -1
- data/test/app/controllers/admin/account_controller_test.rb +4 -2
- data/test/app/controllers/admin/assets_controller_test.rb +12 -12
- data/test/app/controllers/admin/categories_controller_test.rb +5 -12
- data/test/app/controllers/admin/comments_controller_test.rb +1 -1
- data/test/app/controllers/admin/image_holders_controller_test.rb +1 -1
- data/test/app/controllers/admin/invoices_controller_test.rb +1 -1
- data/test/app/controllers/admin/posts_controller_test.rb +32 -32
- data/test/app/controllers/admin/projects_controller_test.rb +1 -1
- data/test/app/controllers/admin/typus_users_controller_test.rb +13 -17
- data/test/app/controllers/admin/users_controller_test.rb +9 -9
- data/test/app/helpers/admin/list_helper_test.rb +17 -0
- data/test/app/models/admin_user_test.rb +5 -0
- data/test/app/models/typus_user_roles_test.rb +1 -0
- data/test/app/models/typus_user_test.rb +45 -11
- data/test/factories.rb +1 -1
- data/test/fixtures/rails_app/app/controllers/admin/hits_controller.rb +40 -0
- data/test/fixtures/rails_app/app/controllers/admin_user.rb +3 -0
- data/test/fixtures/rails_app/app/models/asset.rb +0 -6
- data/test/fixtures/rails_app/app/models/hit.rb +27 -0
- data/test/fixtures/rails_app/app/views/admin/hits/_edit.html.erb +7 -0
- data/test/fixtures/rails_app/app/views/admin/hits/_index.html.erb +3 -0
- data/test/fixtures/rails_app/app/views/admin/hits/index.html.erb +28 -0
- data/test/fixtures/rails_app/config/boot.rb +3 -10
- data/test/fixtures/rails_app/config/deploy.rb +1 -1
- data/test/fixtures/rails_app/config/mongoid.yml +20 -0
- data/test/fixtures/rails_app/config/typus/crud_extended.yml +2 -0
- data/test/fixtures/rails_app/config/typus/mongo_db.yml +4 -0
- data/test/fixtures/rails_app/config/typus/mongo_db_roles.yml +2 -0
- data/test/fixtures/rails_app/db/schema.rb +11 -0
- data/test/lib/support/fake_user_test.rb +4 -0
- data/test/lib/support/string_test.rb +0 -18
- data/test/lib/typus/orm/active_record/class_methods_test.rb +14 -2
- data/test/lib/typus/orm/active_record/search_test.rb +1 -1
- data/test/lib/typus_test.rb +2 -1
- data/typus.gemspec +1 -1
- metadata +32 -45
- data/lib/typus/orm/active_record/instance_methods.rb +0 -13
- data/lib/typus/orm/active_record/user.rb +0 -157
- data/test/fixtures/rails_app/public/javascripts/application.js +0 -2
- data/test/fixtures/rails_app/public/javascripts/controls.js +0 -965
- data/test/fixtures/rails_app/public/javascripts/dragdrop.js +0 -974
- data/test/fixtures/rails_app/public/javascripts/effects.js +0 -1123
- data/test/fixtures/rails_app/public/javascripts/prototype.js +0 -6001
- data/test/fixtures/rails_app/public/javascripts/rails.js +0 -175
@@ -97,7 +97,7 @@ class ClassMethodsTest < ActiveSupport::TestCase
|
|
97
97
|
["password_confirmation", :password],
|
98
98
|
["locale", :selector]]
|
99
99
|
|
100
|
-
assert_equal expected.map { |i| i.first }, TypusUser.typus_fields_for(:
|
100
|
+
assert_equal expected.map { |i| i.first }, TypusUser.typus_fields_for(:new).keys
|
101
101
|
assert_equal expected.map { |i| i.last }, TypusUser.typus_fields_for(:form).values
|
102
102
|
end
|
103
103
|
|
@@ -127,6 +127,16 @@ class ClassMethodsTest < ActiveSupport::TestCase
|
|
127
127
|
assert_equal expected, TypusUser.typus_fields_for(:undefined).keys
|
128
128
|
end
|
129
129
|
|
130
|
+
should "return fields for new Asset" do
|
131
|
+
expected = %w(dragonfly_required)
|
132
|
+
assert_equal expected, Asset.typus_fields_for(:new).keys
|
133
|
+
end
|
134
|
+
|
135
|
+
should "return fields for edit Asset" do
|
136
|
+
expected = %w(caption dragonfly dragonfly_required original_file_name)
|
137
|
+
assert_equal expected, Asset.typus_fields_for(:edit).keys
|
138
|
+
end
|
139
|
+
|
130
140
|
should "work for transversal fields" do
|
131
141
|
expected = [["email", :string],
|
132
142
|
["post", :belongs_to],
|
@@ -363,7 +373,9 @@ class ClassMethodsTest < ActiveSupport::TestCase
|
|
363
373
|
should "return data for existing model" do
|
364
374
|
expected = {"application"=>"CRUD Extended",
|
365
375
|
"fields"=>{"default"=>"caption, dragonfly, dragonfly_required",
|
366
|
-
"special"=>"caption, dragonfly, dragonfly_required, original_file_name"
|
376
|
+
"special"=>"caption, dragonfly, dragonfly_required, original_file_name",
|
377
|
+
"form"=>"caption, dragonfly, dragonfly_required, original_file_name",
|
378
|
+
"new"=>"dragonfly_required"}}
|
367
379
|
assert_equal expected, Asset.read_model_config
|
368
380
|
end
|
369
381
|
|
@@ -34,7 +34,7 @@ class ActiveRecordTest < ActiveSupport::TestCase
|
|
34
34
|
end
|
35
35
|
|
36
36
|
should "generate conditions for id" do
|
37
|
-
Post.
|
37
|
+
Post.expects(:typus_defaults_for).with(:search).returns(["id"])
|
38
38
|
|
39
39
|
expected = case ENV["DB"]
|
40
40
|
when "postgresql"
|
data/test/lib/typus_test.rb
CHANGED
@@ -71,7 +71,7 @@ class TypusTest < ActiveSupport::TestCase
|
|
71
71
|
end
|
72
72
|
|
73
73
|
should "return applications sorted" do
|
74
|
-
expected = ["Admin", "CRUD", "CRUD Extended", "HasManyThrough", "HasOne", "Polymorphic", "STI"]
|
74
|
+
expected = ["Admin", "CRUD", "CRUD Extended", "HasManyThrough", "HasOne", "MongoDB", "Polymorphic", "STI"]
|
75
75
|
assert_equal expected, Typus.applications
|
76
76
|
end
|
77
77
|
|
@@ -89,6 +89,7 @@ class TypusTest < ActiveSupport::TestCase
|
|
89
89
|
"Comment",
|
90
90
|
"Dog",
|
91
91
|
"Entry",
|
92
|
+
"Hit",
|
92
93
|
"ImageHolder",
|
93
94
|
"Invoice",
|
94
95
|
"Order",
|
data/typus.gemspec
CHANGED
@@ -16,9 +16,9 @@ Gem::Specification.new do |s|
|
|
16
16
|
|
17
17
|
s.files = `git ls-files`.split("\n")
|
18
18
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
19
|
s.require_paths = ["lib"]
|
21
20
|
|
21
|
+
s.add_dependency "bcrypt-ruby"
|
22
22
|
s.add_dependency "fastercsv", "~> 1.5" if RUBY_VERSION < '1.9'
|
23
23
|
s.add_dependency "render_inheritable"
|
24
24
|
s.add_dependency "will_paginate", "~> 3.0.pre2"
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 23
|
5
4
|
prerelease:
|
6
|
-
|
7
|
-
- 3
|
8
|
-
- 0
|
9
|
-
- 8
|
10
|
-
version: 3.0.8
|
5
|
+
version: 3.0.9
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Francesc Esplugas
|
@@ -15,22 +10,18 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date: 2011-
|
13
|
+
date: 2011-03-12 00:00:00 +01:00
|
19
14
|
default_executable:
|
20
15
|
dependencies:
|
21
16
|
- !ruby/object:Gem::Dependency
|
22
|
-
name:
|
17
|
+
name: bcrypt-ruby
|
23
18
|
prerelease: false
|
24
19
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
20
|
none: false
|
26
21
|
requirements:
|
27
|
-
- -
|
22
|
+
- - ">="
|
28
23
|
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 1
|
32
|
-
- 5
|
33
|
-
version: "1.5"
|
24
|
+
version: "0"
|
34
25
|
type: :runtime
|
35
26
|
version_requirements: *id001
|
36
27
|
- !ruby/object:Gem::Dependency
|
@@ -41,9 +32,6 @@ dependencies:
|
|
41
32
|
requirements:
|
42
33
|
- - ">="
|
43
34
|
- !ruby/object:Gem::Version
|
44
|
-
hash: 3
|
45
|
-
segments:
|
46
|
-
- 0
|
47
35
|
version: "0"
|
48
36
|
type: :runtime
|
49
37
|
version_requirements: *id002
|
@@ -55,12 +43,6 @@ dependencies:
|
|
55
43
|
requirements:
|
56
44
|
- - ~>
|
57
45
|
- !ruby/object:Gem::Version
|
58
|
-
hash: 1923831917
|
59
|
-
segments:
|
60
|
-
- 3
|
61
|
-
- 0
|
62
|
-
- pre
|
63
|
-
- 2
|
64
46
|
version: 3.0.pre2
|
65
47
|
type: :runtime
|
66
48
|
version_requirements: *id003
|
@@ -102,6 +84,7 @@ files:
|
|
102
84
|
- app/views/admin/account/forgot_password.html.erb
|
103
85
|
- app/views/admin/account/new.html.erb
|
104
86
|
- app/views/admin/base/user_guide.html.erb
|
87
|
+
- app/views/admin/dashboard/_applications.html.erb
|
105
88
|
- app/views/admin/dashboard/_sidebar.html.erb
|
106
89
|
- app/views/admin/dashboard/show.html.erb
|
107
90
|
- app/views/admin/dashboard/styles.html.erb
|
@@ -110,7 +93,6 @@ files:
|
|
110
93
|
- app/views/admin/helpers/base/_flash_message.html.erb
|
111
94
|
- app/views/admin/helpers/base/_header.html.erb
|
112
95
|
- app/views/admin/helpers/base/_login_info.html.erb
|
113
|
-
- app/views/admin/helpers/dashboard/_applications.html.erb
|
114
96
|
- app/views/admin/helpers/dashboard/_resources.html.erb
|
115
97
|
- app/views/admin/helpers/filters/_filters.html.erb
|
116
98
|
- app/views/admin/helpers/resources/_display_link_to_previous.html.erb
|
@@ -261,10 +243,13 @@ files:
|
|
261
243
|
- lib/typus/engine.rb
|
262
244
|
- lib/typus/i18n.rb
|
263
245
|
- lib/typus/orm/active_record.rb
|
246
|
+
- lib/typus/orm/active_record/admin_user_v1.rb
|
247
|
+
- lib/typus/orm/active_record/admin_user_v2.rb
|
264
248
|
- lib/typus/orm/active_record/class_methods.rb
|
265
|
-
- lib/typus/orm/active_record/instance_methods.rb
|
266
249
|
- lib/typus/orm/active_record/search.rb
|
267
|
-
- lib/typus/orm/active_record/user.rb
|
250
|
+
- lib/typus/orm/active_record/user/instance_methods.rb
|
251
|
+
- lib/typus/orm/base.rb
|
252
|
+
- lib/typus/orm/mongo/class_methods.rb
|
268
253
|
- lib/typus/regex.rb
|
269
254
|
- lib/typus/resources.rb
|
270
255
|
- lib/typus/version.rb
|
@@ -298,6 +283,7 @@ files:
|
|
298
283
|
- test/app/helpers/admin/sidebar_helper_test.rb
|
299
284
|
- test/app/helpers/admin/table_helper_test.rb
|
300
285
|
- test/app/mailers/admin/mailer_test.rb
|
286
|
+
- test/app/models/admin_user_test.rb
|
301
287
|
- test/app/models/typus_user_roles_test.rb
|
302
288
|
- test/app/models/typus_user_test.rb
|
303
289
|
- test/config/routes_test.rb
|
@@ -334,6 +320,7 @@ files:
|
|
334
320
|
- test/fixtures/rails_app/app/controllers/admin/comments_controller.rb
|
335
321
|
- test/fixtures/rails_app/app/controllers/admin/dogs_controller.rb
|
336
322
|
- test/fixtures/rails_app/app/controllers/admin/entries_controller.rb
|
323
|
+
- test/fixtures/rails_app/app/controllers/admin/hits_controller.rb
|
337
324
|
- test/fixtures/rails_app/app/controllers/admin/image_holders_controller.rb
|
338
325
|
- test/fixtures/rails_app/app/controllers/admin/invoices_controller.rb
|
339
326
|
- test/fixtures/rails_app/app/controllers/admin/orders_controller.rb
|
@@ -346,6 +333,7 @@ files:
|
|
346
333
|
- test/fixtures/rails_app/app/controllers/admin/users_controller.rb
|
347
334
|
- test/fixtures/rails_app/app/controllers/admin/views_controller.rb
|
348
335
|
- test/fixtures/rails_app/app/controllers/admin/watch_dog_controller.rb
|
336
|
+
- test/fixtures/rails_app/app/controllers/admin_user.rb
|
349
337
|
- test/fixtures/rails_app/app/controllers/application_controller.rb
|
350
338
|
- test/fixtures/rails_app/app/helpers/application_helper.rb
|
351
339
|
- test/fixtures/rails_app/app/helpers/form_helper.rb
|
@@ -359,6 +347,7 @@ files:
|
|
359
347
|
- test/fixtures/rails_app/app/models/delayed/task.rb
|
360
348
|
- test/fixtures/rails_app/app/models/dog.rb
|
361
349
|
- test/fixtures/rails_app/app/models/entry.rb
|
350
|
+
- test/fixtures/rails_app/app/models/hit.rb
|
362
351
|
- test/fixtures/rails_app/app/models/image_holder.rb
|
363
352
|
- test/fixtures/rails_app/app/models/invoice.rb
|
364
353
|
- test/fixtures/rails_app/app/models/order.rb
|
@@ -374,6 +363,9 @@ files:
|
|
374
363
|
- test/fixtures/rails_app/app/views/admin/categories/_index.html.erb
|
375
364
|
- test/fixtures/rails_app/app/views/admin/dashboard/_sidebar.html.erb
|
376
365
|
- test/fixtures/rails_app/app/views/admin/entries/_index.html.erb
|
366
|
+
- test/fixtures/rails_app/app/views/admin/hits/_edit.html.erb
|
367
|
+
- test/fixtures/rails_app/app/views/admin/hits/_index.html.erb
|
368
|
+
- test/fixtures/rails_app/app/views/admin/hits/index.html.erb
|
377
369
|
- test/fixtures/rails_app/app/views/admin/pages/_index.html.erb
|
378
370
|
- test/fixtures/rails_app/app/views/admin/posts/_edit.html.erb
|
379
371
|
- test/fixtures/rails_app/app/views/admin/posts/_index.html.erb
|
@@ -402,6 +394,7 @@ files:
|
|
402
394
|
- test/fixtures/rails_app/config/initializers/typus.rb
|
403
395
|
- test/fixtures/rails_app/config/initializers/typus_resources.rb
|
404
396
|
- test/fixtures/rails_app/config/locales/en.yml
|
397
|
+
- test/fixtures/rails_app/config/mongoid.yml
|
405
398
|
- test/fixtures/rails_app/config/routes.rb
|
406
399
|
- test/fixtures/rails_app/config/typus/README
|
407
400
|
- test/fixtures/rails_app/config/typus/crud_basic.yml
|
@@ -414,6 +407,8 @@ files:
|
|
414
407
|
- test/fixtures/rails_app/config/typus/has_many_through_roles.yml
|
415
408
|
- test/fixtures/rails_app/config/typus/has_one.yml
|
416
409
|
- test/fixtures/rails_app/config/typus/has_one_roles.yml
|
410
|
+
- test/fixtures/rails_app/config/typus/mongo_db.yml
|
411
|
+
- test/fixtures/rails_app/config/typus/mongo_db_roles.yml
|
417
412
|
- test/fixtures/rails_app/config/typus/polymorphic.yml
|
418
413
|
- test/fixtures/rails_app/config/typus/polymorphic_roles.yml
|
419
414
|
- test/fixtures/rails_app/config/typus/resource_roles.yml
|
@@ -436,12 +431,6 @@ files:
|
|
436
431
|
- test/fixtures/rails_app/public/500.html
|
437
432
|
- test/fixtures/rails_app/public/favicon.ico
|
438
433
|
- test/fixtures/rails_app/public/images/rails.png
|
439
|
-
- test/fixtures/rails_app/public/javascripts/application.js
|
440
|
-
- test/fixtures/rails_app/public/javascripts/controls.js
|
441
|
-
- test/fixtures/rails_app/public/javascripts/dragdrop.js
|
442
|
-
- test/fixtures/rails_app/public/javascripts/effects.js
|
443
|
-
- test/fixtures/rails_app/public/javascripts/prototype.js
|
444
|
-
- test/fixtures/rails_app/public/javascripts/rails.js
|
445
434
|
- test/fixtures/rails_app/public/robots.txt
|
446
435
|
- test/fixtures/rails_app/public/stylesheets/.gitkeep
|
447
436
|
- test/fixtures/rails_app/public/vendor/jquery-ui-1.8.9.custom/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png
|
@@ -529,23 +518,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
529
518
|
requirements:
|
530
519
|
- - ">="
|
531
520
|
- !ruby/object:Gem::Version
|
532
|
-
hash: 3
|
533
|
-
segments:
|
534
|
-
- 0
|
535
521
|
version: "0"
|
536
522
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
537
523
|
none: false
|
538
524
|
requirements:
|
539
525
|
- - ">="
|
540
526
|
- !ruby/object:Gem::Version
|
541
|
-
hash: 3
|
542
|
-
segments:
|
543
|
-
- 0
|
544
527
|
version: "0"
|
545
528
|
requirements: []
|
546
529
|
|
547
530
|
rubyforge_project: typus
|
548
|
-
rubygems_version: 1.
|
531
|
+
rubygems_version: 1.6.1
|
549
532
|
signing_key:
|
550
533
|
specification_version: 3
|
551
534
|
summary: Effortless backend interface for Ruby on Rails applications. (Admin scaffold generator)
|
@@ -580,6 +563,7 @@ test_files:
|
|
580
563
|
- test/app/helpers/admin/sidebar_helper_test.rb
|
581
564
|
- test/app/helpers/admin/table_helper_test.rb
|
582
565
|
- test/app/mailers/admin/mailer_test.rb
|
566
|
+
- test/app/models/admin_user_test.rb
|
583
567
|
- test/app/models/typus_user_roles_test.rb
|
584
568
|
- test/app/models/typus_user_test.rb
|
585
569
|
- test/config/routes_test.rb
|
@@ -616,6 +600,7 @@ test_files:
|
|
616
600
|
- test/fixtures/rails_app/app/controllers/admin/comments_controller.rb
|
617
601
|
- test/fixtures/rails_app/app/controllers/admin/dogs_controller.rb
|
618
602
|
- test/fixtures/rails_app/app/controllers/admin/entries_controller.rb
|
603
|
+
- test/fixtures/rails_app/app/controllers/admin/hits_controller.rb
|
619
604
|
- test/fixtures/rails_app/app/controllers/admin/image_holders_controller.rb
|
620
605
|
- test/fixtures/rails_app/app/controllers/admin/invoices_controller.rb
|
621
606
|
- test/fixtures/rails_app/app/controllers/admin/orders_controller.rb
|
@@ -628,6 +613,7 @@ test_files:
|
|
628
613
|
- test/fixtures/rails_app/app/controllers/admin/users_controller.rb
|
629
614
|
- test/fixtures/rails_app/app/controllers/admin/views_controller.rb
|
630
615
|
- test/fixtures/rails_app/app/controllers/admin/watch_dog_controller.rb
|
616
|
+
- test/fixtures/rails_app/app/controllers/admin_user.rb
|
631
617
|
- test/fixtures/rails_app/app/controllers/application_controller.rb
|
632
618
|
- test/fixtures/rails_app/app/helpers/application_helper.rb
|
633
619
|
- test/fixtures/rails_app/app/helpers/form_helper.rb
|
@@ -641,6 +627,7 @@ test_files:
|
|
641
627
|
- test/fixtures/rails_app/app/models/delayed/task.rb
|
642
628
|
- test/fixtures/rails_app/app/models/dog.rb
|
643
629
|
- test/fixtures/rails_app/app/models/entry.rb
|
630
|
+
- test/fixtures/rails_app/app/models/hit.rb
|
644
631
|
- test/fixtures/rails_app/app/models/image_holder.rb
|
645
632
|
- test/fixtures/rails_app/app/models/invoice.rb
|
646
633
|
- test/fixtures/rails_app/app/models/order.rb
|
@@ -656,6 +643,9 @@ test_files:
|
|
656
643
|
- test/fixtures/rails_app/app/views/admin/categories/_index.html.erb
|
657
644
|
- test/fixtures/rails_app/app/views/admin/dashboard/_sidebar.html.erb
|
658
645
|
- test/fixtures/rails_app/app/views/admin/entries/_index.html.erb
|
646
|
+
- test/fixtures/rails_app/app/views/admin/hits/_edit.html.erb
|
647
|
+
- test/fixtures/rails_app/app/views/admin/hits/_index.html.erb
|
648
|
+
- test/fixtures/rails_app/app/views/admin/hits/index.html.erb
|
659
649
|
- test/fixtures/rails_app/app/views/admin/pages/_index.html.erb
|
660
650
|
- test/fixtures/rails_app/app/views/admin/posts/_edit.html.erb
|
661
651
|
- test/fixtures/rails_app/app/views/admin/posts/_index.html.erb
|
@@ -684,6 +674,7 @@ test_files:
|
|
684
674
|
- test/fixtures/rails_app/config/initializers/typus.rb
|
685
675
|
- test/fixtures/rails_app/config/initializers/typus_resources.rb
|
686
676
|
- test/fixtures/rails_app/config/locales/en.yml
|
677
|
+
- test/fixtures/rails_app/config/mongoid.yml
|
687
678
|
- test/fixtures/rails_app/config/routes.rb
|
688
679
|
- test/fixtures/rails_app/config/typus/README
|
689
680
|
- test/fixtures/rails_app/config/typus/crud_basic.yml
|
@@ -696,6 +687,8 @@ test_files:
|
|
696
687
|
- test/fixtures/rails_app/config/typus/has_many_through_roles.yml
|
697
688
|
- test/fixtures/rails_app/config/typus/has_one.yml
|
698
689
|
- test/fixtures/rails_app/config/typus/has_one_roles.yml
|
690
|
+
- test/fixtures/rails_app/config/typus/mongo_db.yml
|
691
|
+
- test/fixtures/rails_app/config/typus/mongo_db_roles.yml
|
699
692
|
- test/fixtures/rails_app/config/typus/polymorphic.yml
|
700
693
|
- test/fixtures/rails_app/config/typus/polymorphic_roles.yml
|
701
694
|
- test/fixtures/rails_app/config/typus/resource_roles.yml
|
@@ -718,12 +711,6 @@ test_files:
|
|
718
711
|
- test/fixtures/rails_app/public/500.html
|
719
712
|
- test/fixtures/rails_app/public/favicon.ico
|
720
713
|
- test/fixtures/rails_app/public/images/rails.png
|
721
|
-
- test/fixtures/rails_app/public/javascripts/application.js
|
722
|
-
- test/fixtures/rails_app/public/javascripts/controls.js
|
723
|
-
- test/fixtures/rails_app/public/javascripts/dragdrop.js
|
724
|
-
- test/fixtures/rails_app/public/javascripts/effects.js
|
725
|
-
- test/fixtures/rails_app/public/javascripts/prototype.js
|
726
|
-
- test/fixtures/rails_app/public/javascripts/rails.js
|
727
714
|
- test/fixtures/rails_app/public/robots.txt
|
728
715
|
- test/fixtures/rails_app/public/stylesheets/.gitkeep
|
729
716
|
- test/fixtures/rails_app/public/vendor/jquery-ui-1.8.9.custom/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png
|
@@ -1,157 +0,0 @@
|
|
1
|
-
module Typus
|
2
|
-
module Orm
|
3
|
-
module ActiveRecord
|
4
|
-
module User
|
5
|
-
|
6
|
-
def self.included(base)
|
7
|
-
base.extend(ClassMethods)
|
8
|
-
end
|
9
|
-
|
10
|
-
module ClassMethods
|
11
|
-
|
12
|
-
def enable_as_typus_user
|
13
|
-
|
14
|
-
extend ClassMethodsMixin
|
15
|
-
|
16
|
-
attr_accessor :password
|
17
|
-
attr_protected :status
|
18
|
-
|
19
|
-
validates :email,
|
20
|
-
:presence => true,
|
21
|
-
:uniqueness => true,
|
22
|
-
:format => { :with => Typus::Regex::Email }
|
23
|
-
|
24
|
-
validates :password,
|
25
|
-
:confirmation => { :if => :password_required? },
|
26
|
-
:presence => { :if => :password_required? }
|
27
|
-
|
28
|
-
validates_length_of :password, :within => 6..40, :if => :password_required?
|
29
|
-
|
30
|
-
validates :role, :presence => true
|
31
|
-
|
32
|
-
before_save :initialize_salt, :encrypt_password, :initialize_token
|
33
|
-
|
34
|
-
serialize :preferences
|
35
|
-
|
36
|
-
include InstanceMethods
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
module ClassMethodsMixin
|
43
|
-
|
44
|
-
def authenticate(email, password)
|
45
|
-
user = find_by_email_and_status(email, true)
|
46
|
-
user && user.authenticated?(password) ? user : nil
|
47
|
-
end
|
48
|
-
|
49
|
-
def generate(*args)
|
50
|
-
options = args.extract_options!
|
51
|
-
|
52
|
-
options[:password] ||= ActiveSupport::SecureRandom.hex(4)
|
53
|
-
options[:role] ||= Typus.master_role
|
54
|
-
|
55
|
-
new :email => options[:email],
|
56
|
-
:password => options[:password],
|
57
|
-
:password_confirmation => options[:password],
|
58
|
-
:role => options[:role],
|
59
|
-
:preferences => { :locale => ::I18n.default_locale.to_s }
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
module InstanceMethods
|
65
|
-
|
66
|
-
def name
|
67
|
-
full_name = [first_name, last_name].delete_if { |s| s.blank? }
|
68
|
-
full_name.any? ? full_name.join(" ") : email
|
69
|
-
end
|
70
|
-
|
71
|
-
def authenticated?(password)
|
72
|
-
crypted_password == encrypt(password)
|
73
|
-
end
|
74
|
-
|
75
|
-
def resources
|
76
|
-
Typus::Configuration.roles[role].compact
|
77
|
-
end
|
78
|
-
|
79
|
-
def applications
|
80
|
-
Typus.applications.delete_if { |a| application(a).empty? }
|
81
|
-
end
|
82
|
-
|
83
|
-
def application(name)
|
84
|
-
Typus.application(name).delete_if { |r| !resources.keys.include?(r) }
|
85
|
-
end
|
86
|
-
|
87
|
-
def can?(action, resource, options = {})
|
88
|
-
resource = resource.model_name if resource.is_a?(Class)
|
89
|
-
|
90
|
-
return false if !resources.include?(resource)
|
91
|
-
return true if resources[resource].include?("all")
|
92
|
-
|
93
|
-
action = options[:special] ? action : action.acl_action_mapper
|
94
|
-
|
95
|
-
resources[resource].extract_settings.include?(action)
|
96
|
-
end
|
97
|
-
|
98
|
-
def cannot?(*args)
|
99
|
-
!can?(*args)
|
100
|
-
end
|
101
|
-
|
102
|
-
def is_root?
|
103
|
-
role == Typus.master_role
|
104
|
-
end
|
105
|
-
|
106
|
-
def is_not_root?
|
107
|
-
!is_root?
|
108
|
-
end
|
109
|
-
|
110
|
-
def locale
|
111
|
-
(preferences && preferences[:locale]) ? preferences[:locale] : ::I18n.default_locale
|
112
|
-
end
|
113
|
-
|
114
|
-
def locale=(locale)
|
115
|
-
options = { :locale => locale }
|
116
|
-
self.preferences ||= {}
|
117
|
-
self.preferences[:locale] = locale
|
118
|
-
end
|
119
|
-
|
120
|
-
protected
|
121
|
-
|
122
|
-
# TODO: Update the hash generation by a harder one ...
|
123
|
-
def generate_hash(string)
|
124
|
-
Digest::SHA1.hexdigest(string)
|
125
|
-
end
|
126
|
-
|
127
|
-
def encrypt_password
|
128
|
-
return if password.blank?
|
129
|
-
self.crypted_password = encrypt(password)
|
130
|
-
end
|
131
|
-
|
132
|
-
def encrypt(string)
|
133
|
-
generate_hash("--#{salt}--#{string}--")
|
134
|
-
end
|
135
|
-
|
136
|
-
def initialize_salt
|
137
|
-
self.salt = generate_hash("--#{Time.zone.now.to_s(:number)}--#{email}--") if new_record?
|
138
|
-
end
|
139
|
-
|
140
|
-
def initialize_token
|
141
|
-
generate_token if new_record?
|
142
|
-
end
|
143
|
-
|
144
|
-
def generate_token
|
145
|
-
self.token = encrypt("--#{Time.zone.now.to_s(:number)}--#{password}--").first(12)
|
146
|
-
end
|
147
|
-
|
148
|
-
def password_required?
|
149
|
-
crypted_password.blank? || !password.blank?
|
150
|
-
end
|
151
|
-
|
152
|
-
end
|
153
|
-
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|