typus 1.0.0.pre8 → 1.0.0.pre9
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -6
- data/Gemfile +16 -13
- data/Gemfile.lock +26 -2
- data/Rakefile +2 -3
- data/app/controllers/admin/base_controller.rb +3 -5
- data/app/controllers/admin/resources_controller.rb +24 -26
- data/app/helpers/admin/base_helper.rb +14 -22
- data/app/helpers/admin/dashboard_helper.rb +2 -5
- data/app/helpers/admin/filters_helper.rb +6 -8
- data/app/helpers/admin/form_helper.rb +3 -9
- data/app/helpers/admin/preview_helper.rb +4 -6
- data/app/helpers/admin/relationships_helper.rb +9 -11
- data/app/helpers/admin/resources_helper.rb +6 -24
- data/app/helpers/admin/search_helper.rb +1 -1
- data/app/helpers/admin/sidebar_helper.rb +12 -15
- data/app/helpers/admin/table_helper.rb +13 -13
- data/app/views/admin/dashboard/show.html.erb +1 -1
- data/app/views/admin/helpers/_apps.html.erb +4 -3
- data/app/views/admin/helpers/_header.html.erb +2 -2
- data/app/views/admin/helpers/dashboard/_applications.html.erb +3 -3
- data/app/views/admin/helpers/dashboard/_resources.html.erb +17 -13
- data/app/views/admin/helpers/filters/_filters.html.erb +9 -27
- data/app/views/admin/helpers/resources/_pagination.html.erb +8 -9
- data/app/views/admin/helpers/search/_search.html.erb +1 -1
- data/app/views/admin/mailer/reset_password_link.text.erb +3 -0
- data/app/views/admin/resources/_form.html.erb +4 -4
- data/app/views/admin/resources/edit.html.erb +2 -3
- data/app/views/admin/resources/index.html.erb +15 -13
- data/app/views/admin/resources/new.html.erb +2 -2
- data/app/views/admin/resources/show.html.erb +1 -2
- data/app/views/admin/templates/_boolean.html.erb +1 -1
- data/app/views/admin/templates/_has_many.html.erb +2 -4
- data/app/views/admin/templates/_has_n.html.erb +1 -1
- data/app/views/admin/templates/_selector.html.erb +0 -1
- data/app/views/admin/templates/_string.html.erb +1 -1
- data/app/views/layouts/admin/session.html.erb +1 -1
- data/config/available_locales/ca.yml +3 -5
- data/config/available_locales/de.yml +2 -4
- data/config/available_locales/es.yml +2 -4
- data/config/available_locales/fr.yml +40 -39
- data/config/available_locales/fr_models.yml +2 -2
- data/config/available_locales/hu.yml +3 -5
- data/config/available_locales/it.yml +0 -4
- data/config/available_locales/language.yml.template +2 -4
- data/config/available_locales/pt-BR.yml +2 -4
- data/config/available_locales/ru.yml +2 -4
- data/config/routes.rb +1 -0
- data/lib/generators/templates/config/initializers/typus.rb +5 -5
- data/lib/generators/templates/config/initializers/typus_authentication.rb +5 -5
- data/lib/generators/templates/config/initializers/typus_resources.rb +7 -7
- data/lib/generators/templates/config/typus/README +11 -13
- data/lib/generators/templates/controller.rb +0 -2
- data/lib/generators/templates/functional_test.rb +4 -15
- data/lib/generators/typus/migration_generator.rb +0 -1
- data/lib/support/active_record.rb +18 -9
- data/lib/support/fake_user.rb +42 -0
- data/lib/support/object.rb +1 -0
- data/lib/support/string.rb +0 -32
- data/lib/tasks/typus.rake +0 -8
- data/lib/typus.rb +34 -18
- data/lib/typus/authentication/base.rb +26 -0
- data/lib/typus/authentication/http_basic.rb +22 -0
- data/lib/typus/authentication/none.rb +19 -0
- data/lib/typus/authentication/session.rb +190 -0
- data/lib/typus/format.rb +12 -19
- data/lib/typus/orm/active_record.rb +13 -51
- data/lib/typus/resources.rb +0 -9
- data/lib/typus/version.rb +1 -1
- data/test/factories.rb +43 -0
- data/test/fixtures/rails_app/app/controllers/application_controller.rb +0 -1
- data/test/fixtures/rails_app/app/models/page.rb +0 -4
- data/test/fixtures/rails_app/config/application.rb +6 -3
- data/test/fixtures/rails_app/config/database.yml +12 -20
- data/test/fixtures/rails_app/config/typus/application.yml +4 -8
- data/test/fixtures/rails_app/db/test.sqlite3 +0 -0
- data/test/fixtures/rails_app/log/test.log +227115 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012213057.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012213132.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012213234.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012213506.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012215057.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012215217.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012215415.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012215443.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012215509.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012215528.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012215551.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012215615.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012215640.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012215714.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012215744.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012215814.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012215836.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012215906.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012220659.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012221043.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012221258.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012222558.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012222752.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012222848.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012223433.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012223535.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012224003.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012224052.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012224109.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012224139.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012224205.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012224243.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012225119.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013063215.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013063300.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013063352.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013063427.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013063448.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013063530.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013063559.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013063646.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013063737.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013063822.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013063837.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013063919.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013063939.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013063952.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013064220.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013064253.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013064318.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013064404.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013064452.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013064536.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013064652.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013064845.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013065023.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013065137.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013065713.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013065954.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013070057.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013070116.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013070156.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013070349.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013070429.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013070448.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013070514.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013070709.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013070745.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013070809.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013070905.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013070955.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013071116.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013071209.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013071335.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013071632.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013071643.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013071735.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013071749.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013072030.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013072050.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013072108.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013072713.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013072751.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013072912.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013074546.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101018180512.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101018183359.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101018183608.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101018183759.csv +2 -0
- data/test/functional/admin/account_controller_test.rb +1 -1
- data/test/functional/admin/{resources_controller_assets_relationships.rb → assets_controller_test.rb} +12 -16
- data/test/functional/admin/categories_controller_test.rb +62 -0
- data/test/functional/admin/{resources_controller_comments_toggle_test.rb → comments_controller_test.rb} +0 -0
- data/test/functional/admin/dashboard_controller_test.rb +34 -2
- data/test/functional/admin/posts_controller_test.rb +548 -0
- data/test/functional/admin/session_controller_test.rb +2 -2
- data/test/functional/admin/{resources_controller_tableless_resource_test.rb → status_controller_test.rb} +0 -0
- data/test/functional/admin/{resources_controller_typus_users_test.rb → typus_users_controller_test.rb} +2 -2
- data/test/helpers/admin/base_helper_test.rb +35 -37
- data/test/helpers/admin/dashboard_helper_test.rb +4 -8
- data/test/helpers/admin/form_helper_test.rb +9 -34
- data/test/helpers/admin/resources_helper_test.rb +28 -16
- data/test/helpers/admin/sidebar_helper_test.rb +14 -27
- data/test/helpers/admin/table_helper_test.rb +24 -68
- data/test/integration/login_test.rb +13 -0
- data/test/integration_test_helper.rb +21 -0
- data/test/lib/support/active_record_test.rb +72 -21
- data/test/lib/support/array_test.rb +2 -6
- data/test/lib/support/string_test.rb +21 -30
- data/test/lib/typus/active_record_test.rb +162 -100
- data/test/lib/typus/resource_test.rb +2 -3
- data/test/lib/typus_test.rb +25 -22
- data/test/test_helper.rb +4 -17
- data/test/unit/admin/mailer_test.rb +2 -2
- data/test/unit/typus_user_roles_test.rb +23 -23
- data/test/unit/typus_user_test.rb +30 -24
- data/typus.gemspec +0 -1
- metadata +111 -60
- data/app/models/admin/fake_user.rb +0 -46
- data/lib/generators/templates/model.yml +0 -10
- data/lib/typus/authentication.rb +0 -241
- data/lib/vendor/paginator.rb +0 -143
- data/test/factories/assets.rb +0 -5
- data/test/factories/categories.rb +0 -3
- data/test/factories/comments.rb +0 -6
- data/test/factories/pages.rb +0 -5
- data/test/factories/pictures.rb +0 -7
- data/test/factories/posts.rb +0 -6
- data/test/factories/typus_users.rb +0 -8
- data/test/fixtures/rails_app/README +0 -244
- data/test/fixtures/rails_app/app/helpers/application_helper.rb +0 -2
- data/test/fixtures/rails_app/app/views/layouts/application.html.erb +0 -14
- data/test/fixtures/rails_app/config/environments/development.rb +0 -19
- data/test/fixtures/rails_app/config/environments/production.rb +0 -42
- data/test/fixtures/rails_app/config/initializers/acts_as_list.rb +0 -258
- data/test/fixtures/rails_app/config/initializers/acts_as_tree.rb +0 -98
- data/test/fixtures/rails_app/config/initializers/backtrace_silencers.rb +0 -7
- data/test/fixtures/rails_app/config/initializers/inflections.rb +0 -10
- data/test/fixtures/rails_app/config/initializers/mime_types.rb +0 -5
- data/test/fixtures/rails_app/config/locales/en.yml +0 -5
- data/test/fixtures/rails_app/db/seeds.rb +0 -7
- data/test/fixtures/rails_app/public/404.html +0 -26
- data/test/fixtures/rails_app/public/422.html +0 -26
- data/test/fixtures/rails_app/public/500.html +0 -26
- 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/index.html +0 -279
- 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 -4874
- data/test/fixtures/rails_app/public/javascripts/rails.js +0 -118
- data/test/fixtures/rails_app/public/robots.txt +0 -5
- data/test/fixtures/rails_app/script/rails +0 -9
- data/test/functional/admin/dashboard_controller_http_basic_test.rb +0 -24
- data/test/functional/admin/dashboard_controller_none_test.rb +0 -18
- data/test/functional/admin/resources_controller_categories_before_test.rb +0 -10
- data/test/functional/admin/resources_controller_categories_lists_test.rb +0 -44
- data/test/functional/admin/resources_controller_categories_views_test.rb +0 -10
- data/test/functional/admin/resources_controller_posts_before_test.rb +0 -10
- data/test/functional/admin/resources_controller_posts_crud_custom_test.rb +0 -27
- data/test/functional/admin/resources_controller_posts_crud_test.rb +0 -44
- data/test/functional/admin/resources_controller_posts_formats_test.rb +0 -39
- data/test/functional/admin/resources_controller_posts_forms_test.rb +0 -58
- data/test/functional/admin/resources_controller_posts_permissions_test.rb +0 -100
- data/test/functional/admin/resources_controller_posts_relationships_test.rb +0 -91
- data/test/functional/admin/resources_controller_posts_roles.rb +0 -52
- data/test/functional/admin/resources_controller_posts_views_test.rb +0 -143
- data/test/lib/vendor/paginator_test.rb +0 -141
- data/typus-1.0.0.pre7.gem +0 -0
@@ -38,11 +38,9 @@ module Admin
|
|
38
38
|
|
39
39
|
setup_relationship(field)
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
form = build_relate_form
|
45
|
-
end
|
41
|
+
@items_to_relate = (@model_to_relate.all - @item.send(field))
|
42
|
+
if set_condition && !@items_to_relate.empty?
|
43
|
+
form = build_relate_form
|
46
44
|
end
|
47
45
|
|
48
46
|
build_pagination
|
@@ -89,22 +87,22 @@ module Admin
|
|
89
87
|
:resource => @resource.name, :resource_id => @item.id,
|
90
88
|
:back_to => @back_to }
|
91
89
|
|
92
|
-
return unless set_condition &&
|
90
|
+
return unless set_condition && current_user.can?("create", @model_to_relate)
|
93
91
|
|
94
92
|
link_to _t("Add new"), default_options.merge(options)
|
95
93
|
end
|
96
94
|
|
97
95
|
def set_condition
|
98
|
-
if @resource.typus_user_id? &&
|
99
|
-
@item.owned_by?(
|
96
|
+
if @resource.typus_user_id? && current_user.is_not_root?
|
97
|
+
@item.owned_by?(current_user)
|
100
98
|
else
|
101
99
|
true
|
102
100
|
end
|
103
101
|
end
|
104
102
|
|
105
103
|
def set_conditions
|
106
|
-
if @model_to_relate.typus_options_for(:only_user_items) &&
|
107
|
-
{ Typus.user_fk =>
|
104
|
+
if @model_to_relate.typus_options_for(:only_user_items) && current_user.is_not_root?
|
105
|
+
{ Typus.user_fk => current_user }
|
108
106
|
end
|
109
107
|
end
|
110
108
|
|
@@ -172,7 +170,7 @@ module Admin
|
|
172
170
|
:action => 'new',
|
173
171
|
:back_to => back_to,
|
174
172
|
:selected => related_fk },
|
175
|
-
:confirm => confirm.join("\n\n") if
|
173
|
+
:confirm => confirm.join("\n\n") if current_user.can?('create', related)
|
176
174
|
|
177
175
|
render "admin/templates/belongs_to",
|
178
176
|
:resource => @resource,
|
@@ -11,18 +11,14 @@ module Admin
|
|
11
11
|
include TableHelper
|
12
12
|
|
13
13
|
#--
|
14
|
-
# If
|
15
|
-
#
|
16
|
-
#
|
14
|
+
# If partial `list` exists we will use it. This partial will have available
|
15
|
+
# the `@items` so we can do whatever we want there. Notice that pagination
|
16
|
+
# is still available.
|
17
17
|
#++
|
18
18
|
def build_list(model, fields, items, resource = @resource.to_resource, link_options = {}, association = nil)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
render :partial => template.gsub('/_', '/'), :collection => items, :as => :item
|
23
|
-
else
|
24
|
-
build_table(model, fields, items, link_options, association)
|
25
|
-
end
|
19
|
+
render "admin/#{resource}/list", :items => items
|
20
|
+
rescue ActionView::MissingTemplate
|
21
|
+
build_table(model, fields, items, link_options, association)
|
26
22
|
end
|
27
23
|
|
28
24
|
def display_link_to_previous
|
@@ -55,20 +51,6 @@ module Admin
|
|
55
51
|
render File.join(path, "pagination") if @items.prev || @items.next
|
56
52
|
end
|
57
53
|
|
58
|
-
=begin
|
59
|
-
|
60
|
-
# TODO: This method should show a list of actions for the actual record.
|
61
|
-
def custom_actions(klass)
|
62
|
-
options = { :controller => klass.to_resource }
|
63
|
-
items = klass.typus_actions_on("index").map do |action|
|
64
|
-
if @current_user.can?(action, klass)
|
65
|
-
(link_to _t(action.humanize), options.merge(:action => action))
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
=end
|
71
|
-
|
72
54
|
private
|
73
55
|
|
74
56
|
def path
|
@@ -8,7 +8,7 @@ module Admin
|
|
8
8
|
|
9
9
|
search_by = typus_search.collect { |x| resource.human_attribute_name(x) }.to_sentence
|
10
10
|
search_params = params.dup
|
11
|
-
%w(action controller id search page).each { |p| search_params.delete(p) }
|
11
|
+
%w(action controller id search page utf8).each { |p| search_params.delete(p) }
|
12
12
|
hidden_params = search_params.map { |k, v| hidden_field_tag(k, v) }
|
13
13
|
|
14
14
|
render "admin/helpers/search/search", :hidden_params => hidden_params, :search_by => search_by
|
@@ -7,9 +7,13 @@ module Admin
|
|
7
7
|
app_name = @resource.typus_application
|
8
8
|
|
9
9
|
Typus.application(app_name).sort {|a,b| a.constantize.model_name.human <=> b.constantize.model_name.human}.each do |resource|
|
10
|
-
next unless
|
10
|
+
next unless current_user.resources.include?(resource)
|
11
11
|
klass = resource.constantize
|
12
|
-
|
12
|
+
|
13
|
+
resources[resource] = default_actions(klass)
|
14
|
+
resources[resource] += export(klass) if params[:action] == 'index'
|
15
|
+
resources[resource] += custom_actions(klass)
|
16
|
+
|
13
17
|
resources[resource].compact!
|
14
18
|
end
|
15
19
|
|
@@ -19,32 +23,25 @@ module Admin
|
|
19
23
|
def default_actions(klass)
|
20
24
|
actions = []
|
21
25
|
|
22
|
-
if
|
23
|
-
|
24
|
-
message = _t("Add new")
|
25
|
-
actions << (link_to_unless_current message, options.merge(:action => "new"))
|
26
|
+
if current_user.can?("create", klass)
|
27
|
+
actions << link_to_unless_current(_t("Add new"), :action => "new")
|
26
28
|
end
|
27
29
|
|
28
|
-
|
29
|
-
options = { :controller => klass.to_resource }
|
30
|
-
actions << (link_to_unless_current message, options)
|
30
|
+
actions << link_to_unless_current(_t("List"), :action => "index")
|
31
31
|
|
32
32
|
return actions
|
33
33
|
end
|
34
34
|
|
35
35
|
def export(klass)
|
36
|
-
return [] unless params[:action] == "index"
|
37
|
-
|
38
36
|
klass.typus_export_formats.map do |format|
|
39
37
|
link_to _t("Export as %{format}", :format => format.upcase), params.merge(:format => format)
|
40
38
|
end
|
41
39
|
end
|
42
40
|
|
43
41
|
def custom_actions(klass)
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
(link_to_unless_current _t(action.humanize), options.merge(:action => action))
|
42
|
+
klass.typus_actions_on(params[:action]).map do |action|
|
43
|
+
if current_user.can?(action, klass)
|
44
|
+
link_to_unless_current(_t(action.humanize), params.merge(:action => action))
|
48
45
|
end
|
49
46
|
end
|
50
47
|
end
|
@@ -63,10 +63,10 @@ module Admin
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def table_default_action(model, item)
|
66
|
-
action = if model.typus_user_id? &&
|
66
|
+
action = if model.typus_user_id? && current_user.is_not_root?
|
67
67
|
# If there's a typus_user_id column on the table and logged user is not root ...
|
68
|
-
item.owned_by?(
|
69
|
-
elsif
|
68
|
+
item.owned_by?(current_user) ? item.class.typus_options_for(:default_action_on_item) : "show"
|
69
|
+
elsif current_user.cannot?("edit", model)
|
70
70
|
'show'
|
71
71
|
else
|
72
72
|
item.class.typus_options_for(:default_action_on_item)
|
@@ -104,12 +104,12 @@ module Admin
|
|
104
104
|
|
105
105
|
case params[:action]
|
106
106
|
when 'index'
|
107
|
-
condition = if model.typus_user_id? &&
|
108
|
-
item.owned_by?(
|
109
|
-
elsif (
|
107
|
+
condition = if model.typus_user_id? && current_user.is_not_root?
|
108
|
+
item.owned_by?(current_user)
|
109
|
+
elsif (current_user.id.eql?(item.id) && model.eql?(Typus.user_class))
|
110
110
|
false
|
111
111
|
else
|
112
|
-
|
112
|
+
current_user.can?('destroy', model)
|
113
113
|
end
|
114
114
|
confirm = _t("Remove %{resource}?", :resource => item.class.model_name.human)
|
115
115
|
when 'edit'
|
@@ -122,8 +122,8 @@ module Admin
|
|
122
122
|
# the owners of the owner record.
|
123
123
|
# If the owner record doesn't have a foreign key (Typus.user_fk) we look
|
124
124
|
# each item to verify the ownership.
|
125
|
-
condition = if @resource.typus_user_id? &&
|
126
|
-
@item.owned_by?(
|
125
|
+
condition = if @resource.typus_user_id? && current_user.is_not_root?
|
126
|
+
@item.owned_by?(current_user)
|
127
127
|
end
|
128
128
|
confirm = _t("Unrelate %{unrelate_model} from %{unrelate_model_from}?",
|
129
129
|
:unrelate_model => model.model_name.human,
|
@@ -145,7 +145,7 @@ module Admin
|
|
145
145
|
unless att_value.nil?
|
146
146
|
content = att_value.to_label
|
147
147
|
action = item.send(attribute).class.typus_options_for(:default_action_on_item)
|
148
|
-
if
|
148
|
+
if current_user.can?(action, att_value.class.name)
|
149
149
|
content = link_to content, :controller => "admin/#{att_value.class.to_resource}", :action => action, :id => att_value.id
|
150
150
|
end
|
151
151
|
end
|
@@ -180,7 +180,7 @@ module Admin
|
|
180
180
|
render "admin/helpers/preview",
|
181
181
|
:attribute => attribute,
|
182
182
|
:attachment => attribute,
|
183
|
-
:content => item.
|
183
|
+
:content => item.to_label,
|
184
184
|
:file_preview_is_image => file_preview_is_image,
|
185
185
|
:has_file_preview => has_file_preview,
|
186
186
|
:href => item.send(attribute).url(file_preview),
|
@@ -220,13 +220,13 @@ module Admin
|
|
220
220
|
end
|
221
221
|
|
222
222
|
def table_boolean_field(attribute, item)
|
223
|
-
boolean_hash = item.class.typus_boolean(attribute)
|
223
|
+
boolean_hash = item.class.typus_boolean(attribute).invert
|
224
224
|
status = item.send(attribute)
|
225
225
|
|
226
226
|
content = if status.nil?
|
227
227
|
Typus::Resources.human_nil
|
228
228
|
else
|
229
|
-
message = _t(boolean_hash[
|
229
|
+
message = _t(boolean_hash[status.to_s])
|
230
230
|
options = { :controller => "admin/#{item.class.to_resource}",
|
231
231
|
:action => "toggle",
|
232
232
|
:id => item.id,
|
@@ -1,7 +1,8 @@
|
|
1
1
|
<ul>
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
<% dashboard = 'active' if params[:controller].include?('dashboard') %>
|
3
|
+
<li><%= link_to _t("Dashboard"), admin_dashboard_path, :class => dashboard %></li>
|
4
|
+
<% current_user.applications.each do |app| %>
|
5
|
+
<% klass = (@resource && Typus.application(app).include?(@resource.name)) ? 'active' : nil %>
|
5
6
|
<li><%= link_to _t(app), { :controller => Typus.application(app).sort {|a,b| a.constantize.model_name.human <=> b.constantize.model_name.human}.first.tableize }, { :class => klass } %></li>
|
6
7
|
<% end %>
|
7
8
|
</ul>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%
|
1
|
+
<% current_user.applications.each do |app| %>
|
2
2
|
|
3
3
|
<table>
|
4
4
|
|
@@ -8,7 +8,7 @@
|
|
8
8
|
</tr>
|
9
9
|
</thead>
|
10
10
|
|
11
|
-
<%
|
11
|
+
<% current_user.application(app).each do |model| %>
|
12
12
|
|
13
13
|
<%
|
14
14
|
klass = model.constantize
|
@@ -21,7 +21,7 @@
|
|
21
21
|
<%= link_to klass_human_name, admin_items_path %>
|
22
22
|
</td>
|
23
23
|
<td class="right">
|
24
|
-
<%= link_to_if
|
24
|
+
<%= link_to_if current_user.can?("create", klass), _t("Add"), admin_items_path.merge(:action => "new") %>
|
25
25
|
</td>
|
26
26
|
</tr>
|
27
27
|
|
@@ -1,16 +1,20 @@
|
|
1
|
-
|
1
|
+
<% if resources.any? %>
|
2
2
|
|
3
|
-
<
|
4
|
-
<tr>
|
5
|
-
<th colspan="2"><%= _t("Resources") %></th>
|
6
|
-
</tr>
|
7
|
-
</thead>
|
3
|
+
<table>
|
8
4
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
</
|
14
|
-
<% end %>
|
5
|
+
<thead>
|
6
|
+
<tr>
|
7
|
+
<th colspan="2"><%= _t("Resources") %></th>
|
8
|
+
</tr>
|
9
|
+
</thead>
|
15
10
|
|
16
|
-
|
11
|
+
<% resources.each do |resource| %>
|
12
|
+
<tr class="<%= cycle("even", "odd") %>">
|
13
|
+
<td><%= link_to _t(resource.titleize.capitalize), :controller => "admin/#{resource.underscore}" %></td>
|
14
|
+
<td align="right" style="vertical-align: bottom;"></td>
|
15
|
+
</tr>
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
</table>
|
19
|
+
|
20
|
+
<% end %>
|
@@ -1,31 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
<ul>
|
4
|
-
|
5
|
-
<%= form_tag nil, :method => :get do %>
|
1
|
+
<%= form_tag nil, :method => :get do %>
|
6
2
|
|
3
|
+
<div id="filters">
|
4
|
+
<ul>
|
7
5
|
<% filters.each do |filter| %>
|
8
|
-
|
9
|
-
<li>
|
10
|
-
<select name="<%= filter[:filter] %>">
|
11
|
-
<option value=""><%= filter[:message] %></option>
|
12
|
-
<% filter[:items].each do |key, value| %>
|
13
|
-
<% selected = "selected" if params[filter[:filter]].eql?(key.to_s) %>
|
14
|
-
<option <%= selected %> value="<%= key %>"><%= value %></option>
|
15
|
-
<% end %>
|
16
|
-
</select>
|
17
|
-
</li>
|
18
|
-
|
6
|
+
<li><%= select_tag filter[:filter], options_for_select(filter[:items], params[filter[:filter]]) %></li>
|
19
7
|
<% end %>
|
8
|
+
<%= hidden_field_tag :search, params[:search] if params[:search] %>
|
9
|
+
<li><%= submit_tag _t("Filter"), :name => nil %></li>
|
10
|
+
</ul>
|
11
|
+
</div>
|
20
12
|
|
21
|
-
|
22
|
-
|
23
|
-
<li>
|
24
|
-
<%= submit_tag _t("Filter"), :name => nil %>
|
25
|
-
</li>
|
26
|
-
|
27
|
-
<% end %>
|
28
|
-
|
29
|
-
</ul>
|
30
|
-
|
31
|
-
</div>
|
13
|
+
<% end %>
|
@@ -1,26 +1,25 @@
|
|
1
1
|
<div id="pagination">
|
2
2
|
|
3
|
-
<%
|
4
|
-
previous_text = "← " + _t("Previous")
|
5
|
-
next_text = _t("Next") + " →"
|
6
|
-
%>
|
7
|
-
|
8
3
|
<div class="left">
|
9
4
|
|
5
|
+
<% previous_text = ("← " + _t("Previous")).html_safe %>
|
6
|
+
|
10
7
|
<% if @items.prev? %>
|
11
|
-
<%= link_to
|
8
|
+
<%= link_to previous_text, params.merge(:page => @items.prev.number, :anchor => @options[:anchor]) %>
|
12
9
|
<% else %>
|
13
|
-
<span class="disabled"><%=
|
10
|
+
<span class="disabled"><%= previous_text %></span>
|
14
11
|
<% end %>
|
15
12
|
|
16
13
|
</div>
|
17
14
|
|
18
15
|
<div class="right">
|
19
16
|
|
17
|
+
<% next_text = (_t("Next") + " →").html_safe %>
|
18
|
+
|
20
19
|
<% if @items.next? %>
|
21
|
-
<%= link_to
|
20
|
+
<%= link_to next_text, params.merge(:page => @items.next.number, :anchor => @options[:anchor]) %>
|
22
21
|
<% else %>
|
23
|
-
<span class="disabled"><%=
|
22
|
+
<span class="disabled"><%= next_text %></span>
|
24
23
|
<% end %>
|
25
24
|
|
26
25
|
</div>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
<%= form_tag url_for(:controller => params[:controller]), :method => :get do %>
|
4
4
|
<ul>
|
5
|
-
<li
|
5
|
+
<li><%= search_field_tag "search", nil, :id => "quicksearch", :title => (params[:search] || _t("Search")) %></li>
|
6
6
|
</ul>
|
7
7
|
<% hidden_params.each do |field| %>
|
8
8
|
<%= field %>
|
@@ -1,11 +1,11 @@
|
|
1
|
-
<%= form_for @item, :url => options, :html => { :multipart => true } do |form| %>
|
1
|
+
<%= form_for @item, :url => options[:options], :html => { :multipart => true } do |form| %>
|
2
2
|
|
3
3
|
<% if @item.errors.any? %>
|
4
4
|
<div id="errorExplanation">
|
5
5
|
<h3><%= pluralize(@item.errors.count, "error") %> prohibited this page from being saved:</h3>
|
6
6
|
<ul>
|
7
|
-
<% @item.errors.full_messages.each do |
|
8
|
-
<li><%=
|
7
|
+
<% @item.errors.full_messages.each do |full_message| %>
|
8
|
+
<li><%= full_message %></li>
|
9
9
|
<% end %>
|
10
10
|
</ul>
|
11
11
|
</div>
|
@@ -19,7 +19,7 @@
|
|
19
19
|
|
20
20
|
<fieldset class="buttons">
|
21
21
|
<ol>
|
22
|
-
<li><%= submit_tag button , :class => "commit" %> or <%= link_to _t("Cancel and go back").downcase, :action => "index" %></li>
|
22
|
+
<li><%= submit_tag options[:button] , :class => "commit" %> or <%= link_to _t("Cancel and go back").downcase, :action => "index" %></li>
|
23
23
|
</ol>
|
24
24
|
</fieldset>
|
25
25
|
|