typus 3.0.6 → 3.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/.gitignore +15 -0
- data/Gemfile +9 -5
- data/Rakefile +34 -21
- data/app/controllers/admin/base_controller.rb +0 -4
- data/app/controllers/admin/resources_controller.rb +77 -213
- data/app/controllers/admin/session_controller.rb +1 -1
- data/app/helpers/admin/base_helper.rb +4 -4
- data/app/helpers/admin/dashboard_helper.rb +1 -3
- data/app/helpers/admin/display_helper.rb +49 -0
- data/app/helpers/admin/file_preview_helper.rb +10 -12
- data/app/helpers/admin/filters_helper.rb +1 -1
- data/app/helpers/admin/form_helper.rb +2 -13
- data/app/helpers/admin/list_helper.rb +14 -3
- data/app/helpers/admin/relationships_helper.rb +79 -62
- data/app/helpers/admin/resources_helper.rb +17 -16
- data/app/helpers/admin/search_helper.rb +1 -1
- data/app/helpers/admin/sidebar_helper.rb +1 -2
- data/app/helpers/admin/table_helper.rb +9 -4
- data/app/views/admin/helpers/_file_preview.html.erb +1 -1
- data/app/views/admin/helpers/base/_apps.html.erb +23 -0
- data/app/views/admin/helpers/{_flash_message.html.erb → base/_flash_message.html.erb} +0 -0
- data/app/views/admin/helpers/{_header.html.erb → base/_header.html.erb} +0 -0
- data/app/views/admin/helpers/{_login_info.html.erb → base/_login_info.html.erb} +0 -0
- data/app/views/admin/helpers/resources/_display_link_to_previous.html.erb +1 -1
- data/app/views/admin/resources/show.html.erb +4 -27
- data/app/views/admin/templates/_belongs_to_with_autocomplete.html.erb +11 -0
- data/app/views/admin/templates/_has_n.html.erb +1 -1
- data/app/views/admin/templates/_has_one.html.erb +3 -3
- data/app/views/admin/templates/_relate_form.html.erb +1 -1
- data/app/views/admin/templates/_relate_form_with_autocomplete.html.erb +24 -0
- data/app/views/layouts/admin/base.html.erb +15 -9
- data/app/views/layouts/admin/headless.html.erb +44 -0
- data/app/views/layouts/admin/session.html.erb +3 -2
- data/doc/hudson_setup.md +19 -0
- data/lib/generators/typus/assets_generator.rb +0 -4
- data/lib/generators/typus/config_generator.rb +107 -0
- data/lib/generators/typus/controller_generator.rb +0 -4
- data/lib/generators/typus/initializers_generator.rb +22 -0
- data/lib/generators/typus/migration_generator.rb +0 -4
- data/lib/generators/typus/typus_generator.rb +8 -101
- data/lib/generators/typus/views_generator.rb +0 -4
- data/lib/support/active_record.rb +8 -2
- data/lib/support/fake_user.rb +2 -0
- data/lib/support/hash.rb +1 -1
- data/lib/support/string.rb +3 -3
- data/lib/tasks/typus.rake +1 -1
- data/lib/typus.rb +15 -6
- data/lib/typus/controller/actions.rb +69 -0
- data/lib/typus/controller/associations.rb +82 -0
- data/lib/typus/controller/autocomplete.rb +16 -0
- data/lib/typus/controller/filters.rb +24 -0
- data/lib/typus/controller/format.rb +70 -0
- data/lib/typus/orm/active_record.rb +9 -240
- data/lib/typus/orm/active_record/class_methods.rb +227 -0
- data/lib/typus/orm/active_record/instance_methods.rb +13 -0
- data/lib/typus/orm/active_record/search.rb +17 -5
- data/lib/typus/orm/active_record/user.rb +157 -0
- data/lib/typus/regex.rb +11 -0
- data/lib/typus/version.rb +1 -1
- data/test/app/controllers/admin/account_controller_test.rb +104 -0
- data/test/app/controllers/admin/assets_controller_test.rb +153 -0
- data/test/app/controllers/admin/base_controller_test.rb +41 -0
- data/test/app/controllers/admin/birds_controller_test.rb +42 -0
- data/test/app/controllers/admin/cases_controller_test.rb +21 -0
- data/test/app/controllers/admin/categories_controller_test.rb +141 -0
- data/test/app/controllers/admin/comments_controller_test.rb +79 -0
- data/test/app/controllers/admin/dashboard_controller_test.rb +162 -0
- data/test/app/controllers/admin/image_holders_controller_test.rb +75 -0
- data/test/app/controllers/admin/invoices_controller_test.rb +78 -0
- data/test/app/controllers/admin/orders_controller_test.rb +18 -0
- data/test/app/controllers/admin/pages_controller_test.rb +37 -0
- data/test/app/controllers/admin/posts_controller_test.rb +745 -0
- data/test/app/controllers/admin/projects_controller_test.rb +52 -0
- data/test/app/controllers/admin/session_controller_test.rb +92 -0
- data/test/app/controllers/admin/status_controller_test.rb +54 -0
- data/test/app/controllers/admin/typus_users_controller_test.rb +160 -0
- data/test/app/controllers/admin/users_controller_test.rb +106 -0
- data/test/app/helpers/admin/base_helper_test.rb +83 -0
- data/test/app/helpers/admin/dashboard_helper_test.rb +32 -0
- data/test/app/helpers/admin/file_preview_helper_test.rb +82 -0
- data/test/app/helpers/admin/filters_helper_test.rb +161 -0
- data/test/app/helpers/admin/form_helper_test.rb +126 -0
- data/test/app/helpers/admin/list_helper_test.rb +59 -0
- data/test/app/helpers/admin/relationships_helper_test.rb +19 -0
- data/test/app/helpers/admin/resources_helper_test.rb +46 -0
- data/test/app/helpers/admin/search_helper_test.rb +60 -0
- data/test/app/helpers/admin/sidebar_helper_test.rb +34 -0
- data/test/app/helpers/admin/table_helper_test.rb +215 -0
- data/test/app/mailers/admin/mailer_test.rb +32 -0
- data/test/app/models/typus_user_roles_test.rb +124 -0
- data/test/app/models/typus_user_test.rb +194 -0
- data/test/config/routes_test.rb +29 -0
- data/test/factories.rb +111 -0
- data/test/fixtures/config/broken/application.yml +68 -0
- data/test/fixtures/config/broken/application_roles.yml +20 -0
- data/test/fixtures/config/broken/empty.yml +0 -0
- data/test/fixtures/config/broken/empty_roles.yml +0 -0
- data/test/fixtures/config/broken/undefined.yml +3 -0
- data/test/fixtures/config/broken/undefined_roles.yml +6 -0
- data/test/fixtures/config/default/typus.yml +13 -0
- data/test/fixtures/config/default/typus_roles.yml +2 -0
- data/test/fixtures/config/empty/empty_01.yml +0 -0
- data/test/fixtures/config/empty/empty_01_roles.yml +0 -0
- data/test/fixtures/config/empty/empty_02.yml +0 -0
- data/test/fixtures/config/empty/empty_02_roles.yml +0 -0
- data/test/fixtures/config/locales/es.yml +10 -0
- data/test/fixtures/config/namespaced/application.yml +5 -0
- data/test/fixtures/config/namespaced/application_roles.yml +2 -0
- data/test/fixtures/config/ordered/001_roles.yml +2 -0
- data/test/fixtures/config/ordered/002_roles.yml +2 -0
- data/test/fixtures/config/unordered/app_one_roles.yml +2 -0
- data/test/fixtures/config/unordered/app_two_roles.yml +2 -0
- data/test/fixtures/rails_app/.gitignore +4 -0
- data/test/fixtures/rails_app/Capfile +6 -0
- data/test/fixtures/rails_app/README +256 -0
- data/test/fixtures/rails_app/Rakefile +7 -0
- data/test/fixtures/rails_app/app/controllers/admin/animals_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/articles_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/assets_controller.rb +51 -0
- data/test/fixtures/rails_app/app/controllers/admin/birds_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/cases_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/categories_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/comments_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/dogs_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/entries_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/image_holders_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/invoices_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/orders_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/pages_controller.rb +7 -0
- data/test/fixtures/rails_app/app/controllers/admin/posts_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/project_collaborators_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/projects_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/status_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/typus_users_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/users_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/views_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/admin/watch_dog_controller.rb +2 -0
- data/test/fixtures/rails_app/app/controllers/application_controller.rb +3 -0
- data/test/fixtures/rails_app/app/helpers/application_helper.rb +2 -0
- data/test/fixtures/rails_app/app/helpers/form_helper.rb +3 -0
- data/test/fixtures/rails_app/app/models/animal.rb +21 -0
- data/test/fixtures/rails_app/app/models/article.rb +10 -0
- data/test/fixtures/rails_app/app/models/asset.rb +39 -0
- data/test/fixtures/rails_app/app/models/bird.rb +2 -0
- data/test/fixtures/rails_app/app/models/case.rb +2 -0
- data/test/fixtures/rails_app/app/models/category.rb +31 -0
- data/test/fixtures/rails_app/app/models/comment.rb +17 -0
- data/test/fixtures/rails_app/app/models/delayed/task.rb +5 -0
- data/test/fixtures/rails_app/app/models/dog.rb +2 -0
- data/test/fixtures/rails_app/app/models/entry.rb +23 -0
- data/test/fixtures/rails_app/app/models/image_holder.rb +21 -0
- data/test/fixtures/rails_app/app/models/invoice.rb +10 -0
- data/test/fixtures/rails_app/app/models/order.rb +9 -0
- data/test/fixtures/rails_app/app/models/page.rb +24 -0
- data/test/fixtures/rails_app/app/models/post.rb +32 -0
- data/test/fixtures/rails_app/app/models/project.rb +17 -0
- data/test/fixtures/rails_app/app/models/project_collaborator.rb +16 -0
- data/test/fixtures/rails_app/app/models/typus_user.rb +22 -0
- data/test/fixtures/rails_app/app/models/user.rb +10 -0
- data/test/fixtures/rails_app/app/models/view.rb +17 -0
- data/test/fixtures/rails_app/app/views/admin/assets/_index.html.erb +3 -0
- data/test/fixtures/rails_app/app/views/admin/cases/_index.html.erb +3 -0
- data/test/fixtures/rails_app/app/views/admin/categories/_index.html.erb +3 -0
- data/test/fixtures/rails_app/app/views/admin/dashboard/_sidebar.html.erb +11 -0
- data/test/fixtures/rails_app/app/views/admin/entries/_index.html.erb +3 -0
- data/test/fixtures/rails_app/app/views/admin/pages/_index.html.erb +3 -0
- data/test/fixtures/rails_app/app/views/admin/posts/_edit.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/posts/_index.html.erb +5 -0
- data/test/fixtures/rails_app/app/views/admin/posts/_new.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/posts/_show.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/resources/_sidebar.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/status/index.html.erb +9 -0
- data/test/fixtures/rails_app/app/views/admin/templates/_datepicker.html.erb +1 -0
- data/test/fixtures/rails_app/app/views/admin/watch_dog/index.html.erb +9 -0
- data/test/fixtures/rails_app/app/views/layouts/admin/headless.html.erb +38 -0
- data/test/fixtures/rails_app/config.ru +4 -0
- data/test/fixtures/rails_app/config/application.rb +44 -0
- data/test/fixtures/rails_app/config/boot.rb +13 -0
- data/test/fixtures/rails_app/config/database.yml +34 -0
- data/test/fixtures/rails_app/config/deploy.rb +32 -0
- data/test/fixtures/rails_app/config/environment.rb +5 -0
- data/test/fixtures/rails_app/config/environments/development.rb +32 -0
- data/test/fixtures/rails_app/config/environments/production.rb +54 -0
- data/test/fixtures/rails_app/config/environments/test.rb +40 -0
- data/test/fixtures/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/test/fixtures/rails_app/config/initializers/dragonfly.rb +1 -0
- data/test/fixtures/rails_app/config/initializers/inflections.rb +12 -0
- data/test/fixtures/rails_app/config/initializers/mime_types.rb +5 -0
- data/test/fixtures/rails_app/config/initializers/secret_token.rb +7 -0
- data/test/fixtures/rails_app/config/initializers/session_store.rb +8 -0
- data/test/fixtures/rails_app/config/initializers/typus.rb +5 -0
- data/test/fixtures/rails_app/config/initializers/typus_resources.rb +27 -0
- data/test/fixtures/rails_app/config/locales/en.yml +5 -0
- data/test/fixtures/rails_app/config/routes.rb +61 -0
- data/test/fixtures/rails_app/config/typus/README +68 -0
- data/test/fixtures/rails_app/config/typus/crud_basic.yml +10 -0
- data/test/fixtures/rails_app/config/typus/crud_basic_roles.yml +2 -0
- data/test/fixtures/rails_app/config/typus/crud_extended.yml +64 -0
- data/test/fixtures/rails_app/config/typus/crud_extended_roles.yml +18 -0
- data/test/fixtures/rails_app/config/typus/has_many.yml +0 -0
- data/test/fixtures/rails_app/config/typus/has_many_roles.yml +0 -0
- data/test/fixtures/rails_app/config/typus/has_many_through.yml +23 -0
- data/test/fixtures/rails_app/config/typus/has_many_through_roles.yml +4 -0
- data/test/fixtures/rails_app/config/typus/has_one.yml +12 -0
- data/test/fixtures/rails_app/config/typus/has_one_roles.yml +3 -0
- data/test/fixtures/rails_app/config/typus/polymorphic.yml +17 -0
- data/test/fixtures/rails_app/config/typus/polymorphic_roles.yml +5 -0
- data/test/fixtures/rails_app/config/typus/resource_roles.yml +7 -0
- data/test/fixtures/rails_app/config/typus/sti.yml +5 -0
- data/test/fixtures/rails_app/config/typus/sti_roles.yml +2 -0
- data/test/fixtures/rails_app/config/typus/typus.yml +13 -0
- data/test/fixtures/rails_app/config/typus/typus_roles.yml +2 -0
- data/test/fixtures/rails_app/config/typus/unknown.yml +3 -0
- data/test/fixtures/rails_app/config/typus/unknown_roles.yml +5 -0
- data/test/fixtures/rails_app/db/.gitkeep +0 -0
- data/test/fixtures/rails_app/db/schema.rb +174 -0
- data/test/fixtures/rails_app/db/seeds.rb +54 -0
- data/test/fixtures/rails_app/db/seeds/assets/000.jpg +0 -0
- data/test/fixtures/rails_app/db/seeds/assets/001.jpg +0 -0
- data/test/fixtures/rails_app/db/seeds/assets/002.jpg +0 -0
- data/test/fixtures/rails_app/db/seeds/assets/003.jpg +0 -0
- data/test/fixtures/rails_app/db/seeds/assets/004.jpg +0 -0
- data/test/fixtures/rails_app/public/404.html +26 -0
- data/test/fixtures/rails_app/public/422.html +26 -0
- data/test/fixtures/rails_app/public/500.html +26 -0
- data/test/fixtures/rails_app/public/favicon.ico +0 -0
- data/test/fixtures/rails_app/public/images/rails.png +0 -0
- data/test/fixtures/rails_app/public/javascripts/application.js +2 -0
- data/test/fixtures/rails_app/public/javascripts/controls.js +965 -0
- data/test/fixtures/rails_app/public/javascripts/dragdrop.js +974 -0
- data/test/fixtures/rails_app/public/javascripts/effects.js +1123 -0
- data/test/fixtures/rails_app/public/javascripts/prototype.js +6001 -0
- data/test/fixtures/rails_app/public/javascripts/rails.js +175 -0
- data/test/fixtures/rails_app/public/robots.txt +5 -0
- data/test/fixtures/rails_app/public/stylesheets/.gitkeep +0 -0
- data/test/fixtures/rails_app/script/rails +6 -0
- data/test/lib/support/active_record_test.rb +150 -0
- data/test/lib/support/fake_user_test.rb +59 -0
- data/test/lib/support/hash_test.rb +29 -0
- data/test/lib/support/object_test.rb +17 -0
- data/test/lib/support/string_test.rb +116 -0
- data/test/lib/typus/configuration_test.rb +46 -0
- data/test/lib/typus/controller/actions_test.rb +141 -0
- data/test/lib/typus/controller/associations_test.rb +7 -0
- data/test/lib/typus/controller/autocomplete_test.rb +7 -0
- data/test/lib/typus/controller/filters_test.rb +73 -0
- data/test/lib/typus/controller/format_test.rb +7 -0
- data/test/lib/typus/i18n_test.rb +9 -0
- data/test/lib/typus/orm/active_record/class_methods_test.rb +378 -0
- data/test/lib/typus/orm/active_record/search_test.rb +330 -0
- data/test/lib/typus/regex_test.rb +53 -0
- data/test/lib/typus/resources_test.rb +41 -0
- data/test/lib/typus_test.rb +141 -0
- data/test/test_helper.rb +15 -0
- data/typus.gemspec +25 -0
- metadata +586 -64
- data/Gemfile.lock +0 -149
- data/app/views/admin/helpers/_apps.html.erb +0 -9
- data/lib/generators/templates/public/admin/javascripts/application.js +0 -2
- data/lib/generators/templates/public/admin/javascripts/jquery-1.4.4.min.js +0 -167
- data/lib/generators/templates/public/admin/javascripts/jquery.application.js +0 -16
- data/lib/generators/templates/public/admin/javascripts/jquery.rails.js +0 -160
- data/lib/generators/templates/public/admin/javascripts/jquery.searchField.js +0 -91
- data/lib/generators/templates/public/admin/stylesheets/application.css +0 -11
- data/lib/generators/templates/public/admin/stylesheets/screen.css +0 -367
- data/lib/generators/templates/public/admin/vendor/fancybox/blank.gif +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_close.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_loading.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_nav_left.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_nav_right.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_e.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_n.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_ne.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_nw.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_s.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_se.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_sw.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_shadow_w.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_title_left.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_title_main.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_title_over.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancy_title_right.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancybox-x.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancybox-y.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/fancybox.png +0 -0
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.easing-1.3.pack.js +0 -72
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.4.css +0 -359
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.4.js +0 -1156
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.4.pack.js +0 -46
- data/lib/generators/templates/public/admin/vendor/fancybox/jquery.mousewheel-3.0.4.pack.js +0 -14
- data/lib/typus/actions.rb +0 -41
- data/lib/typus/filters.rb +0 -12
- data/lib/typus/format.rb +0 -70
- data/lib/typus/user.rb +0 -157
data/.gemtest
ADDED
File without changes
|
data/.gitignore
ADDED
data/Gemfile
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
-
source
|
1
|
+
source "http://rubygems.org"
|
2
2
|
|
3
|
+
# Specify your gem's dependencies in typus.gemspec
|
3
4
|
gemspec
|
4
5
|
|
6
|
+
# Yes, some dependencies are in typus.gemspec, but it's a little bit difficult
|
7
|
+
# to mantain the above code there. I'll keep here for the moment ...
|
8
|
+
|
5
9
|
gem 'acts_as_list'
|
6
10
|
gem 'acts_as_tree'
|
7
11
|
gem 'dragonfly', '~>0.8.1'
|
@@ -12,19 +16,19 @@ gem 'rails', '~> 3.0'
|
|
12
16
|
|
13
17
|
group :test do
|
14
18
|
gem 'shoulda'
|
15
|
-
gem '
|
16
|
-
|
17
|
-
gem 'mocha'
|
19
|
+
gem 'mocha' # Make sure mocha is loaded at the end ...
|
18
20
|
end
|
19
21
|
|
20
22
|
group :development, :test do
|
21
23
|
|
22
24
|
platforms :jruby do
|
23
25
|
gem 'activerecord-jdbc-adapter', :require => false
|
24
|
-
|
26
|
+
|
25
27
|
gem 'jdbc-mysql'
|
26
28
|
gem 'jdbc-postgres'
|
27
29
|
gem 'jdbc-sqlite3'
|
30
|
+
|
31
|
+
gem 'jruby-openssl' # JRuby limited openssl loaded. http://jruby.org/openssl
|
28
32
|
end
|
29
33
|
|
30
34
|
platforms :ruby do
|
data/Rakefile
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
1
4
|
require 'rubygems'
|
2
5
|
require 'rake/testtask'
|
3
6
|
require 'rake/rdoctask'
|
4
7
|
|
5
|
-
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
6
|
-
require 'typus/version'
|
7
|
-
|
8
|
-
desc 'Default: run unit tests.'
|
9
8
|
task :default => :test
|
10
9
|
|
11
10
|
desc 'Test the typus plugin.'
|
@@ -16,6 +15,7 @@ Rake::TestTask.new(:test) do |t|
|
|
16
15
|
t.verbose = true
|
17
16
|
end
|
18
17
|
|
18
|
+
=begin
|
19
19
|
desc 'Generate plugin documentation.'
|
20
20
|
Rake::RDocTask.new(:rdoc) do |rdoc|
|
21
21
|
rdoc.rdoc_dir = 'rdoc'
|
@@ -24,26 +24,39 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
24
24
|
rdoc.rdoc_files.include('README.rdoc')
|
25
25
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
26
26
|
end
|
27
|
+
=end
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
system "gem build typus.gemspec"
|
31
|
-
system "gem install typus-#{Typus::VERSION}.gem"
|
29
|
+
task :deploy do
|
30
|
+
system "cd test/fixtures/rails_app && cap deploy"
|
32
31
|
end
|
33
32
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
33
|
+
RUBIES = ["ruby-1.8.7-p330", "ruby-1.9.2-p136", "ree-1.8.7-2010.02", "jruby-1.5.6"]
|
34
|
+
|
35
|
+
namespace :setup do
|
36
|
+
|
37
|
+
desc "Setup test environment"
|
38
|
+
task :test_environment do
|
39
|
+
RUBIES.each { |ruby| system "rvm install #{ruby}" }
|
40
|
+
end
|
41
|
+
|
42
|
+
desc "Setup CI Joe"
|
43
|
+
task :cijoe do
|
44
|
+
system "git config --replace-all cijoe.runner 'rake test:all'"
|
45
|
+
end
|
46
|
+
|
44
47
|
end
|
45
48
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
+
namespace :test do
|
50
|
+
|
51
|
+
task :all do
|
52
|
+
RUBIES.each do |ruby|
|
53
|
+
system "rvm use #{ruby}"
|
54
|
+
system "rm -f Gemfile.lock"
|
55
|
+
system "bundle install"
|
56
|
+
system "rake"
|
57
|
+
# system "rake DB=postgresql"
|
58
|
+
# system "rake DB=mysql"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
49
62
|
end
|
@@ -1,18 +1,18 @@
|
|
1
1
|
class Admin::ResourcesController < Admin::BaseController
|
2
2
|
|
3
|
-
include Typus::Actions
|
4
|
-
include Typus::
|
5
|
-
include Typus::
|
3
|
+
include Typus::Controller::Actions
|
4
|
+
include Typus::Controller::Associations
|
5
|
+
include Typus::Controller::Autocomplete
|
6
|
+
include Typus::Controller::Filters
|
7
|
+
include Typus::Controller::Format
|
6
8
|
|
7
9
|
before_filter :get_model
|
8
10
|
before_filter :set_scope
|
9
|
-
before_filter :get_object, :only => [:show, :edit, :update, :destroy, :toggle, :position, :relate, :unrelate
|
11
|
+
before_filter :get_object, :only => [:show, :edit, :update, :destroy, :toggle, :position, :relate, :unrelate]
|
10
12
|
before_filter :check_resource_ownership, :only => [:edit, :update, :destroy, :toggle, :position, :relate, :unrelate ]
|
11
13
|
before_filter :check_if_user_can_perform_action_on_resources
|
12
14
|
before_filter :set_order, :only => [:index]
|
13
|
-
before_filter :set_fields, :only => [:index, :new, :edit, :create, :update, :show
|
14
|
-
|
15
|
-
before_filter :check_if_we_can_add_a_new_item, :only => [:new, :create]
|
15
|
+
before_filter :set_fields, :only => [:index, :new, :edit, :create, :update, :show]
|
16
16
|
|
17
17
|
##
|
18
18
|
# This is the main index of the model. With filters, conditions and more.
|
@@ -21,13 +21,15 @@ class Admin::ResourcesController < Admin::BaseController
|
|
21
21
|
# your formats.
|
22
22
|
#
|
23
23
|
def index
|
24
|
-
add_resource_action(default_action.titleize, {:action => default_action}, {})
|
25
|
-
add_resource_action("Trash", {:action => "destroy"}, {:confirm => "#{Typus::I18n.t("Trash")}?", :method => 'delete'})
|
26
|
-
|
27
24
|
get_objects
|
28
25
|
|
29
26
|
respond_to do |format|
|
30
|
-
format.html
|
27
|
+
format.html do
|
28
|
+
prepend_predefined_filter("All", "index", "unscoped")
|
29
|
+
add_resource_action(default_action.titleize, {:action => default_action}, {})
|
30
|
+
add_resource_action("Trash", {:action => "destroy"}, {:confirm => "#{Typus::I18n.t("Trash")}?", :method => 'delete'})
|
31
|
+
generate_html
|
32
|
+
end
|
31
33
|
@resource.typus_export_formats.each { |f| format.send(f) { send("generate_#{f}") } }
|
32
34
|
end
|
33
35
|
end
|
@@ -36,6 +38,11 @@ class Admin::ResourcesController < Admin::BaseController
|
|
36
38
|
item_params = params.dup
|
37
39
|
item_params.delete_if { |k, v| !@resource.columns.map(&:name).include?(k) }
|
38
40
|
@item = @resource.new(item_params)
|
41
|
+
|
42
|
+
respond_to do |format|
|
43
|
+
format.html # new.html.erb
|
44
|
+
format.json { render :json => @item }
|
45
|
+
end
|
39
46
|
end
|
40
47
|
|
41
48
|
##
|
@@ -48,63 +55,76 @@ class Admin::ResourcesController < Admin::BaseController
|
|
48
55
|
|
49
56
|
set_attributes_on_create
|
50
57
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
58
|
+
respond_to do |format|
|
59
|
+
if @item.save
|
60
|
+
format.html do
|
61
|
+
params[:resource] ? create_with_back_to : redirect_on_success
|
62
|
+
end
|
63
|
+
format.json { render :json => @item, :status => :created, :location => @item }
|
64
|
+
else
|
65
|
+
format.html { render :action => "new" }
|
66
|
+
format.json { render :json => @item.errors, :status => :unprocessable_entity }
|
67
|
+
end
|
55
68
|
end
|
56
69
|
end
|
57
70
|
|
58
71
|
def edit
|
59
|
-
add_resource_action(default_action.titleize, {:action => default_action}, {})
|
60
|
-
add_resource_action("Unrelate", {:action => "unrelate", :resource => @resource.model_name, :resource_id => @item.id}, {:confirm => "#{Typus::I18n.t("Unrelate")}?"})
|
61
72
|
end
|
62
73
|
|
63
74
|
def show
|
64
75
|
check_resource_ownership if @resource.typus_options_for(:only_user_items)
|
76
|
+
|
77
|
+
=begin
|
78
|
+
# FIXME
|
79
|
+
respond_to do |format|
|
80
|
+
format.html # show.html.erb
|
81
|
+
format.json { render :json => @item }
|
82
|
+
end
|
83
|
+
=end
|
65
84
|
end
|
66
85
|
|
67
86
|
def update
|
87
|
+
attributes = params[:attribute] ? { params[:attribute] => nil } : params[@object_name]
|
88
|
+
|
68
89
|
respond_to do |format|
|
69
|
-
if @item.update_attributes(
|
90
|
+
if @item.update_attributes(attributes)
|
70
91
|
set_attributes_on_update
|
71
92
|
reload_locales
|
72
93
|
format.html { redirect_on_success }
|
73
94
|
format.json { render :json => @item }
|
74
95
|
else
|
75
96
|
format.html { render :edit }
|
76
|
-
format.json { render :json => @item.errors
|
97
|
+
format.json { render :json => @item.errors, :status => :unprocessable_entity }
|
77
98
|
end
|
78
99
|
end
|
79
100
|
end
|
80
101
|
|
81
|
-
def detach
|
82
|
-
if @item.update_attributes(params[:attribute] => nil)
|
83
|
-
notice = Typus::I18n.t("%{model} successfully updated.", :model => @resource.model_name.human)
|
84
|
-
redirect_to :back, :notice => notice
|
85
|
-
else
|
86
|
-
render :edit
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
102
|
def destroy
|
91
103
|
if @item.destroy
|
92
104
|
notice = Typus::I18n.t("%{model} successfully removed.", :model => @resource.model_name.human)
|
93
105
|
else
|
94
106
|
alert = @item.errors.full_messages
|
95
107
|
end
|
96
|
-
redirect_to
|
108
|
+
redirect_to :back, :notice => notice, :alert => alert
|
97
109
|
end
|
98
110
|
|
99
111
|
def toggle
|
100
112
|
@item.toggle(params[:field])
|
101
|
-
@item.save!
|
102
|
-
|
103
|
-
notice = Typus::I18n.t("%{model} successfully updated.", :model => @resource.model_name.human)
|
104
113
|
|
105
114
|
respond_to do |format|
|
106
|
-
|
107
|
-
|
115
|
+
if @item.save
|
116
|
+
format.html do
|
117
|
+
notice = Typus::I18n.t("%{model} successfully updated.", :model => @resource.model_name.human)
|
118
|
+
redirect_to :back, :notice => notice
|
119
|
+
end
|
120
|
+
format.json { render :json => @item }
|
121
|
+
else
|
122
|
+
format.html do
|
123
|
+
set_fields
|
124
|
+
render :edit
|
125
|
+
end
|
126
|
+
format.json { render :json => @item.errors, :status => :unprocessable_entity }
|
127
|
+
end
|
108
128
|
end
|
109
129
|
end
|
110
130
|
|
@@ -120,7 +140,7 @@ class Admin::ResourcesController < Admin::BaseController
|
|
120
140
|
def position
|
121
141
|
@item.send(params[:go])
|
122
142
|
notice = Typus::I18n.t("%{model} successfully updated.", :model => @resource.model_name.human)
|
123
|
-
redirect_to
|
143
|
+
redirect_to :back, :notice => notice
|
124
144
|
end
|
125
145
|
|
126
146
|
##
|
@@ -151,10 +171,10 @@ class Admin::ResourcesController < Admin::BaseController
|
|
151
171
|
association_name = params[:related][:association_name].tableize
|
152
172
|
|
153
173
|
if @item.send(association_name) << resource_class.find(params[:related][:id])
|
154
|
-
|
174
|
+
notice = Typus::I18n.t("%{model} successfully updated.", :model => @resource.model_name.human)
|
155
175
|
end
|
156
176
|
|
157
|
-
redirect_to
|
177
|
+
redirect_to :back, :notice => notice
|
158
178
|
end
|
159
179
|
|
160
180
|
##
|
@@ -165,44 +185,25 @@ class Admin::ResourcesController < Admin::BaseController
|
|
165
185
|
# - has_one
|
166
186
|
#
|
167
187
|
def unrelate
|
168
|
-
|
169
|
-
##
|
170
|
-
# Find the remote object which is named item!
|
171
|
-
#
|
172
|
-
|
173
188
|
item_class = params[:resource].typus_constantize
|
174
189
|
item = item_class.find(params[:resource_id])
|
175
190
|
|
176
|
-
##
|
177
|
-
# Detect which kind of relationship there's between both models.
|
178
|
-
#
|
179
|
-
# item respect @item
|
180
|
-
#
|
181
|
-
|
182
|
-
# This is not nil in case of a has_many :through association.
|
183
|
-
association_name = params[:association_name].to_sym unless params[:association_name].blank?
|
184
|
-
|
185
191
|
case item_class.relationship_with(@resource)
|
186
192
|
when :has_one
|
187
193
|
association_name = @resource.model_name.underscore.to_sym
|
188
194
|
worked = item.send(association_name).delete
|
189
195
|
else
|
190
|
-
association_name
|
196
|
+
association_name = params[:association_name] ? params[:association_name].to_sym : @resource.model_name.tableize.to_sym
|
191
197
|
worked = item.send(association_name).delete(@item)
|
192
198
|
end
|
193
199
|
|
194
|
-
##
|
195
|
-
# Finally delete the associated object. Depending on your models setup
|
196
|
-
# associated models will be removed or foreign_key will be set to nil.
|
197
|
-
#
|
198
|
-
|
199
200
|
if worked
|
200
201
|
notice = Typus::I18n.t("%{model} successfully updated.", :model => item_class.model_name.human)
|
201
202
|
else
|
202
203
|
alert = item.error.full_messages
|
203
204
|
end
|
204
205
|
|
205
|
-
redirect_to
|
206
|
+
redirect_to :back, :notice => notice, :alert => alert
|
206
207
|
end
|
207
208
|
|
208
209
|
private
|
@@ -235,7 +236,7 @@ class Admin::ResourcesController < Admin::BaseController
|
|
235
236
|
check_resources_ownership
|
236
237
|
end
|
237
238
|
|
238
|
-
@
|
239
|
+
@resource = @resource.order(set_order).includes(eager_loading)
|
239
240
|
end
|
240
241
|
|
241
242
|
def set_fields
|
@@ -248,178 +249,41 @@ class Admin::ResourcesController < Admin::BaseController
|
|
248
249
|
end
|
249
250
|
|
250
251
|
def redirect_on_success
|
251
|
-
action = @resource.typus_options_for(:action_after_save)
|
252
252
|
path = params.dup.cleanup
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
path.merge!(:id => @item.id)
|
258
|
-
notice = Typus::I18n.t("%{model} successfully created.", :model => @resource.model_name.human)
|
259
|
-
when "update", "detach"
|
260
|
-
case action
|
261
|
-
when "index"
|
262
|
-
if params[:back_to]
|
263
|
-
path = "#{params[:back_to]}##{@resource.to_resource}"
|
264
|
-
else
|
265
|
-
path.delete_if { |k, v| %w(action id).include?(k) }
|
266
|
-
end
|
267
|
-
else
|
268
|
-
path.merge!(:action => action) #, :id => @item.id)
|
269
|
-
end
|
270
|
-
notice = Typus::I18n.t("%{model} successfully updated.", :model => @resource.model_name.human)
|
253
|
+
|
254
|
+
if action_after_save.eql?('index')
|
255
|
+
path.delete_if { |k, v| %w(action id).include?(k) }
|
256
|
+
else
|
257
|
+
path.merge!(:action => action_after_save, :id => @item.id)
|
271
258
|
end
|
272
259
|
|
260
|
+
message = (params[:action] == 'create') ? "%{model} successfully created." : "%{model} successfully updated."
|
261
|
+
notice = Typus::I18n.t(message, :model => @resource.model_name.human)
|
262
|
+
|
273
263
|
redirect_to path, :notice => notice
|
274
264
|
end
|
275
265
|
|
276
266
|
##
|
277
267
|
# Here what we basically do is to associate objects after they have been
|
278
|
-
# created. It's similar to calling `relate
|
279
|
-
#
|
280
|
-
# We have two objects:
|
268
|
+
# created. It's similar to calling `relate` but which the difference that
|
269
|
+
# we are creating a new record.
|
281
270
|
#
|
282
|
-
#
|
283
|
-
#
|
284
|
-
#
|
285
|
-
# http://0.0.0.0:3000/admin/entries/new?back_to=%2Fadmin%2Fcategories%2Fedit%2F3&resource=categories&resource_id=3
|
271
|
+
# We have two objects, detect the relationship_between them and then
|
272
|
+
# call the related method.
|
286
273
|
#
|
287
274
|
def create_with_back_to
|
288
|
-
|
289
|
-
#
|
290
|
-
# Find the remote object which is named item!
|
291
|
-
#
|
292
|
-
|
293
275
|
item_class = params[:resource].typus_constantize
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
# Detect which kind of relationship there's between both models.
|
298
|
-
#
|
299
|
-
|
300
|
-
##
|
301
|
-
# Here we have something like:
|
302
|
-
#
|
303
|
-
# Eg 1.
|
304
|
-
#
|
305
|
-
# - We are editing an Order and want to add a new Invoice.
|
306
|
-
# - Click on "Add New" and we are redirected to the form.
|
307
|
-
# - We want to know which kind of relationship there's between both
|
308
|
-
# objects.
|
309
|
-
#
|
310
|
-
# >> Order.relationship_with(Invoice)
|
311
|
-
# => :has_one
|
312
|
-
#
|
313
|
-
# Eg 2.
|
314
|
-
#
|
315
|
-
# - We are editing a Entry and want to add a new Attachment.
|
316
|
-
# - Click on "Add New" and we are redirected to the form.
|
317
|
-
# - We want to know which kind of relationship there's between both
|
318
|
-
# objects.
|
319
|
-
#
|
320
|
-
# >> Entry.relationship_with(Attachment)
|
321
|
-
# => :has_and_belongs_to_many
|
322
|
-
#
|
323
|
-
# Eg 3.
|
324
|
-
#
|
325
|
-
# - We are editing a Entry and want to add a new Comment.
|
326
|
-
# - Click on "Add New" and we are redirected to the form.
|
327
|
-
# - We want to know which kind of relationship there's between both
|
328
|
-
# objects.
|
329
|
-
#
|
330
|
-
# >> Entry.relationship_with(Comment)
|
331
|
-
# => :has_many
|
332
|
-
#
|
333
|
-
# Eg 4.
|
334
|
-
#
|
335
|
-
# - We are editing a Post (Entry) and want to add a new Attachment.
|
336
|
-
# - Click on "Add New" and we are redirected to the form.
|
337
|
-
# - We want to know which kind of relationship there's between both
|
338
|
-
# objects.
|
339
|
-
#
|
340
|
-
# >> Post.relationship_with(Attachment)
|
341
|
-
# => :has_and_belongs_to_many
|
342
|
-
#
|
343
|
-
|
344
|
-
case item_class.relationship_with(@resource)
|
345
|
-
when :has_one
|
346
|
-
# Order#invoice = @item
|
347
|
-
association_name = @resource.model_name.underscore.to_sym
|
348
|
-
item.send("#{association_name}=", @item)
|
349
|
-
worked = true
|
350
|
-
when :has_and_belongs_to_many
|
351
|
-
# Attachment#entries.push(item)
|
352
|
-
association_name = @resource.model_name.tableize.to_sym
|
353
|
-
worked = item.send(association_name).push(@item)
|
354
|
-
when :belongs_to
|
355
|
-
# Entry#comments.push(item)
|
356
|
-
association_name = item_class.model_name.tableize.to_sym
|
357
|
-
if item
|
358
|
-
worked = @item.send(association_name).push(item)
|
359
|
-
end
|
360
|
-
when :has_many
|
361
|
-
# Dog#image_holders
|
362
|
-
association_name = @resource.model_name.tableize.to_sym
|
363
|
-
worked = item.send(association_name).push(@item)
|
364
|
-
end
|
365
|
-
|
366
|
-
association = @resource.reflect_on_association(association_name)
|
367
|
-
|
368
|
-
##
|
369
|
-
# Set @back_to
|
370
|
-
#
|
371
|
-
|
372
|
-
@back_to = if item
|
373
|
-
params[:back_to]
|
374
|
-
else
|
375
|
-
"#{params[:back_to]}?#{association.primary_key_name}=#{@item.id}"
|
376
|
-
end
|
377
|
-
|
378
|
-
##
|
379
|
-
# Finally delete the associated object. Depending on your models setup
|
380
|
-
# associated models will be removed or foreign_key will be set to nil.
|
381
|
-
#
|
382
|
-
|
383
|
-
if item
|
384
|
-
if worked
|
385
|
-
notice = Typus::I18n.t("%{model} successfully updated.", :model => item_class.model_name.human)
|
386
|
-
else
|
387
|
-
alert = @item.errors.full_messages
|
388
|
-
end
|
389
|
-
end
|
390
|
-
|
391
|
-
redirect_to set_path, :notice => notice, :alert => alert
|
276
|
+
options = { :controller => item_class.to_resource }
|
277
|
+
assoc = item_class.relationship_with(@resource).to_s
|
278
|
+
send("set_#{assoc}_association", item_class, options)
|
392
279
|
end
|
393
280
|
|
394
281
|
def default_action
|
395
282
|
@resource.typus_options_for(:default_action_on_item)
|
396
283
|
end
|
397
284
|
|
398
|
-
|
399
|
-
|
400
|
-
# verify before the the Order doesn't have an Invoice, otherwise we would
|
401
|
-
# have and Order with many Invoices which is something not desired.
|
402
|
-
#
|
403
|
-
# Eg:
|
404
|
-
#
|
405
|
-
# @resource (Invoice)
|
406
|
-
# params[:resource] = "Order"
|
407
|
-
# params[:resource_id] = "1"
|
408
|
-
#
|
409
|
-
# Does this Order already has an Invoice. If true, redirect to back.
|
410
|
-
#
|
411
|
-
def check_if_we_can_add_a_new_item
|
412
|
-
if params[:resource] && params[:resource_id]
|
413
|
-
item_class = params[:resource].typus_constantize
|
414
|
-
item = item_class.find(params[:resource_id]) if params[:resource_id]
|
415
|
-
|
416
|
-
if item_class.relationship_with(@resource) == :has_one
|
417
|
-
association_name = @resource.model_name.underscore.to_sym
|
418
|
-
if item.send(association_name)
|
419
|
-
render :text => "Not allowed!", :status => :unprocessable_entity
|
420
|
-
end
|
421
|
-
end
|
422
|
-
end
|
285
|
+
def action_after_save
|
286
|
+
@resource.typus_options_for(:action_after_save)
|
423
287
|
end
|
424
288
|
|
425
289
|
end
|