admin_data 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. data/History.txt +221 -0
  2. data/README.textile +21 -0
  3. data/Rakefile +46 -0
  4. data/app/controllers/admin_data/base_controller.rb +114 -0
  5. data/app/controllers/admin_data/diagnostic_controller.rb +28 -0
  6. data/app/controllers/admin_data/feed_controller.rb +17 -0
  7. data/app/controllers/admin_data/main_controller.rb +132 -0
  8. data/app/controllers/admin_data/migration_controller.rb +19 -0
  9. data/app/controllers/admin_data/search_controller.rb +125 -0
  10. data/app/controllers/admin_data/validate_model_controller.rb +106 -0
  11. data/app/views/admin_data/diagnostic/index.html.erb +17 -0
  12. data/app/views/admin_data/diagnostic/missing_index.html.erb +26 -0
  13. data/app/views/admin_data/feed/index.rss.builder +24 -0
  14. data/app/views/admin_data/main/all_models.html.erb +22 -0
  15. data/app/views/admin_data/main/association/_association_info.html.erb +10 -0
  16. data/app/views/admin_data/main/association/_belongs_to_info.html.erb +7 -0
  17. data/app/views/admin_data/main/association/_has_many_info.html.erb +7 -0
  18. data/app/views/admin_data/main/association/_has_one_info.html.erb +6 -0
  19. data/app/views/admin_data/main/edit.html.erb +38 -0
  20. data/app/views/admin_data/main/misc/_form.html.erb +25 -0
  21. data/app/views/admin_data/main/misc/_modify_record.html.erb +22 -0
  22. data/app/views/admin_data/main/new.html.erb +23 -0
  23. data/app/views/admin_data/main/show.html.erb +41 -0
  24. data/app/views/admin_data/main/table_structure.html.erb +55 -0
  25. data/app/views/admin_data/migration/index.html.erb +18 -0
  26. data/app/views/admin_data/migration/jstest.html.erb +51 -0
  27. data/app/views/admin_data/search/_search_base.html.erb +34 -0
  28. data/app/views/admin_data/search/advance_search.html.erb +3 -0
  29. data/app/views/admin_data/search/quick_search.html.erb +6 -0
  30. data/app/views/admin_data/search/search/_advance_search_form.html.erb +48 -0
  31. data/app/views/admin_data/search/search/_errors.html.erb +5 -0
  32. data/app/views/admin_data/search/search/_listing.html.erb +40 -0
  33. data/app/views/admin_data/search/search/_search_form.html.erb +28 -0
  34. data/app/views/admin_data/search/search/_sortby.html.erb +18 -0
  35. data/app/views/admin_data/search/search/_title.html.erb +34 -0
  36. data/app/views/admin_data/shared/_breadcrum.html.erb +10 -0
  37. data/app/views/admin_data/shared/_drop_down_klasses.html.erb +4 -0
  38. data/app/views/admin_data/shared/_flash_message.html.erb +13 -0
  39. data/app/views/admin_data/shared/_header.html.erb +23 -0
  40. data/app/views/admin_data/shared/_powered_by.html.erb +23 -0
  41. data/app/views/admin_data/shared/_secondary_navigation.html.erb +28 -0
  42. data/app/views/admin_data/validate_model/_bad.html.erb +1 -0
  43. data/app/views/admin_data/validate_model/tid.html.erb +2 -0
  44. data/app/views/admin_data/validate_model/validate.html.erb +67 -0
  45. data/app/views/layouts/admin_data.html.erb +60 -0
  46. data/config/routes.rb +34 -0
  47. data/init.rb +1 -0
  48. data/lib/admin_data.rb +34 -0
  49. data/lib/admin_data/chelper.rb +37 -0
  50. data/lib/admin_data/compatibility.rb +7 -0
  51. data/lib/admin_data/helpers.rb +222 -0
  52. data/lib/admin_data/railtie.rb +21 -0
  53. data/lib/admin_data/search.rb +186 -0
  54. data/lib/admin_data/settings.rb +72 -0
  55. data/lib/admin_data/util.rb +237 -0
  56. data/lib/admin_data/version.rb +3 -0
  57. data/lib/admin_data_date_validation.rb +79 -0
  58. data/lib/css/app.css +224 -0
  59. data/lib/css/base.css +1071 -0
  60. data/lib/css/header.css +65 -0
  61. data/lib/css/rounded.css +18 -0
  62. data/lib/css/themes/drastic-dark/style.css +374 -0
  63. data/lib/css/umbrella.css +34 -0
  64. data/lib/css/vendor/images/ui-bg_diagonals-thick_75_f3d8d8_40x40.png +0 -0
  65. data/lib/css/vendor/images/ui-bg_dots-small_65_a6a6a6_2x2.png +0 -0
  66. data/lib/css/vendor/images/ui-bg_flat_0_333333_40x100.png +0 -0
  67. data/lib/css/vendor/images/ui-bg_flat_65_ffffff_40x100.png +0 -0
  68. data/lib/css/vendor/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  69. data/lib/css/vendor/images/ui-bg_glass_55_fbf8ee_1x400.png +0 -0
  70. data/lib/css/vendor/images/ui-bg_highlight-hard_100_eeeeee_1x100.png +0 -0
  71. data/lib/css/vendor/images/ui-bg_highlight-hard_100_f6f6f6_1x100.png +0 -0
  72. data/lib/css/vendor/images/ui-bg_highlight-soft_15_cc0000_1x100.png +0 -0
  73. data/lib/css/vendor/images/ui-icons_004276_256x240.png +0 -0
  74. data/lib/css/vendor/images/ui-icons_cc0000_256x240.png +0 -0
  75. data/lib/css/vendor/images/ui-icons_ffffff_256x240.png +0 -0
  76. data/lib/css/vendor/jquery-ui-1.7.2.custom.css +406 -0
  77. data/lib/css/vendor/qunit.css +119 -0
  78. data/lib/js/advance_search/act_on_result.js +47 -0
  79. data/lib/js/advance_search/adv_search.js +46 -0
  80. data/lib/js/advance_search/advance_search.js +60 -0
  81. data/lib/js/advance_search/advance_search_structure.js +79 -0
  82. data/lib/js/advance_search/ajaxify_advance_search.js +28 -0
  83. data/lib/js/advance_search/build_first_row.js +12 -0
  84. data/lib/js/advance_search/event_bindings.js +87 -0
  85. data/lib/js/advance_search/global_ajax_setting.js +10 -0
  86. data/lib/js/advance_search/trigger_submit_on_domready.js +6 -0
  87. data/lib/js/misc/drop_down_change.js +8 -0
  88. data/lib/js/misc/js_util.js +42 -0
  89. data/lib/js/misc/quick_search_input_focus.js +6 -0
  90. data/lib/js/test/act_on_result.js +120 -0
  91. data/lib/js/test/advance_search.js +80 -0
  92. data/lib/js/test/ajaxify_advance_search.js +29 -0
  93. data/lib/js/test/build_first_row.js +10 -0
  94. data/lib/js/test/event_bindings.js +100 -0
  95. data/lib/js/validate_model/ajaxify_form.js +66 -0
  96. data/lib/js/validate_model/select_all.js +15 -0
  97. data/lib/js/vendor/jack.js +903 -0
  98. data/lib/js/vendor/jquery-1.4.1.js +6078 -0
  99. data/lib/js/vendor/jquery-ui-1.7.2.custom.min.js +298 -0
  100. data/lib/js/vendor/jquery.ba-isjquery.js +21 -0
  101. data/lib/js/vendor/jquery.form.js +814 -0
  102. data/lib/js/vendor/jquery.lint.js +604 -0
  103. data/lib/js/vendor/log.js +9 -0
  104. data/lib/js/vendor/qunit.js +1043 -0
  105. data/lib/tasks/admin_data_tasks.rake +7 -0
  106. data/lib/tasks/validate_models_bg.rake +23 -0
  107. data/test/factories/article.rb +9 -0
  108. data/test/factories/car.rb +4 -0
  109. data/test/factories/city.rb +4 -0
  110. data/test/factories/comment.rb +6 -0
  111. data/test/factories/door.rb +4 -0
  112. data/test/factories/engine.rb +4 -0
  113. data/test/functional/base_controller_test.rb +5 -0
  114. data/test/functional/feed_controller_test.rb +34 -0
  115. data/test/functional/main_controller_test.rb +421 -0
  116. data/test/functional/migration_controller_test.rb +30 -0
  117. data/test/functional/routes_test.rb +61 -0
  118. data/test/functional/search_controller_test.rb +814 -0
  119. data/test/helper/view_helper_test.rb +177 -0
  120. data/test/misc_tests/date_validation_test.rb +32 -0
  121. data/test/misc_tests/settings_test.rb +29 -0
  122. data/test/misc_tests/util_test.rb +83 -0
  123. data/test/rails_root/Gemfile +22 -0
  124. data/test/rails_root/Gemfile.lock +101 -0
  125. data/test/rails_root/Rakefile +7 -0
  126. data/test/rails_root/app/controllers/application_controller.rb +3 -0
  127. data/test/rails_root/app/helpers/application_helper.rb +2 -0
  128. data/test/rails_root/app/models/article.rb +25 -0
  129. data/test/rails_root/app/models/city.rb +15 -0
  130. data/test/rails_root/app/models/comment.rb +13 -0
  131. data/test/rails_root/app/models/tech_magazine.rb +2 -0
  132. data/test/rails_root/app/models/vehicle/car.rb +4 -0
  133. data/test/rails_root/app/models/vehicle/door.rb +3 -0
  134. data/test/rails_root/app/models/vehicle/engine.rb +3 -0
  135. data/test/rails_root/app/views/layouts/application.html.erb +14 -0
  136. data/test/rails_root/config.ru +4 -0
  137. data/test/rails_root/config/application.rb +42 -0
  138. data/test/rails_root/config/boot.rb +13 -0
  139. data/test/rails_root/config/database.yml +22 -0
  140. data/test/rails_root/config/environment.rb +5 -0
  141. data/test/rails_root/config/environments/development.rb +22 -0
  142. data/test/rails_root/config/environments/production.rb +49 -0
  143. data/test/rails_root/config/environments/test.rb +35 -0
  144. data/test/rails_root/config/initializers/backtrace_silencers.rb +7 -0
  145. data/test/rails_root/config/initializers/inflections.rb +10 -0
  146. data/test/rails_root/config/initializers/mime_types.rb +5 -0
  147. data/test/rails_root/config/initializers/secret_token.rb +7 -0
  148. data/test/rails_root/config/initializers/session_store.rb +8 -0
  149. data/test/rails_root/config/locales/en.yml +5 -0
  150. data/test/rails_root/config/routes.rb +58 -0
  151. data/test/rails_root/db/migrate/20090809061114_create_tables.rb +70 -0
  152. data/test/rails_root/db/schema.rb +74 -0
  153. data/test/rails_root/db/seeds.rb +7 -0
  154. data/test/rails_root/script/rails +6 -0
  155. data/test/rails_root/test/performance/browsing_test.rb +0 -0
  156. data/test/rails_root/test/test_helper.rb +13 -0
  157. data/test/support/assertions.rb +20 -0
  158. data/test/test_helper.rb +74 -0
  159. metadata +321 -0
