aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/public_body.rb
Commit message (Collapse)AuthorAgeLines
* Fix the command-line CSV importer under Ruby 1.9Mark Longair2013-12-03-4/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Under Ruby 1.8.7, you can parse a CSV file with the following code (Example A): require 'csv' CSV.parse('foo.csv') do |row| puts "got row: #{row.inspect}" end Rather confusingly, under Ruby 1.8.7, CSV.parse can also take a string representation of the contents of the file as its parameter, so this also works (Example B): require 'csv' CSV.parse("1,hello,red\n2,goodbye,green") do |row| puts "got row: #{row.inspect}" end However under Ruby 1.9.3, CSV.parse only expects a string representation of the contents of the CSV file, so only Example B works; Example B fails silently (interpreting the filename as a single cell CSV file, typically). The import:import_csv rake task unfortunately relied on both A and B working. This commit fixes this by adding PublicBody.import_csv_from_file, and refactoring PublicBody.import_csv to use the newly added class method, and adds a test to check for any regression in this behaviour. (This means that the usage of import_csv in the admin public body controller's import_csv action could now be changed to use PublicBody.import_csv_from_file directly from the uploaded file, which would be more efficient and cope with larger files without using lots of memory.) Fixes #1229
* Merge remote-tracking branch 'origin/merged-rails-3-2-assset-pipeline' into ↵Louise Crow2013-11-29-1/+0
|\ | | | | | | | | | | | | rails-3-develop Conflicts: Gemfile.lock
| * Merge branch 'feature/rails-3-2-upgrade-spike' into ↵Mark Longair2013-11-29-1/+0
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | feature/switch-to-asset-pipeline Conflicts: Gemfile.lock app/assets/images/admin-theme/ui-bg_flat_0_aaaaaa_40x100.png app/assets/images/admin-theme/ui-bg_flat_55_fbf9ee_40x100.png app/assets/images/admin-theme/ui-bg_flat_65_ffffff_40x100.png app/assets/images/admin-theme/ui-bg_flat_75_cccccc_40x100.png app/assets/images/admin-theme/ui-bg_flat_75_dadada_40x100.png app/assets/images/admin-theme/ui-bg_flat_75_e6e6e6_40x100.png app/assets/images/admin-theme/ui-bg_flat_75_ffffff_40x100.png app/assets/images/admin-theme/ui-bg_inset-soft_95_fef1ec_1x100.png app/assets/images/admin-theme/ui-icons_222222_256x240.png app/assets/images/admin-theme/ui-icons_2e83ff_256x240.png app/assets/images/admin-theme/ui-icons_454545_256x240.png app/assets/images/admin-theme/ui-icons_888888_256x240.png app/assets/images/admin-theme/ui-icons_cd0a0a_256x240.png app/assets/javascripts/admin.js app/assets/javascripts/admin/jquery-ui.min.js app/assets/javascripts/application.js app/assets/javascripts/jquery-ui.min.js app/assets/javascripts/jquery.flot.errorbars.min.js app/assets/javascripts/jquery.flot.min.js app/assets/javascripts/stats.js app/assets/stylesheets/application.css app/assets/stylesheets/fonts.scss app/views/general/_stylesheet_includes.html.erb app/views/layouts/admin.html.erb app/views/layouts/default.html.erb app/views/public_body/statistics.html.erb config/application.rb config/environments/development.rb
| | * Remove virtual attribute created_atLouise Crow2013-11-12-1/+0
| | | | | | | | | | | | | | | | | | The need for this was removed in 0ec315c52a731ff149977b9231a15770fa3bd742, and it now causes a MissingAttribute error.
* | | Use built-in SQL quoting.Louise Crow2013-11-25-2/+3
| | |
* | | Move getting popular bodies into a model method.Louise Crow2013-11-25-0/+23
|/ /
* | Reduce the memory used to serve /body/all-authorities.csvMark Longair2013-11-14-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On WDTK, /body/all-authorities was using lots of memory - this commit reduces that by (a) fetching the public bodies in batches, rather than keeping them all in memory at one time and (b) writing the CSV to a file and then returning it with X-Sendfile (or equivalent), rather than returning the whole file from memory with send_data. There's a FIXME to do with the layout of download directories; if that's changed, the example nginx config, etc. will need to be updated too. This commit also adds a basic test for reasonable CSV being returned and switches from FasterCSV to CSV in order to fix this NotImplementedError under Ruby 1.9: Please switch to Ruby 1.9's standard CSV library. It's FasterCSV plus support for Ruby 1.9's m17n encoding engine. (The CSV version seems to still work fine under 1.8.7.)
* | Don't include public bodies tagged 'test' in public body statisticsMark Longair2013-11-07-2/+12
| | | | | | | | | | | | | | | | | | | | In the initial release of public body statistics to WhatDoTheyKnow a public body only intended for testing ("mySociety Test Quango") was included in the statistics. This commit causes public bodies tagged with "test" to be excluded from the public body statistics page. Fixes #1115.
* | Add "(n)" to the tooltips on the stats graphsMark Longair2013-11-05-2/+4
| |
* | For percentage stats, exclude hidden or unclassified requestsMark Longair2013-11-05-1/+1
| | | | | | | | | | | | | | | | The WDTK volunteers pointed out that it's not fair to include hidden requests in the denominator, since they're typically hidden for a good reason (e.g. being vexatious, spam, etc.), and we have no information about those that are awaiting_description (i.e. unclassified) so they should be excluded as well.
* | Add a info_requests_visible_classified_count column to PublicBodyMark Longair2013-11-05-20/+22
| | | | | | | | | | | | This counts only those info requests that have prominence 'normal' (i.e. are not hidden) and are not 'awaiting_description' (i.e. that they have had some basic status classification).
* | Update the helpful model schema annotationsMark Longair2013-11-01-17/+20
| | | | | | | | These are regenerated with "bundle exec annotate"
* | Add a rake task to import public bodies from a CSV fileMark Longair2013-10-15-0/+2
| | | | | | | | | | | | | | | | For importing a very large number of public bodies, it's mostly likely less frustrating to import them from the CSV file using this rake task instead of using the form in the admin interface. Fixes #1132
* | Fix upcasing of a non-US-ASCII first letter under Ruby 1.8Mark Longair2013-10-04-1/+1
|/ | | | | | | | In the rare circumstance that someone created a public body whose name started with a lower case letter outside [a-z] with Alaveteli running under Ruby 1.8, the letter would not be upcased correctly before saving to the first_letter column. This commit fixes that by using a Unicode-aware upcase function.
* Merge branch 'feature/hide-individual-responses' into rails-3-developLouise Crow2013-09-17-18/+18
|\ | | | | | | | | | | | | | | | | | | | | Conflicts: Gemfile app/views/admin_request/edit_outgoing.html.erb config/packages doc/CHANGES.md doc/INSTALL.md spec/models/info_request_spec.rb spec/models/public_body_spec.rb
| * Re-annotate models with database fieldsLouise Crow2013-09-16-18/+18
| |
* | Don't dirty the first_letter attribute when not changed.Louise Crow2013-09-05-3/+14
| |
* | Don't re-index body when updating statsLouise Crow2013-09-05-0/+1
| |
* | Don't save versions of new counter cache columnsLouise Crow2013-09-05-1/+5
| |
* | Don't include NULL column values in the statisticsMark Longair2013-08-20-1/+1
| | | | | | | | | | | | | | We were already excluding graphs where all the data was NULL but it's possible by directly manipulating the database to have some values NULL and some non-NULL, so exclude any NULL values anyway.
* | Refactor calculation of statisticsMark Longair2013-08-20-0/+59
|/ | | | | | Move the calculation of statistics on public bodies into the PublicBody model, so that there's less logic in the controller.
* Rename Configuration class to avoid conflict with ActiveSupport::ConfigurableHenare Degan2013-03-03-2/+2
|
* Merge branch 'develop' into rails-3-spikeHenare Degan2013-02-15-2/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: Gemfile Gemfile.lock app/controllers/general_controller.rb app/controllers/track_controller.rb app/models/outgoing_message.rb app/models/public_body.rb app/models/user.rb app/views/general/frontpage.rhtml config/environment.rb config/initializers/inflections.rb config/initializers/mime_types.rb db/migrate/094_remove_old_tags_foreign_key.rb lib/timezone_fixes.rb spec/models/request_mailer_spec.rb spec/views/request/list.rhtml_spec.rb
| * PublicBody model - Overwriting validate is deprecated in Rails 3Henare Degan2013-01-25-9/+10
| |
* | Update to globalize3 methodHenare Degan2013-02-07-1/+1
| |
* | Overwriting validate has been deprecatedHenare Degan2013-01-25-9/+12
| |
* | Merge branch 'rails_xss' into rails-3-spikeMatthew Landauer2013-01-25-0/+2
|\| | | | | | | | | | | | | | | Conflicts: Gemfile Gemfile.lock config/environment.rb lib/i18n_fixes.rb
| * Merge remote-tracking branch 'mysociety/develop' into rails_xssMatthew Landauer2013-01-15-0/+2
| |\
| | * Don't export the fake authorities that we use for admin.Louise Crow2013-01-08-0/+2
| | |
* | | Change method name as it conflicts with globalize3 method nameHenare Degan2013-01-24-1/+1
| | |
* | | PublicBody.locale doesn't exist anymoreMatthew Landauer2013-01-04-2/+2
| | |
* | | Merge branch 'rails_xss' into rails-3-spikeMatthew Landauer2013-01-04-1/+1
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: Gemfile Gemfile.lock app/views/request/_hidden_correspondence.rhtml app/views/request/hidden.rhtml app/views/request/new_please_describe.rhtml app/views/user/show.rhtml lib/i18n_fixes.rb
| * | Escaping fixesMatthew Landauer2013-01-03-1/+1
| |/
* | named_scope has been renamed to scopeHenare Degan2012-12-11-1/+1
| |
* | The with_locale has been removed in Globalize3Henare Degan2012-12-11-26/+23
| | | | | | | | | | | | I think Globalize is supposed to pick up the locale from I18n anyway so I don't know if these are needed. I think I still haven't done the right thing but it's time to move on.
* | Switch to new method nameHenare Degan2012-12-11-5/+5
|/
* Restore disclosure log fields.Louise Crow2012-10-24-0/+2
|
* Merge remote-tracking branch ↵Louise Crow2012-10-24-0/+37
|\ | | | | | | | | | | | | 'openaustralia_github/csv_export_internal_admin_authority_bug' into develop Conflicts: app/controllers/public_body_controller.rb
| * added notes to csv exportMatthew Landauer2012-10-24-0/+2
| |
| * When exporting the authorities as csv don't include the internal admin authorityMatthew Landauer2012-10-24-2/+2
| |
| * Extract methodMatthew Landauer2012-10-24-0/+35
| |
* | Allow disclosure_log to be imported in csvMatthew Landauer2012-10-22-1/+1
|/
* Don't include admin authority in count on home pageMatthew Landauer2012-10-17-0/+6
|
* Rerun annotate -mMatthew Landauer2012-10-11-1/+1
|
* Use new Configuration for OVERRIDE_ALL_PUBLIC_BODY_REQUEST_EMAILSMatthew Landauer2012-10-02-1/+1
|
* Merge remote-tracking branch 'openaustralia_github/configuration_refactor' ↵Louise Crow2012-10-01-1/+1
|\ | | | | | | | | | | | | into develop Conflicts: config/general.yml-example
| * Extract configuration with defaults into one moduleMatthew Landauer2012-09-25-1/+1
| |
* | override_request_email returns nil if configuration not setMatthew Landauer2012-09-27-2/+4
| |
* | Extract methodMatthew Landauer2012-09-27-3/+6
| |
* | Add option to override all public body request emailsMatthew Landauer2012-09-27-0/+9
|/