aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/public_body.rb
Commit message (Collapse)AuthorAgeLines
* Group PublicBody callbacks and macros at topGareth Rees2014-10-29-18/+21
|
* Remove old PublicBodyCategories calls.Louise Crow2014-10-09-2/+2
| | | | | Add deprecation notice to draw attention to any place where PublicBodyCategories is called from themes.
* fixup! Basic category admin screenLouise Crow2014-09-24-5/+5
|
* Make csv import fields a class attribute that can be overridenSteven Day2014-08-22-1/+19
|
* Merge branch 'issues/1415-bulk-update-public-bodies' into rails-3-developGareth Rees2014-06-25-39/+3
|\
| * Move PublicBody domain logic from controllerGareth Rees2014-06-06-0/+3
| | | | | | | | | | | | Moves the magic 'site_administration' tag logic to the PublicBody model. Easier to make the string passed to `PublicBody#has_tag?` configurable if we want to allow this to be set per install.
| * Extract public body CSV export to its own classGareth Rees2014-06-06-39/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - SRP: Do one thing. PublicBodyCSV converts a collection of bodies in to a CSV formatted String - Adds some parenthesis around parameters in PublicBodyController#list_all_csv - Let the controller handle what records to pull out for the CSV export Arguably this doesn't really need to be anything to do with PublicBody, but it allows us to set nice defaults.
* | Rename XXX comments with TODO:Gareth Rees2014-06-10-2/+2
|/ | | | Picks these up in `rake notes` and adds semantic meaning
* Add PublicBody.searchGareth Rees2014-05-01-0/+28
| | | | | Search for public bodies whose searchable attributes are like a given query.
* Handle validation errors in PublicBody.import_csvGareth Rees2014-04-14-1/+9
| | | | | | | | | Specifically using save! so that anything other than an ActiveRecord::RecordInvalid doesn't get missed Note that ActiveModel::Errors#full_messages includes the attribute key in the message. This is by design, so we should consider whether we can improve the way that we use translated validation messages.
* Add missing validation to PublicBodyGareth Rees2014-04-14-0/+1
| | | | | There's a unique index on public_bodies url_name, so we should have a validation for that.
* Add default blank string to PublicBody@short_nameGareth Rees2014-04-09-1/+1
| | | | The validation allows a blank short_name but the schema does not.
* Use more semantic allow_blank validationGareth Rees2014-04-09-1/+1
|
* Merge branch 'feature/batch-requests' into rails-3-developLouise Crow2014-01-29-0/+1
|\ | | | | | | | | | | Conflicts: config/general.yml-example spec/factories.rb
| * Add InfoRequestBatch model.Louise Crow2013-12-04-0/+1
| | | | | | | | | | Re-annotate models. Index InfoRequestBatches by user - we'll display the batches for a user when they view their own requests.
* | Ignore translations when finding the internal admin bodyMark Longair2014-01-14-15/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If you change the default locale after having set up your site, and exception would always be thrown by PublicBody.internal_admin_body, which looks up that distinguished body based on url_name. Since that's a translated field, and there would be no translation for it in the new locale, it wouldn't be found, and the code would try to create a second internal_admin_body, which would fail because of the url_name being non-unque in public_bodies. There are various ways of fixing this; the one introduced in this commit is to use raw SQL to find the public body, bypassing the public_body_translations table. Fixes #1001.
* | Merge branch 'feature/locale-underscore-fixes' into rails-3-developLouise Crow2013-12-09-3/+4
|\ \
| * | Make sure globalize uses the right locale version when updating.Louise Crow2013-12-05-2/+2
| | |
| * | Search for bodies using the underscore version of the locale.Louise Crow2013-12-05-1/+2
| |/
* / 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
| | |