diff options
-rw-r--r-- | app/models/public_body_category.rb | 5 | ||||
-rw-r--r-- | config/initializers/alaveteli.rb | 2 | ||||
-rw-r--r-- | doc/CHANGES.md | 57 | ||||
-rw-r--r-- | lib/category_and_heading_migrator.rb | 91 | ||||
-rw-r--r-- | lib/public_body_categories.rb | 11 | ||||
-rw-r--r-- | spec/models/public_body_category_spec.rb | 29 | ||||
-rw-r--r-- | spec/models/public_body_heading_spec.rb | 20 |
7 files changed, 43 insertions, 172 deletions
diff --git a/app/models/public_body_category.rb b/app/models/public_body_category.rb index c313e5734..198e8b737 100644 --- a/app/models/public_body_category.rb +++ b/app/models/public_body_category.rb @@ -49,11 +49,6 @@ class PublicBodyCategory < ActiveRecord::Base PublicBodyCategory.find_by_sql(sql) end - # Called from the old-style public_body_categories_[locale].rb data files - def self.add(locale, data_list) - CategoryAndHeadingMigrator.add_categories_and_headings_from_list(locale, data_list) - end - # Convenience methods for creating/editing translations via forms def find_translation_by_locale(locale) translations.find_by_locale(locale) diff --git a/config/initializers/alaveteli.rb b/config/initializers/alaveteli.rb index d2096fd52..840639228 100644 --- a/config/initializers/alaveteli.rb +++ b/config/initializers/alaveteli.rb @@ -53,8 +53,6 @@ require 'theme' require 'xapian_queries' require 'date_quarter' require 'public_body_csv' -require 'category_and_heading_migrator' -require 'public_body_categories' require 'routing_filters' require 'alaveteli_text_masker' diff --git a/doc/CHANGES.md b/doc/CHANGES.md index dee11f6f7..40bab6ecf 100644 --- a/doc/CHANGES.md +++ b/doc/CHANGES.md @@ -1,31 +1,60 @@ # rails-3-develop ## Highlighted Features - +* Lots of improvements in the process of making a new + request (Martin Wright, Gareth Rees, Louise Crow): + * Removal of confusing AJAX results in `/select_authority`. + * Better layout of search/filtering options on the authority pages. + * Better layout of the authority pages on smaller screens. + * The dynamic list of possibly related requests for a new request + is now limited to requests to the same authority and capped at + three requests + * 'Create a new account' option now more prominent than 'Sign in' on `/sign_in` + * Better options for sharing your request on social media, and other + actions to take once the request is made. +* Some general security improvements: + * State changing admin actions are now restricted to PUT or POST methods + to protect against CSRF attacks, and now use more standard RESTful + routing (Louise Crow). + * Global request forgery protection is now used (Gareth Rees). + * Some standard security headers are added by default (Louise Crow). + * A TTL is enforced on session cookies (Louise Crow). * Added a new `AUTHORITY_MUST_RESPOND` configuration variable. Set this to `true` If authorities must respond by law. Set to `false` otherwise. It - defaults to `true`. At the moment this just tweaks some UI text. -* State changing admin actions are now restricted to PUT or POST methods - to protect against CSRF attacks, and now use more standard RESTful - routing. -* Global request forgery protection is now used -* The dynamic list of possibly related requests for a new request is now - limited to requests to the same authority and capped at three requests -* Some standard security headers are added by default + defaults to `true`. At the moment this just tweaks some UI text (Gareth Rees). * New rake task for cleaning theme translations - `rake - gettext:clean_theme` -* A TTL is enforced on session cookies + gettext:clean_theme` (Gareth Rees). * There's a new admin interface for adding public holidays for the site, - to be used in calculating request due dates. -* Autocomplete has been turned off on password fields + to be used in calculating request due dates. Documentation for using + this interface is available at + http://alaveteli.org/docs/installing/next_steps/#add-some-public-holidays (Louise Crow). * Some interface phrases have been grouped together for easier - translation + translation (Gareth Rees, Louise Crow). +* Now using the bootstrap js files from the bootstrap-sass gem. +* Confusing 'web analytics' section of admin pages removed (Henare Degan) +* Banned users can no longer update their profile (Gareth Rees). +* The code that removes email addresses and mobile phone numbers from + the public view of requests an responses has been refactored, and the + text that's used to replace the email addresses and phone numbers can + now be translated (Louise Crow). +* Fixed a bug with the CSV import of authorities which have the same + name in multiple locales (Louise Crow). ## Upgrade notes * Admin route names have been standardised so if you have overridden templates that refer to admin routes, check the original templates to see if these need to be changed. +* If you override the `app/views/user/_signin.html.erb` or + `app/view/user/_signup.html.erb` templates, check the tabindex order + is still sensible - the order of the elements on the page has changed + - signup now appears on the left. +* If you override the application stylesheets rather than adding to them + using a `custom.css` or `custom.scss` file, check that your + stylesheets still order elements correctly in the + `app/views/request/select_authority.html.erb`, + `app/views/public_body/show.html.erb` and + `app/views/request/new.html.erb`. # Version 0.20 diff --git a/lib/category_and_heading_migrator.rb b/lib/category_and_heading_migrator.rb deleted file mode 100644 index 402ea7204..000000000 --- a/lib/category_and_heading_migrator.rb +++ /dev/null @@ -1,91 +0,0 @@ -module CategoryAndHeadingMigrator - - # This module migrates data from public_body_categories_[locale].rb files - # into PublicBodyHeading and PublicBodyCategory models - - # Load all the data from public_body_categories_[locale].rb files. - def self.migrate_categories_and_headings - if PublicBodyCategory.count > 0 - puts "PublicBodyCategories exist already, not migrating." - else - @first_locale = true - I18n.available_locales.each do |locale| - begin - load "public_body_categories_#{locale}.rb" - rescue MissingSourceFile - end - @first_locale = false - end - end - end - - # Load the categories and headings for a locale - def self.add_categories_and_headings_from_list(locale, data_list) - # set the counter for headings loaded from this locale - @@locale_heading_display_order = 0 - current_heading = nil - data_list.each do |list_item| - if list_item.is_a?(Array) - # item is list of category data - add_category(list_item, current_heading, locale) - else - # item is heading name - current_heading = add_heading(list_item, locale, @first_locale) - end - end - end - - def self.add_category(category_data, heading, locale) - tag, title, description = category_data - category = PublicBodyCategory.find_by_category_tag(tag) - if category - add_category_in_locale(category, title, description, locale) - else - category = PublicBodyCategory.create(:category_tag => tag, - :title => title, - :description => description) - - # add the translation if this is not the default locale - # (occurs when a category is not defined in default locale) - unless category.translations.map { |t| t.locale }.include?(locale) - add_category_in_locale(category, title, description, locale) - end - end - heading.add_category(category) - end - - def self.add_category_in_locale(category, title, description, locale) - I18n.with_locale(locale) do - category.title = title - category.description = description - category.save - end - end - - def self.add_heading(name, locale, first_locale) - heading = nil - I18n.with_locale(locale) do - heading = PublicBodyHeading.find_by_name(name) - end - # For multi-locale installs, we assume that all public_body_[locale].rb files - # use the same headings in the same order, so we add translations to the heading - # that was in the same position in the list loaded from other public_body_[locale].rb - # files. - if heading.nil? && !@first_locale - heading = PublicBodyHeading.where(:display_order => @@locale_heading_display_order).first - end - - if heading - I18n.with_locale(locale) do - heading.name = name - heading.save - end - else - I18n.with_locale(locale) do - heading = PublicBodyHeading.create(:name => name) - end - end - @@locale_heading_display_order += 1 - heading - end -end diff --git a/lib/public_body_categories.rb b/lib/public_body_categories.rb deleted file mode 100644 index 3528e85b1..000000000 --- a/lib/public_body_categories.rb +++ /dev/null @@ -1,11 +0,0 @@ -# Allow the PublicBodyCategory model to be addressed using the same syntax -# as the old PublicBodyCategories class without needing to rename everything, -# make sure we're not going to break any themes -class PublicBodyCategories - - def self.method_missing(method, *args, &block) - warn 'Use of PublicBodyCategories is deprecated and will be removed in release 0.21. Please use PublicBodyCategory instead.' - PublicBodyCategory.send(method, *args, &block) - end - -end diff --git a/spec/models/public_body_category_spec.rb b/spec/models/public_body_category_spec.rb index 96fe5686b..c16c9b8a1 100644 --- a/spec/models/public_body_category_spec.rb +++ b/spec/models/public_body_category_spec.rb @@ -9,35 +9,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe PublicBodyCategory do - describe 'when loading the data' do - it 'should use the display_order field to preserve the original data order' do - PublicBodyCategory.add(:en, [ - "Local and regional", - [ "local_council", "Local councils", "a local council" ], - "Miscellaneous", - [ "other", "Miscellaneous", "miscellaneous" ], - [ "aardvark", "Aardvark", "daft test"],]) - - headings = PublicBodyHeading.all - cat_group1 = headings[0].public_body_categories - cat_group1.count.should eq 1 - cat_group1[0].title.should eq "Local councils" - - cat_group2 = headings[1].public_body_categories - cat_group2.count.should eq 2 - cat_group2[0].title.should eq "Miscellaneous" - cat_group2[0].public_body_category_links.where( - :public_body_heading_id => headings[1].id). - first. - category_display_order.should eq 0 - - cat_group2[1].title.should eq "Aardvark" - cat_group2[1].public_body_category_links.where( - :public_body_heading_id => headings[1].id). - first. - category_display_order.should eq 1 - end - end context 'when validating' do diff --git a/spec/models/public_body_heading_spec.rb b/spec/models/public_body_heading_spec.rb index 9372e0a07..620f7da9c 100644 --- a/spec/models/public_body_heading_spec.rb +++ b/spec/models/public_body_heading_spec.rb @@ -10,26 +10,6 @@ require 'spec_helper' describe PublicBodyHeading do - context 'when loading the data' do - - before do - PublicBodyCategory.add(:en, [ - "Local and regional", - [ "local_council", "Local councils", "a local council" ], - "Miscellaneous", - [ "other", "Miscellaneous", "miscellaneous" ],]) - end - - it 'should use the display_order field to preserve the original data order' do - headings = PublicBodyHeading.all - headings[0].name.should eq 'Local and regional' - headings[0].display_order.should eq 0 - headings[1].name.should eq 'Miscellaneous' - headings[1].display_order.should eq 1 - end - - end - context 'when validating' do it 'should require a name' do |