admin_data 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/History.txt +10 -0
  2. data/app/controllers/admin_data/base_controller.rb +9 -16
  3. data/app/controllers/admin_data/feed_controller.rb +1 -1
  4. data/app/controllers/admin_data/main_controller.rb +4 -8
  5. data/app/controllers/admin_data/search_controller.rb +1 -1
  6. data/app/views/admin_data/main/new.html.erb +3 -1
  7. data/app/views/admin_data/search/search/_errors.html.erb +3 -3
  8. data/app/views/admin_data/search/search/_listing.html.erb +0 -1
  9. data/lib/admin_data/chelper.rb +2 -2
  10. data/lib/admin_data/railtie.rb +2 -3
  11. data/lib/admin_data/settings.rb +2 -2
  12. data/lib/admin_data/version.rb +1 -1
  13. data/lib/admin_data.rb +2 -0
  14. data/test/functional/main_controller_authorization_test.rb +96 -0
  15. data/test/functional/main_controller_test.rb +0 -2
  16. data/test/rails_root/db/test.sqlite3 +0 -0
  17. data/test/rails_root/log/test.log +2289 -0
  18. metadata +7 -25
  19. data/app/controllers/admin_data/diagnostic_controller.rb +0 -28
  20. data/app/controllers/admin_data/validate_model_controller.rb +0 -106
  21. data/app/views/admin_data/diagnostic/index.html.erb +0 -17
  22. data/app/views/admin_data/diagnostic/missing_index.html.erb +0 -26
  23. data/app/views/admin_data/validate_model/_bad.html.erb +0 -1
  24. data/app/views/admin_data/validate_model/tid.html.erb +0 -2
  25. data/app/views/admin_data/validate_model/validate.html.erb +0 -67
  26. data/lib/css/vendor/images/ui-bg_diagonals-thick_75_f3d8d8_40x40.png +0 -0
  27. data/lib/css/vendor/images/ui-bg_dots-small_65_a6a6a6_2x2.png +0 -0
  28. data/lib/css/vendor/images/ui-bg_flat_0_333333_40x100.png +0 -0
  29. data/lib/css/vendor/images/ui-bg_flat_65_ffffff_40x100.png +0 -0
  30. data/lib/css/vendor/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  31. data/lib/css/vendor/images/ui-bg_glass_55_fbf8ee_1x400.png +0 -0
  32. data/lib/css/vendor/images/ui-bg_highlight-hard_100_eeeeee_1x100.png +0 -0
  33. data/lib/css/vendor/images/ui-bg_highlight-hard_100_f6f6f6_1x100.png +0 -0
  34. data/lib/css/vendor/images/ui-bg_highlight-soft_15_cc0000_1x100.png +0 -0
  35. data/lib/css/vendor/images/ui-icons_004276_256x240.png +0 -0
  36. data/lib/css/vendor/images/ui-icons_cc0000_256x240.png +0 -0
  37. data/lib/css/vendor/images/ui-icons_ffffff_256x240.png +0 -0
  38. data/lib/css/vendor/qunit.css +0 -119
  39. data/lib/tasks/admin_data_tasks.rake +0 -7
  40. data/lib/tasks/validate_models_bg.rake +0 -23
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 2
9
- version: 1.0.2
8
+ - 3
9
+ version: 1.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Neeraj Singh
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-08-16 00:00:00 -04:00
17
+ date: 2010-08-17 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -99,14 +99,10 @@ files:
99
99
  - README.textile
100
100
  - Rakefile
101
101
  - app/controllers/admin_data/base_controller.rb
102
- - app/controllers/admin_data/diagnostic_controller.rb
103
102
  - app/controllers/admin_data/feed_controller.rb
104
103
  - app/controllers/admin_data/main_controller.rb
105
104
  - app/controllers/admin_data/migration_controller.rb
106
105
  - app/controllers/admin_data/search_controller.rb
107
- - app/controllers/admin_data/validate_model_controller.rb
108
- - app/views/admin_data/diagnostic/index.html.erb
109
- - app/views/admin_data/diagnostic/missing_index.html.erb
110
106
  - app/views/admin_data/feed/index.rss.builder
111
107
  - app/views/admin_data/main/all_models.html.erb
112
108
  - app/views/admin_data/main/association/_association_info.html.erb
@@ -136,9 +132,6 @@ files:
136
132
  - app/views/admin_data/shared/_header.html.erb
137
133
  - app/views/admin_data/shared/_powered_by.html.erb
138
134
  - app/views/admin_data/shared/_secondary_navigation.html.erb
