admin_data 1.0.8 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/app/controllers/admin_data/base_controller.rb +25 -12
- data/app/controllers/admin_data/main_controller.rb +1 -1
- data/lib/admin_data/chelper.rb +3 -3
- data/lib/admin_data/settings.rb +7 -13
- data/lib/admin_data/version.rb +1 -1
- data/lib/admin_data.rb +1 -6
- data/lib/js/advance_search/act_on_result.js +0 -1
- data/test/rails_root/db/test.sqlite3 +0 -0
- data/test/rails_root/log/test.log +16965 -0
- metadata +3 -3
data/Rakefile
CHANGED
@@ -31,8 +31,8 @@ class AdminData::BaseController < ApplicationController
|
|
31
31
|
render :text => 'not authorized', :status => :unauthorized unless admin_data_is_allowed_to_update?
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
35
|
-
render :text => 'not authorized', :status => :unauthorized unless
|
34
|
+
def ensure_is_allowed_to_update_klass
|
35
|
+
render :text => 'not authorized', :status => :unauthorized unless admin_data_is_allowed_to_update_klass?
|
36
36
|
end
|
37
37
|
|
38
38
|
|
@@ -49,19 +49,32 @@ class AdminData::BaseController < ApplicationController
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def build_klasses
|
52
|
-
|
52
|
+
# if is_allowed_to_view_klass option is passed then golbal constant can't be used since
|
53
|
+
# list of klasses need to be built for each user. It will slow down the speed a bit since
|
54
|
+
# every single the list needs to be built
|
55
|
+
if AdminData::Config.setting[:is_allowed_to_view_klass]
|
56
|
+
@klasses = _build_custom_klasses
|
57
|
+
else
|
58
|
+
@klasses = _build_all_klasses
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def _build_all_klasses
|
63
|
+
if defined? $admin_data_all_klasses
|
64
|
+
return $admin_data_all_klasses
|
65
|
+
else
|
53
66
|
model_dir = File.join(Rails.root, 'app', 'models')
|
54
67
|
model_names = Dir.chdir(model_dir) { Dir["**/*.rb"] }
|
55
68
|
klasses = get_klass_names(model_names)
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
69
|
+
$admin_data_all_klasses = remove_klasses_without_table(klasses).sort_by {|r| r.name.underscore}
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def _build_custom_klasses
|
74
|
+
_build_all_klasses.compact.select do |klass_local|
|
75
|
+
@klass = klass_local
|
76
|
+
admin_data_is_allowed_to_view_klass?
|
63
77
|
end
|
64
|
-
@klasses = $admin_data_klasses
|
65
78
|
end
|
66
79
|
|
67
80
|
def remove_klasses_without_table(klasses)
|
@@ -92,7 +105,7 @@ class AdminData::BaseController < ApplicationController
|
|
92
105
|
end
|
93
106
|
|
94
107
|
def check_page_parameter
|
95
|
-
# Got hoptoad error because of url like
|
108
|
+
# Got hoptoad error because of url like
|
96
109
|
# http://localhost:3000/admin_data/User/advance_search?page=http://201.134.249.164/intranet/on.txt?
|
97
110
|
if params[:page].blank? || (params[:page] =~ /\A\d+\z/)
|
98
111
|
# proceed
|
@@ -12,7 +12,7 @@ class AdminData::MainController < AdminData::BaseController
|
|
12
12
|
|
13
13
|
before_filter :ensure_is_allowed_to_update, :only => [:destroy, :del, :edit, :update, :create]
|
14
14
|
|
15
|
-
before_filter :
|
15
|
+
before_filter :ensure_is_allowed_to_update_klass, :only => [:destroy, :del, :edit, :update, :create]
|
16
16
|
|
17
17
|
|
18
18
|
def table_structure
|
data/lib/admin_data/chelper.rb
CHANGED
@@ -10,7 +10,7 @@ module AdminData::Chelper
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def admin_data_is_allowed_to_view_klass?
|
13
|
-
return true if Rails.env.development?
|
13
|
+
return true if Rails.env.development? || AdminData::Config.setting[:is_allowed_to_view_klass].blank?
|
14
14
|
AdminData::Config.setting[:is_allowed_to_view_klass].call(self)
|
15
15
|
end
|
16
16
|
|
@@ -19,9 +19,9 @@ module AdminData::Chelper
|
|
19
19
|
AdminData::Config.setting[:is_allowed_to_update].call(self)
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
22
|
+
def admin_data_is_allowed_to_update_klass?
|
23
23
|
return true if Rails.env.development?
|
24
|
-
AdminData::Config.setting[:
|
24
|
+
AdminData::Config.setting[:is_allowed_to_update_klass].call(self)
|
25
25
|
end
|
26
26
|
|
27
27
|
def admin_data_invalid_record_link(klassu, id, error)
|
data/lib/admin_data/settings.rb
CHANGED
@@ -9,17 +9,18 @@ class AdminData::Config
|
|
9
9
|
find_conditions
|
10
10
|
plugin_dir
|
11
11
|
will_paginate_per_page
|
12
|
+
|
12
13
|
is_allowed_to_view
|
14
|
+
is_allowed_to_view_klass
|
15
|
+
is_allowed_to_update
|
16
|
+
is_allowed_to_update_klass
|
17
|
+
|
13
18
|
is_allowed_to_view_feed
|
14
19
|
feed_authentication_user_id
|
15
20
|
feed_authentication_password
|
16
|
-
is_allowed_to_view_klass
|
17
|
-
is_allowed_to_update
|
18
|
-
is_allowed_to_update_model
|
19
21
|
column_settings
|
20
22
|
columns_order
|
21
23
|
use_google_hosting_for_jquery
|
22
|
-
rake_options
|
23
24
|
drop_down_for_associations
|
24
25
|
ignore_column_limit
|
25
26
|
).collect(&:intern)
|
@@ -30,13 +31,6 @@ class AdminData::Config
|
|
30
31
|
self.setting ||= {}
|
31
32
|
self.setting.merge!(input)
|
32
33
|
|
33
|
-
unless self.setting[:rake_options].blank?
|
34
|
-
env = self.setting[:rake_options][:env]
|
35
|
-
if env.blank? || env.include?(Rails.env.intern)
|
36
|
-
self.setting[:rake_command] = self.setting[:rake_options][:command]
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
34
|
end
|
41
35
|
|
42
36
|
def self.initialize_defaults
|
@@ -50,9 +44,9 @@ class AdminData::Config
|
|
50
44
|
|
51
45
|
:is_allowed_to_update => lambda {|controller| return true if Rails.env.development? },
|
52
46
|
|
53
|
-
:is_allowed_to_view_klass =>
|
47
|
+
:is_allowed_to_view_klass => nil,
|
54
48
|
|
55
|
-
:
|
49
|
+
:is_allowed_to_update_klass => lambda {|controller| return true },
|
56
50
|
|
57
51
|
:find_conditions => nil,
|
58
52
|
|
data/lib/admin_data/version.rb
CHANGED
data/lib/admin_data.rb
CHANGED
@@ -3,12 +3,7 @@ begin
|
|
3
3
|
rescue LoadError => e
|
4
4
|
$stderr.puts %(
|
5
5
|
*************************************************************************************************
|
6
|
-
* *
|
7
6
|
* gem will_paginate is missing *
|
8
|
-
* plugin admin_data depends on will_paginate *
|
9
|
-
* Please install will_paginate by adding following line to Gemfile *
|
10
|
-
* gem 'will_paginate', :git => 'git://github.com/mislav/will_paginate.git', :branch => 'rails3' *
|
11
|
-
* *
|
12
7
|
*************************************************************************************************
|
13
8
|
)
|
14
9
|
end
|
@@ -19,7 +14,7 @@ end
|
|
19
14
|
if Rails.version >= '3.0'
|
20
15
|
require 'admin_data/railtie'
|
21
16
|
else
|
22
|
-
raise "Please see documentation at http://
|
17
|
+
raise "Please see documentation at http://github.com/neerajdotname/admin_data to find out how to use this gem with rails 2.3"
|
23
18
|
end
|
24
19
|
|
25
20
|
# move date_validation to inside admin_data
|
Binary file
|