aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/public_body.rb
Commit message (Collapse)AuthorAgeLines
* Merge branch '2134-fix-same-attribute-value-across-locales' into rails-3-developLouise Crow2015-02-23-80/+99
|\
| * Refactor massive import method into smaller instance level methodsLouise Crow2015-02-23-89/+83
| |
| * Use standard spacing for hashes, new lines for commentsLouise Crow2015-02-23-2/+3
| |
| * Test localised value for import against existing localised valueLouise Crow2015-02-23-2/+26
| | | | | | | | | | | | | | | | | | Previously the call to public_body.send would return the value for the default locale if no value was set in the current locale, meaning that translations for attributes that were the same as the attribute values in the default locale were not being loaded. Fixes #2134.
* | Move logic to modelLouise Crow2015-02-20-0/+5
| |
* | Use correct method name in error.Louise Crow2015-02-20-1/+1
| |
* | Refactor common logicLouise Crow2015-02-20-15/+7
| |
* | Standard separation of methods.Louise Crow2015-02-20-1/+3
| | | | | | | | Comment above a method should apply to that method only
* | Merge branch 'hotfix/0.20.0.6' into rails-3-developLouise Crow2015-02-05-3/+16
|\ \ | | | | | | | | | | | | Conflicts: spec/models/public_body_spec.rb
| * | Deprecate PublicBody#translations_attributes=(Array)Gareth Rees2015-02-03-0/+13
| | | | | | | | | | | | Array handling will no longer be supported in release 0.22
| * | Fix submission of form containing both existing and new translationsLouise Crow2015-02-03-2/+2
| | |
| * | Add specs for PublicBody#translated_versions=Gareth Rees2015-01-30-1/+1
| |/ | | | | | | | | | | | | | | Also fixes #empty_translation? to check for String and Symbol keys named 'locale'. Specs use a pre-change check to assert difference. For some reason rspec change matcher fails with 'nil is not a symbol'.
* | Use each_with_index rather than magic booleanGareth Rees2015-02-04-2/+2
| |
* | Use map instead of creating empty arrayGareth Rees2015-02-04-3/+4
| |
* | Nicer capitalize first letter onlyGareth Rees2015-02-04-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | String#capitalize downcases remaining letters, so: > 'heLLo WorLd'.capitalize # => "Hello world" Our version only works on the first character of the String, preserving the case of the rest of the String: > 'heLLo WorLd'.sub(/\S/) { |m| Unicode.upcase(m) } # => 'HeLLo WorLd' Also handle unicode.
* | Use each instead of forGareth Rees2015-01-23-1/+1
| |
* | Remove home-grown Array#to_sentence dupGareth Rees2015-01-23-8/+4
|/ | | | | - to_sentence does the same job as the removed code. - Clean up the conditional with .any? and implicit returns
* Try to avoid n+1 queries, and multiple admin authority queries.0.20.0.1hotfix/0.20.0.1Louise Crow2014-12-18-2/+3
| | | | Attempting to make the import faster when there are lots of public authorities in the database already
* 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