data/History.txt ADDED
@@ -0,0 +1,221 @@
1
+ === 2010-04-14
2
+
3
+ * JavaScript code refactoring
4
+ * More JavaScript code test
5
+ * Moved functionalities from layout to helper
6
+
7
+ === 0.0.37 2010-01-28
8
+
9
+ * refactored the code to take inline style out to style section
10
+ * moves a lot of ruby code from view to helpers and controllers
11
+ * better indentation
12
+
13
+ === 0.0.36 2010-01-05
14
+
15
+ * Fixing the online validation of models that have primary key not id
16
+
17
+ === 0.0.35 2010-01-05
18
+
19
+ * If invalid children value is passed in apply rescue
20
+
21
+ === 0.0.34 2010-01-04
22
+
23
+ * updated README
24
+
25
+ === 0.0.33 2009-12-27
26
+
27
+ * added authentication for feed
28
+
29
+ === 0.0.32 2009-12-23
30
+
31
+ * the default search result for advance search should be primary key des
32
+ * changed the layout for quick search
33
+
34
+ === 0.0.31 2009-12-15
35
+
36
+ * association information is rescued so that show method works even if association info throws error
37
+ * association info is displayed with belongs_to or has_many name instead of class name
38
+ * debugging variable $debug_admin_data
39
+
40
+ === 0.0.30 2009-12-02
41
+
42
+ * RSS feed for all the models
43
+
44
+ === 0.0.29 2009-11-18
45
+
46
+ * rake task to validate all the models
47
+ * ability to validate all the models using browser
48
+ * increased the font size of overall app
49
+
50
+ === 0.0.28 2009-11-12
51
+
52
+ * has_many association_info were too close to each other
53
+ * fixing the issue where a class is used as a hash key. It breaks in development
54
+
55
+ === 0.0.28 2009-11-11
56
+
57
+ * better link color
58
+
59
+ === 0.0.28 2009-11-11
60
+
61
+ * refactored the way advance search JavaScript code
62
+ * for pretty urls like /42-SEO-friendly-title the show method should pickup 42 as id
63
+
64
+ === 0.0.27 2009-11-04
65
+
66
+ * test for has_one association
67
+
68
+ === 0.0.26 2009-11-04
69
+
70
+ * cleaning up History.txt file
71
+
72
+ === 0.0.25 2009-11-03
73
+
74
+ * fix for issue #14 so that not like will also include records which are null
75
+
76
+ === 0.0.24 2009-11-03
77
+
78
+ * advance search refactoring
79
+
80
+ === 0.0.23 2009-10-29
81
+
82
+ * advance search bug fix
83
+
84
+ === 0.0.22 2009-10-26
85
+
86
+ * fixed adding rows on advanced search
87
+ * consistenly use model_id for search and association parent objects
88
+ * datetime/date/time fixes on edit and advanced search pages
89
+ * added configuration to not use admin_data layout and use application one instead
90
+
91
+ === 0.0.21 2009-10-26
92
+
93
+ * fixed the formatting issue while displaying missing index in diagnostic section
94
+ * by passing additional parameter called 'attr' editing of a record would display
95
+ only one field to avoid any accidental change.
96
+
97
+ === 0.0.20 2009-10-22
98
+
99
+ * warning message if JavaScript is disabled
100
+
101
+ === 0.0.19 2009-10-20
102
+
103
+ * ability to pass :find_conditions to settings so that models with to_param method could
104
+ override the sql that is built by admin_data
105
+
106
+ === 0.0.18 2009-10-16
107
+
108
+ * changed theme from warehouse to dark because the association info on the right
109
+ hand side was not appearing correctly
110
+ * homepage should have main tab selected
111
+ * changed urls to support models that override to_param to other than id
112
+ * fixed the sorting order. model a, model B and model A/Q was being sorted
113
+ as A,Q,B instead of A,B,Q.
114
+
115
+ === 0.0.17 2009-10-08
116
+
117
+ * drop down of klasses is now available at the center of home page
118
+ * current model will be selected in the drop down
119
+
120
+ === 0.0.16 2009-10-07
121
+
122
+ * form UI foreign keys are dropdown (display name attribute if it exists and id otherwise)
123
+ * form UI date fields use date_select (with free text year since we cannot guess a good range)
124
+ * form UI refactored to use form_for instead of form_tag and hadcoded html
125
+
126
+ === 0.0.15 2009-10-06
127
+
128
+ * cache the list of models
129
+ * advance search refactoring
130
+ * jQuery UI datepicker for date field
131
+ * advance search now shows validation error for integer and date fields
132
+ * log.js for easy logging in JavaScript
133
+
134
+ === 0.0.14 2009-10-05
135
+
136
+ * while editing match was being done for hard coded value id. Now it looks for klass.primary_key
137
+
138
+ === 0.0.13 2009-10-04
139
+
140
+ * fixed IE7 bug
141
+
142
+ === 0.0.12 2009-10-04
143
+
144
+ * fixed bug regarding integer values not appearning in listing
145
+ * better indentation
146
+
147
+ === 0.0.11 2009-10-01
148
+
149
+ * Major contribution in this release by Alex Rothenberg. http://github.com/alexrothenberg
150
+ * this plugin now treats each model as a restful resource.
151
+ * security fix and test for it
152
+ * commented out offending code for has_one relationship
153
+ * has_one and habtm relationships along with test would be taken up in next release
154
+
155
+ === 0.0.11 2009-09-28
156
+
157
+ * renamed quick search to search
158
+ * using jQuery theme to make drop down boxes jazzier
159
+ * more tests
160
+ * moved some inline css to external css file
161
+
162
+ === 0.0.10 2009-09-18
163
+
164
+ * fixed listing and has_many association info for namespaced model
165
+
166
+ === 0.0.9 2009-09-18
167
+
168
+ * fixed security issue
169
+
170
+ === 0.0.8 2009-09-18
171
+
172
+ * do not assume that primary key is 'id' . Respect the primary key set by model.
173
+
174
+ * test for alternate primary key
175
+
176
+ === 0.0.7 2009-09-17
177
+
178
+ * fixed test for Vehicle::Car
179
+
180
+ === 0.0.6 2009-09-09
181
+
182
+ * more tests for the plugin. Now 151 tests and 229 assertions
183
+
184
+ * support for name spaced models like Vehicle::Car and Vehicle::Engine
185
+
186
+ * fixed a bug related to advance search
187
+
188
+ * refactored JavaScript code for advance search
189
+
190
+ === 0.0.5 2009-09-04
191
+
192
+ * tests for the plugin
193
+
194
+ * changed the way security configiruation is passed to the plugin
195
+
196
+ * users can configure number of records in a page. Default is 50
197
+
198
+ * fixed bug associated with advance search
199
+
200
+ * added link to report bug in footer
201
+
202
+ * fixed bug in date parsing
203
+
204
+ === 0.0.4 2009-08-28
205
+
206
+ * storing serialized array in string causing problem in truncate method. more at
207
+ http://github.com/neerajdotname/admin_data/issues#issue/3.
208
+
209
+ === 0.0.3 2009-08-10
210
+
211
+ * not requiring rubygems
212
+ * if will_paginate is missing then not raising exception
213
+
214
+ === 0.0.2 2009-07-06
215
+
216
+ * ability to sort records
217
+ * better visual clue that search is in progress
218
+
219
+ === 0.0.1 2009-05-01
220
+
221
+ * Initial release
data/README.textile ADDED
@@ -0,0 +1,21 @@
1
+ h1. This plugin works with rails3. "More information is available here":http://neerajdotname.github.com/admin_data/#howtousethispluginwithrails3
2
+
3
+ h1. Live Demo
4
+
5
+ "http://demo.neeraj.name/admin_data":http://demo.neeraj.name/admin_data
6
+
7
+ h1. Documentation
8
+
9
+ "http://neerajdotname.github.com/admin_data":http://neerajdotname.github.com/admin_data
10
+
11
+ h1. JavaScript Unit tests live result
12
+
13
+ "http://demo.neeraj.name/admin_data/jstest":http://demo.neeraj.name/admin_data/jstest
14
+
15
+ h1. Source code
16
+
17
+ "http://github.com/neerajdotname/admin_data":http://github.com/neerajdotname/admin_data
18
+
19
+ h2. License
20
+
21
+ Dual licensed under the "MIT":http://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt and "GPL version 2":http://github.com/jquery/jquery/blob/master/GPL-LICENSE.txt licenses.
data/Rakefile ADDED
@@ -0,0 +1,46 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ desc 'Test admin_data plugin.'
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << 'lib' << 'test'
11
+ t.pattern = 'test/**/*_test.rb'
12
+ t.verbose = true
13
+ end
14
+
15
+ desc 'Generate documentation for admin_data plugin.'
16
+ Rake::RDocTask.new(:rdoc) do |rdoc|
17
+ rdoc.rdoc_dir = 'rdoc'
18
+ rdoc.title = 'AdminData'
19
+ rdoc.options << '--line-numbers' << '--inline-source'
20
+ rdoc.rdoc_files.include('README.textile')
21
+ rdoc.rdoc_files.include('lib/**/*.rb')
22
+ end
23
+
24
+ begin
25
+ require 'jeweler'
26
+ require './lib/admin_data/version'
27
+ Jeweler::Tasks.new do |s|
28
+ s.name = "admin_data"
29
+ s.version = AdminData::VERSION
30
+ s.summary = s.description = "Manage database using browser"
31
+ s.email = "neerajdotname@gmail.com"
32
+ s.homepage = "http://github.com/neerajdotname/admin_data"
33
+ s.authors = ['Neeraj Singh']
34
+ s.files = FileList["[A-Z]*", "{app,config,lib,test}/**/*", 'init.rb']
35
+
36
+ s.add_dependency 'will_paginate'
37
+
38
+ s.add_development_dependency 'flexmock'
39
+ s.add_development_dependency 'shoulda'
40
+ s.add_development_dependency 'factory_girl'
41
+ s.add_development_dependency 'nokogiri'
42
+ end
43
+ Jeweler::GemcutterTasks.new
44
+ rescue LoadError => le
45
+ puts "Jeweler not available. Install it for jeweler-related tasks with: gem install jeweler: #{le.message}"
46
+ end
@@ -0,0 +1,114 @@
1
+ class AdminData::BaseController < ApplicationController
2
+
3
+ unloadable
4
+
5
+ helper_method :admin_data_is_allowed_to_update?
6
+
7
+ layout 'admin_data'
8
+
9
+ include AdminData::Chelper
10
+
11
+ before_filter :rails3_hack, :build_klasses, :build_drop_down_for_klasses, :check_page_parameter, :prepare_drop_down_klasses
12
+
13
+ attr_reader :klass
14
+ attr_reader :model
15
+
16
+ private
17
+
18
+ def prepare_drop_down_klasses
19
+ k = params[:klass] || ''
20
+ @drop_down_url = "http://#{request.host_with_port}/admin_data/quick_search/#{CGI.escape(k)}"
21
+ end
22
+
23
+ def ensure_is_allowed_to_view
24
+ render :text => '<h2>not authorized</h2>', :status => :unauthorized unless admin_data_is_allowed_to_view?
25
+ end
26
+
27
+ def ensure_is_allowed_to_view_model
28
+ render :text => 'not authorized', :status => :unauthorized unless admin_data_is_allowed_to_view_model?
29
+ end
30
+
31
+ def ensure_is_allowed_to_update
32
+ render :text => 'not authorized', :status => :unauthorized unless admin_data_is_allowed_to_update?
33
+ end
34
+
35
+ def ensure_is_allowed_to_update_model
36
+ render :text => 'not authorized', :status => :unauthorized unless admin_data_is_allowed_to_update_model?
37
+ end
38
+
39
+ def ensure_is_allowed_to_view_feed
40
+ render :text => 'not authorized', :status => :unauthorized unless AdminData::Util.is_allowed_to_view_feed?(self)
41
+ end
42
+
43
+ def get_class_from_params
44
+ begin
45
+ @klass = AdminData::Util.camelize_constantize(params[:klass])
46
+ rescue TypeError => e # in case no params[:klass] is supplied
47
+ Rails.logger.debug 'no params[:klass] was supplied'
48
+ redirect_to admin_data_index_path
49
+ rescue NameError # in case wrong params[:klass] is supplied
50
+ Rails.logger.debug 'wrong params[:klass] was supplied'
51
+ redirect_to admin_data_index_path
52
+ end
53
+ end
54
+
55
+ def build_klasses
56
+ unless defined? $admin_data_klasses
57
+ model_dir = File.join(Rails.root, 'app', 'models')
58
+ model_names = Dir.chdir(model_dir) { Dir["**/*.rb"] }
59
+ klasses = get_klass_names(model_names)
60
+ filtered_klasses = remove_klasses_without_table(klasses).sort_by {|r| r.name.underscore}
61
+ klasses_with_security_clearance = filtered_klasses.select do |klass_local|
62
+ @klass = klass_local
63
+ admin_data_is_allowed_to_view_model?
64
+ end
65
+ #TODO remove global constant. it is not thread safe
66
+ $admin_data_klasses = klasses_with_security_clearance
67
+ puts $admin_data_klasses.inspect
68
+ end
69
+ @klasses = $admin_data_klasses
70
+ end
71
+
72
+ def remove_klasses_without_table(klasses)
73
+ klasses.select { |k| k.ancestors.include?(ActiveRecord::Base) &&
74
+ k.connection.table_exists?(k.table_name) }
75
+ end
76
+
77
+ def get_klass_names(model_names)
78
+ model_names.inject([]) do |output, model_name|
79
+ klass_name = model_name.sub(/\.rb$/,'').camelize
80
+ begin
81
+ output << AdminData::Util.constantize_klass(klass_name)
82
+ rescue Exception => e
83
+ Rails.logger.debug e.message
84
+ end
85
+ output
86
+ end
87
+ end
88
+
89
+ def build_drop_down_for_klasses
90
+ @drop_down_for_klasses = @klasses.inject([]) do |result,klass|
91
+ #TODO FIXME for some weird reason tests fail if I don't do this
92
+ if Rails.env.test?
93
+ result
94
+ else
95
+ result << [klass.name.underscore, admin_data_search_url(:klass => klass.name.underscore)]
96
+ end
97
+ end
98
+ end
99
+
100
+ def check_page_parameter
101
+ # Got hoptoad error because of url like http://localhost:3000/admin_data/User/advance_search?page=http://201.134.249.164/intranet/on.txt?
102
+ if params[:page].blank? || (params[:page] =~ /\A\d+\z/)
103
+ # proceed
104
+ else
105
+ render :text => 'Invalid params[:page]', :status => :unprocessable_entity
106
+ end
107
+ end
108
+
109
+ def rails3_hack
110
+ #require_dependency File.join(Rails.root, 'vendor', 'plugins', 'admin_data', 'lib', 'admin_data', 'settings.rb')
111
+ #AdminData::Config.initialize_defaults
112
+ end
113
+
114
+ end
@@ -0,0 +1,28 @@
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
@@ -0,0 +1,17 @@
1
+ class AdminData::FeedController < AdminData::BaseController
2
+
3
+ unloadable
4
+
5
+ before_filter :ensure_is_allowed_to_view_feed
6
+
7
+ def index
8
+ render :text => "usage: http://localhost:3000/admin_data/feed/user" and return if params[:klasss].blank?
9
+
10
+ begin
11
+ @klass = AdminData::Util.camelize_constantize(params[:klasss])
12
+ rescue NameError => e
13
+ render :text => "No constant was found with name #{params[:klasss]}" and return
14
+ end
15
+ end
16
+
17
+ end