139
- - app/views/admin_data/validate_model/_bad.html.erb
140
- - app/views/admin_data/validate_model/tid.html.erb
141
- - app/views/admin_data/validate_model/validate.html.erb
142
135
  - app/views/layouts/admin_data.html.erb
143
136
  - config/routes.rb
144
137
  - init.rb
@@ -158,20 +151,7 @@ files:
158
151
  - lib/css/rounded.css
159
152
  - lib/css/themes/drastic-dark/style.css
160
153
  - lib/css/umbrella.css
161
- - lib/css/vendor/images/ui-bg_diagonals-thick_75_f3d8d8_40x40.png
162
- - lib/css/vendor/images/ui-bg_dots-small_65_a6a6a6_2x2.png
163
- - lib/css/vendor/images/ui-bg_flat_0_333333_40x100.png
164
- - lib/css/vendor/images/ui-bg_flat_65_ffffff_40x100.png
165
- - lib/css/vendor/images/ui-bg_flat_75_ffffff_40x100.png
166
- - lib/css/vendor/images/ui-bg_glass_55_fbf8ee_1x400.png
167
- - lib/css/vendor/images/ui-bg_highlight-hard_100_eeeeee_1x100.png
168
- - lib/css/vendor/images/ui-bg_highlight-hard_100_f6f6f6_1x100.png
169
- - lib/css/vendor/images/ui-bg_highlight-soft_15_cc0000_1x100.png
170
- - lib/css/vendor/images/ui-icons_004276_256x240.png
171
- - lib/css/vendor/images/ui-icons_cc0000_256x240.png
172
- - lib/css/vendor/images/ui-icons_ffffff_256x240.png
173
154
  - lib/css/vendor/jquery-ui-1.7.2.custom.css
174
- - lib/css/vendor/qunit.css
175
155
  - lib/js/advance_search/act_on_result.js
176
156
  - lib/js/advance_search/adv_search.js
177
157
  - lib/js/advance_search/advance_search.js
@@ -199,8 +179,6 @@ files:
199
179
  - lib/js/vendor/jquery.lint.js
200
180
  - lib/js/vendor/log.js
201
181
  - lib/js/vendor/qunit.js
202
- - lib/tasks/admin_data_tasks.rake
203
- - lib/tasks/validate_models_bg.rake
204
182
  - test/factories/article.rb
205
183
  - test/factories/car.rb
206
184
  - test/factories/city.rb
@@ -209,6 +187,7 @@ files:
209
187
  - test/factories/engine.rb
210
188
  - test/functional/base_controller_test.rb
211
189
  - test/functional/feed_controller_test.rb
190
+ - test/functional/main_controller_authorization_test.rb
212
191
  - test/functional/main_controller_test.rb
213
192
  - test/functional/migration_controller_test.rb
214
193
  - test/functional/routes_test.rb
@@ -248,6 +227,8 @@ files:
248
227
  - test/rails_root/db/migrate/20090809061114_create_tables.rb
249
228
  - test/rails_root/db/schema.rb
250
229
  - test/rails_root/db/seeds.rb
230
+ - test/rails_root/db/test.sqlite3
231
+ - test/rails_root/log/test.log
251
232
  - test/rails_root/script/rails
252
233
  - test/rails_root/test/performance/browsing_test.rb
253
234
  - test/rails_root/test/test_helper.rb
@@ -292,6 +273,7 @@ test_files:
292
273
  - test/factories/engine.rb
293
274
  - test/functional/base_controller_test.rb
294
275
  - test/functional/feed_controller_test.rb
276
+ - test/functional/main_controller_authorization_test.rb
295
277
  - test/functional/main_controller_test.rb
296
278
  - test/functional/migration_controller_test.rb
297
279
  - test/functional/routes_test.rb
@@ -1,28 +0,0 @@
1
- class AdminData::DiagnosticController < AdminData::BaseController
2
-
3
- unloadable
4
-
5
- before_filter :ensure_is_allowed_to_view
6
-
7
- def index
8
- @page_title = 'diagnostic'
9
- respond_to {|format| format.html}
10
- end
11
-
12
- def missing_index
13
- @page_title = 'missing index'
14
- @indexes = {}
15
- conn = ActiveRecord::Base.connection
16
- conn.tables.each do |table|
17
- indexed_columns = conn.indexes(table).map { |i| i.columns }.flatten
18
- conn.columns(table).each do |column|
19
- if column.name.match(/_id/) && !indexed_columns.include?(column.name)
20
- @indexes[table] ||= []
21
- @indexes[table] << column.name
22
- end
23
- end
24
- end
25
- respond_to {|format| format.html}
26
- end
27
-
28
- end
@@ -1,106 +0,0 @@
1
- require 'fileutils'
2
-
3
- class AdminData::ValidateModelController < AdminData::BaseController
4
-
5
- unloadable
6
-
7
- before_filter :ensure_is_allowed_to_view
8
-
9
- def tid
10
- @data = gather_data(params[:tid])
11
- respond_to {|format| format.html}
12
- end
13
-
14
- def validate
15
- @page_title = 'validate model'
16
- @tid = Time.now.strftime('%Y%m%d%H%M%S')
17
-
18
- dir = Rails.root.join('tmp', 'admin_data', 'validate_model')
19
- FileUtils.mkdir_p(dir)
20
- tids = Dir.chdir(dir) { Dir["*"] }
21
- @tids = tids.sort!
22
-
23
- respond_to {|format| format.html}
24
- end
25
-
26
- def validate_model
27
- respond_to do |format|
28
- format.js do
29
- if params[:tid].blank?
30
- render :json => {:error => 'Something went wrong. Please try again !!' }
31
- return
32
-
33
- elsif params[:model].blank? && params[:still_processing].blank?
34
- render :json => {:error => 'Please select at least one model' }
35
- return
36
-
37
- elsif !params[:still_processing].blank?
38
- tid = params[:tid]
39
- data = gather_data(tid)
40
- done_file = File.join(Rails.root, 'tmp', 'admin_data', 'validate_model', tid, 'done.txt')
41
- answer = File.exists?(done_file) ? 'no' : 'yes'
42
- h = {
43
- :still_processing => answer,
44
- :data => data,
45
- :currently_processing_klass => AdminData::Util.read_validation_file(tid, 'processing.txt')
46
- }
47
- render :json => h
48
- return
49
- else
50
- tid = params[:tid]
51
- klasses = params[:model].keys.join(',')
52
- start_validation_rake_task(tid, klasses)
53
- base_url = request.protocol + request.host_with_port
54
- render :json => {:still_processing => 'yes', :base_url => base_url }
55
- return
56
- end
57
- end
58
- end
59
- end
60
-
61
- private
62
-
63
- def start_validation_rake_task(tid, klasses)
64
- f = File.join(Rails.root, 'tmp', 'admin_data', 'validate_model', tid)
65
- FileUtils.rm_rf(f) if File.directory?(f)
66
- FileUtils.mkdir_p(f)
67
-
68
- AdminData::Util.write_to_validation_file('', 'a', tid, 'processing.txt')
69
- AdminData::Util.write_to_validation_file('', 'a', tid, 'bad.txt')
70
- AdminData::Util.write_to_validation_file('', 'a', tid, 'good.txt')
71
- AdminData::Util.write_to_validation_file('', 'a', tid, 'error.txt')
72
-
73
- call_rake('admin_data:validate_models_bg', {:tid => tid, :klasses => klasses} )
74
- end
75
-
76
- def call_rake(task, options = {})
77
- options[:rails_env] ||= Rails.env
78
- args = options.map { |n, v| "#{n.to_s.upcase}='#{v}'" }
79
- rake_command = AdminDataConfig.setting[:rake_command]
80
- command = "#{rake_command} #{task} #{args.join(' ')}"
81
- Rails.logger.info "command: #{command}"
82
- p1 = Process.fork { system(command) }
83
- AdminData::Util.write_to_validation_file(p1, 'a', options[:tid], 'pid.txt')
84
- Process.detach(p1)
85
- end
86
-
87
- def gather_data(tid)
88
- good_file = File.join(Rails.root, 'tmp', 'admin_data', 'validate_model', tid, 'good.txt')
89
- bad_file = File.join(Rails.root, 'tmp', 'admin_data', 'validate_model', tid, 'bad.txt')
90
- regex = /(\w+)\s+\|\s+(\d+)\s+\|\s+(.*)/
91
-
92
- data = []
93
- File.open(bad_file, "r") do |f|
94
- f.each_line do |line|
95
- next if line.strip.blank?
96
- data << '<p>'
97
- m = regex.match(line)
98
- data << render_to_string(:partial => 'bad', :locals => {:klassu => m[1], :id => m[2], :error => m[3]})
99
- data << '</p>'
100
- end
101
- end
102
- File.open(good_file, "r") { |f| f.each_line { |line| data << "<p>#{line}</p>" } }
103
- data.join
104
- end
105
-
106
- end
@@ -1,17 +0,0 @@
1
- <div id="main">
2
- <div class="block" id="block-tables">
3
-
4
- <div class="content rounded">
5
- <h2 class="title">Diagnostic test</h2>
6
- <div class="inner">
7
- <h2>
8
- <%= link_to 'Find missing database index', admin_data_diagnostic_missing_index_url %>
9
- </h2>
10
- <h2>
11
- <%= link_to 'Validate Models', admin_data_validate_url %>
12
- </h2>
13
- </div>
14
- </div>
15
-
16
- </div>
17
- </div>
@@ -1,26 +0,0 @@
1
- <div id="main">
2
- <div class="block" id="block-tables">
3
- <div class="content rounded">
4
- <h2 class="title">Missing Index Report</h2>
5
- <div class="inner">
6
- <p>It is recommended that all foreign keys be indexed.</p>
7
- <p>
8
- Given below is the migration code that should be performed to create index.
9
- </p>
10
-
11
- <table id='missing_index'>
12
- <% @indexes.each do |table, columns|
13
- columns.map do |column| %>
14
- <tr>
15
- <td>
16
- add_index '<%=table%>', '<%=column%>'
17
- </td>
18
- </tr>
19
- <% end %>
20
- <% end %>
21
- </table>
22
-
23
- </div>
24
- </div>
25
- </div>
26
- </div>
@@ -1 +0,0 @@
1
- <%=admin_data_invalid_record_link(klassu, id, error)%>
@@ -1,2 +0,0 @@
1
- <%= AdminData::Util.read_validation_file(params[:tid], 'processing.txt') %>
2
- <%=@data%>
@@ -1,67 +0,0 @@
1
- <div id="main">
2
- <div class="block" id="block-tables">
3
-
4
- <div class="content rounded">
5
- <div class='validate_model_umbrella'>
6
-
7
- <div class='lhs'>
8
- <h2 class="title">Validate model</h2>
9
- <div id='error'></div>
10
-
11
- <div id='tid' style='display:none'><%=@tid%></div>
12
-
13
-
14
- <% form_tag "/admin_data/diagnostic/validate_model?tid=#{@tid}", :method => "post", :id => "validate_model_form" do |f| %>
15
- <%= check_box_tag 'validate_model_select_all' %>
16
- <strong>
17
- <%= label_tag 'Select all models', nil, :for => 'validate_model_select_all' %>
18
- </strong>
19
- <% $admin_data_klasses.each do |klass| %>
20
- <p>
21
- <%= check_box_tag klass.name, '1', false, :name => "model[#{klass.name}]" %>
22
- <%= label_tag klass.name, nil, :id => klass.name.downcase.underscore %>
23
- </p>
24
- <% end %>
25
- <%= submit_tag('Start validation', :id => 'submit') %>
26
- <% end %>
27
-
28
- <h3>Previous runs</h3>
29
- <%@tids.each do |tid| %>
30
- <p><%= link_to tid, "/admin_data/diagnostic/tid/#{tid}" %></p>
31
- <% end %>
32
-
33
- </div>
34
-
35
- <div class='rhs'>
36
- <h2 id='validation_result'>
37
- Validation result
38
- </h2>
39
- <div id='validate_model_rhs_data'></div>
40
- </div>
41
-
42
- <div class='clear'></div>
43
- </div>
44
- </div>
45
- </div>
46
- </div>
47
-
48
- <style>
49
- .lhs {
50
- float: left;
51
- width: 300px;
52
- }
53
- .rhs {
54
- float: left;
55
- }
56
- #error {
57
- color: red;
58
- font-size: 120%;
59
- }
60
- #validate_model_form {
61
- padding: 10px;
62
- }
63
- #validation_result {
64
- display: none;
65
- margin-left: 0;
66
- }
67
- </style>
@@ -1,119 +0,0 @@
1
-
2
- ol#qunit-tests {
3
- font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
4
- margin:0;
5
- padding:0;
6
- list-style-position:inside;
7
-
8
- font-size: smaller;
9
- }
10
- ol#qunit-tests li{
11
- padding:0.4em 0.5em 0.4em 2.5em;
12
- border-bottom:1px solid #fff;
13
- font-size:small;
14
- list-style-position:inside;
15
- }
16
- ol#qunit-tests li ol{
17
- box-shadow: inset 0px 2px 13px #999;
18
- -moz-box-shadow: inset 0px 2px 13px #999;
19
- -webkit-box-shadow: inset 0px 2px 13px #999;
20
- margin-top:0.5em;
21
- margin-left:0;
22
- padding:0.5em;
23
- background-color:#fff;
24
- border-radius:15px;
25
- -moz-border-radius: 15px;
26
- -webkit-border-radius: 15px;
27
- }
28
- ol#qunit-tests li li{
29
- border-bottom:none;
30
- margin:0.5em;
31
- background-color:#fff;
32
- list-style-position: inside;
33
- padding:0.4em 0.5em 0.4em 0.5em;
34
- }
35
-
36
- ol#qunit-tests li li.pass{
37
- border-left:26px solid #C6E746;
38
- background-color:#fff;
39
- color:#5E740B;
40
- }
41
- ol#qunit-tests li li.fail{
42
- border-left:26px solid #EE5757;
43
- background-color:#fff;
44
- color:#710909;
45
- }
46
- ol#qunit-tests li.pass{
47
- background-color:#D2E0E6;
48
- color:#528CE0;
49
- }
50
- ol#qunit-tests li.fail{
51
- background-color:#EE5757;
52
- color:#000;
53
- }
54
- ol#qunit-tests li strong {
55
- cursor:pointer;
56
- }
57
- h1#qunit-header{
58
- background-color:#0d3349;
59
- margin:0;
60
- padding:0.5em 0 0.5em 1em;
61
- color:#fff;
62
- font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
63
- border-top-right-radius:15px;
64
- border-top-left-radius:15px;
65
- -moz-border-radius-topright:15px;
66
- -moz-border-radius-topleft:15px;
67
- -webkit-border-top-right-radius:15px;
68
- -webkit-border-top-left-radius:15px;
69
- text-shadow: rgba(0, 0, 0, 0.5) 4px 4px 1px;
70
- }
71
- h2#qunit-banner{
72
- font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
73
- height:5px;
74
- margin:0;
75
- padding:0;
76
- }
77
- h2#qunit-banner.qunit-pass{
78
- background-color:#C6E746;
79
- }
80
- h2#qunit-banner.qunit-fail, #qunit-testrunner-toolbar {
81
- background-color:#EE5757;
82
- }
83
- #qunit-testrunner-toolbar {
84
- font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
85
- padding:0;
86
- /*width:80%;*/
87
- padding:0em 0 0.5em 2em;
88
- font-size: small;
89
- }
90
- h2#qunit-userAgent {
91
- font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
92
- background-color:#2b81af;
93
- margin:0;
94
- padding:0;
95
- color:#fff;
96
- font-size: small;
97
- padding:0.5em 0 0.5em 2.5em;
98
- text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
99
- }
100
- p#qunit-testresult{
101
- font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
102
- margin:0;
103
- font-size: small;
104
- color:#2b81af;
105
- border-bottom-right-radius:15px;
106
- border-bottom-left-radius:15px;
107
- -moz-border-radius-bottomright:15px;
108
- -moz-border-radius-bottomleft:15px;
109
- -webkit-border-bottom-right-radius:15px;
110
- -webkit-border-bottom-left-radius:15px;
111
- background-color:#D2E0E6;
112
- padding:0.5em 0.5em 0.5em 2.5em;
113
- }
114
- strong b.fail{
115
- color:#710909;
116
- }
117
- strong b.pass{
118
- color:#5E740B;
119
- }
@@ -1,7 +0,0 @@
1
- namespace :admin_data do
2
- desc "Copy views from the admin_data plugin into your application (so you can customize them)"
3
- task :localize_views do
4
- require "#{File.dirname(__FILE__)}/../lib/admin_data/admin_data_tasks"
5
- AdminDataTasks.copy_views_to_app
6
- end
7
- end
@@ -1,23 +0,0 @@
1
- #
2
- # Usage :
3
- # rake admin_data:validate_models_bg RAILS_ENV='development' KLASSES='Country,PhoneNumber,Website' TID='20100107095100'
4
- #
5
- require 'fileutils'
6
- namespace :admin_data do
7
- desc "Run model valiations"
8
- task :validate_models_bg => :environment do
9
- begin
10
- usage = %Q{ rake admin_data:validate_models_bg RAILS_ENV='development' KLASSES='Country,EeeSociety,PhoneNumber,Website,Car,User' TID='20100107095100' }
11
- usage = ' Usage: ' + usage
12
- tid = ENV['TID'].try(:to_s)
13
- raise "tid is blank. #{usage} " if tid.blank?
14
-
15
- klasses = ENV['KLASSES']
16
- klasses.split(',').compact.each { |klasss| AdminData::RakeUtil.process_klass(klasss, tid) }
17
-
18
- AdminData::Util.write_to_validation_file('', 'a', tid,'done.txt')
19
- rescue Exception => e
20
- AdminData::Util.write_to_validation_file(AdminData::Util.exception_info(e), 'a', 'rake_errors.txt')
21
- end
22
- end
23
- end