diff options
-rw-r--r-- | .hound.yml | 11 | ||||
-rw-r--r-- | Gemfile.lock | 2 | ||||
-rw-r--r-- | Vagrantfile | 9 | ||||
-rw-r--r-- | app/controllers/general_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/public_body_controller.rb | 48 | ||||
-rw-r--r-- | app/controllers/user_controller.rb | 2 | ||||
-rw-r--r-- | app/views/admin_request/edit.html.erb | 8 | ||||
-rw-r--r-- | app/views/general/_frontpage_bodies_list.html.erb | 5 | ||||
-rw-r--r-- | app/views/general/_frontpage_requests_list.html.erb | 5 | ||||
-rw-r--r-- | app/views/general/_frontpage_search_box.html.erb | 3 | ||||
-rw-r--r-- | app/views/public_body/show.html.erb | 5 | ||||
-rw-r--r-- | app/views/request/upload_response.html.erb | 6 | ||||
-rw-r--r-- | config/packages | 1 | ||||
-rw-r--r-- | config/packages.debian-squeeze | 1 | ||||
-rw-r--r-- | config/packages.ubuntu-precise | 1 | ||||
-rw-r--r-- | db/migrate/20140528110536_update_track_things_index.rb | 17 | ||||
-rw-r--r-- | doc/INSTALL.md | 2 | ||||
-rw-r--r-- | lib/tasks/cleanup.rake | 20 | ||||
-rw-r--r-- | spec/controllers/public_body_controller_spec.rb | 5 |
19 files changed, 117 insertions, 38 deletions
diff --git a/.hound.yml b/.hound.yml new file mode 100644 index 000000000..574cfe7ac --- /dev/null +++ b/.hound.yml @@ -0,0 +1,11 @@ +# Configuration for https://houndci.com/ + +Style/IndentationWidth: + Description: 'Use 2 spaces for indentation.' + Enabled: false + +Style/HashSyntax: + Description: >- + Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax + { :a => 1, :b => 2 }. + Enabled: false diff --git a/Gemfile.lock b/Gemfile.lock index 32a1e77f5..fd02983c0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -243,7 +243,7 @@ GEM hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) - tilt (!= 1.3.0, ~> 1.1) + tilt (~> 1.1, != 1.3.0) sqlite3 (1.3.7) statistics2 (0.54) syslog_protocol (0.9.2) diff --git a/Vagrantfile b/Vagrantfile index 5d56914a5..31b2553a1 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -46,6 +46,15 @@ # Both have the same effect, but exporting will retain the variable for the # duration of your shell session. # +# Using Themes +# ------------ +# +# You can also use the built in theme switcher (script/switch-theme.rb). The +# ALAVETELI_THEMES_DIR will be shared in to /home/vagrant/alaveteli-themes so +# that the default location is used on the guest. You can use the env var +# ALAVETELI_THEMES_DIR to change where this Vagrantfile looks for the themes +# directory on the host. +# # Customization Options # ===================== ALAVETELI_FQDN = ENV['ALAVETELI_VAGRANT_FQDN'] || "alaveteli.10.10.10.30.xip.io" diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb index 6f0d29889..e2a2190b0 100644 --- a/app/controllers/general_controller.rb +++ b/app/controllers/general_controller.rb @@ -178,7 +178,9 @@ class GeneralController < ApplicationController format.json { render :json => { :alaveteli_git_commit => alaveteli_git_commit, :alaveteli_version => ALAVETELI_VERSION, - :ruby_version => RUBY_VERSION + :ruby_version => RUBY_VERSION, + :visible_request_count => InfoRequest.visible.count, + :confirmed_user_count => User.where(:email_confirmed => true).count }} end end diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb index 862f4b318..96e69d333 100644 --- a/app/controllers/public_body_controller.rb +++ b/app/controllers/public_body_controller.rb @@ -109,17 +109,17 @@ class PublicBodyController < ApplicationController # Restrict the public bodies shown according to the tag # parameter supplied in the URL: - if @tag.nil? or @tag == "all" - @tag = "all" + if @tag.nil? || @tag == 'all' + @tag = 'all' elsif @tag == 'other' - category_list = PublicBodyCategories::get().tags().map{|c| "'"+c+"'"}.join(",") + category_list = PublicBodyCategories.get.tags.map{ |c| %Q('#{ c }') }.join(",") where_condition += base_tag_condition + " AND has_tag_string_tags.name in (#{category_list})) = 0" elsif @tag.scan(/./mu).size == 1 - @tag = Unicode.upcase @tag + @tag = Unicode.upcase(@tag) # The first letter queries have to be done on # translations, so just indicate to add that later: first_letter = true - elsif @tag.include?(":") + elsif @tag.include?(':') name, value = HasTagString::HasTagStringTag.split_tag_into_name_value(@tag) where_condition += base_tag_condition + " AND has_tag_string_tags.name = ? AND has_tag_string_tags.value = ?) > 0" where_parameters.concat [name, value] @@ -128,16 +128,16 @@ class PublicBodyController < ApplicationController where_parameters.concat [@tag] end - if @tag == "all" - @description = "" + if @tag == 'all' + @description = '' elsif @tag.size == 1 - @description = _("beginning with ‘{{first_letter}}’", :first_letter=>@tag) + @description = _("beginning with ‘{{first_letter}}’", :first_letter => @tag) else - category_name = PublicBodyCategories::get().by_tag()[@tag] + category_name = PublicBodyCategories.get.by_tag[@tag] if category_name.nil? - @description = _("matching the tag ‘{{tag_name}}’", :tag_name=>@tag) + @description = _("matching the tag ‘{{tag_name}}’", :tag_name => @tag) else - @description = _("in the category ‘{{category_name}}’", :category_name=>category_name) + @description = _("in the category ‘{{category_name}}’", :category_name => category_name) end end @@ -151,15 +151,15 @@ class PublicBodyController < ApplicationController FROM public_bodies LEFT OUTER JOIN public_body_translations as current_locale ON (public_bodies.id = current_locale.public_body_id - AND current_locale.locale = ? AND #{get_public_body_list_translated_condition 'current_locale', first_letter}) + AND current_locale.locale = ? AND #{ get_public_body_list_translated_condition('current_locale', first_letter) }) LEFT OUTER JOIN public_body_translations as default_locale ON (public_bodies.id = default_locale.public_body_id - AND default_locale.locale = ? AND #{get_public_body_list_translated_condition 'default_locale', first_letter}) - WHERE #{where_condition} AND COALESCE(current_locale.name, default_locale.name) IS NOT NULL + AND default_locale.locale = ? AND #{ get_public_body_list_translated_condition('default_locale', first_letter) }) + WHERE #{ where_condition } AND COALESCE(current_locale.name, default_locale.name) IS NOT NULL ORDER BY display_name} - sql = [query, underscore_locale, like_query, like_query] + sql = [query, underscore_locale, like_query, like_query, like_query] sql.push @tag if first_letter - sql += [underscore_default_locale, like_query, like_query] + sql += [underscore_default_locale, like_query, like_query, like_query] sql.push @tag if first_letter sql += where_parameters @public_bodies = PublicBody.paginate_by_sql( @@ -170,17 +170,17 @@ class PublicBodyController < ApplicationController # The simpler case where we're just searching in the current locale: where_condition = get_public_body_list_translated_condition('public_body_translations', first_letter, true) + ' AND ' + where_condition - where_sql = [where_condition, like_query, like_query] + where_sql = [where_condition, like_query, like_query, like_query] where_sql.push @tag if first_letter where_sql += [underscore_locale] + where_parameters - @public_bodies = PublicBody.where(where_sql) \ - .joins(:translations) \ - .order("public_body_translations.name") \ - .paginate(:page => params[:page], :per_page => 100) + @public_bodies = PublicBody.where(where_sql). + joins(:translations). + order("public_body_translations.name"). + paginate(:page => params[:page], :per_page => 100) end respond_to do |format| - format.html { render :template => "public_body/list" } + format.html { render :template => 'public_body/list' } end end end @@ -344,9 +344,11 @@ class PublicBodyController < ApplicationController end private + def get_public_body_list_translated_condition(table, first_letter=false, locale=nil) result = "(upper(#{table}.name) LIKE upper(?)" \ - " OR upper(#{table}.notes) LIKE upper (?))" + " OR upper(#{table}.notes) LIKE upper(?)" \ + " OR upper(#{table}.short_name) LIKE upper(?))" if first_letter result += " AND #{table}.first_letter = ?" end diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 8d6522923..12207362b 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -288,7 +288,7 @@ class UserController < ApplicationController :reason_params => { :web => "", :email => _("Then you can change your password on {{site_name}}",:site_name=>site_name), - :email_subject => _("Change your password {{site_name}}",:site_name=>site_name) + :email_subject => _("Change your password on {{site_name}}",:site_name=>site_name) }, :circumstance => "change_password" # special login that lets you change your password ) diff --git a/app/views/admin_request/edit.html.erb b/app/views/admin_request/edit.html.erb index 0e9c68aea..552b31bbb 100644 --- a/app/views/admin_request/edit.html.erb +++ b/app/views/admin_request/edit.html.erb @@ -33,7 +33,7 @@ <p><label for="info_request_tag_string"><strong>Tags</strong> <small>(space separated, can use key:value)</small></label><br/> <%= text_field 'info_request', 'tag_string', :size => 60 %></p> - <p><%= submit_tag 'Save changes', :accesskey => 's' %> + <p><%= submit_tag 'Save changes', :accesskey => 's', :class => 'btn btn-primary' %> </p> <p><strong>Note:</strong> To edit the actual request body text, click edit @@ -49,13 +49,17 @@ <hr> +<div class="well"> + <%= form_tag admin_request_destroy_path(@info_request) do %> <p> - <strong>This is permanent and irreversible!</strong> <%= submit_tag 'Destroy request entirely' %> + <strong>This is permanent and irreversible!</strong> <%= submit_tag 'Destroy request entirely', :class => 'btn btn-danger' %> <br>Use it mainly if someone posts private information, e.g. made a Data Protection request. It destroys all responses and tracks as well. </p> <% end %> +</div> + <hr> diff --git a/app/views/general/_frontpage_bodies_list.html.erb b/app/views/general/_frontpage_bodies_list.html.erb index 44321f14a..1c35c55ad 100644 --- a/app/views/general/_frontpage_bodies_list.html.erb +++ b/app/views/general/_frontpage_bodies_list.html.erb @@ -3,9 +3,10 @@ <div id="examples_0"> <h3><%= _("Who can I request information from?") %></h3> <%= _("{{site_name}} covers requests to {{number_of_authorities}} authorities, including:", - :site_name => site_name, :number_of_authorities => PublicBody.visible.count) %> + :site_name => site_name, + :number_of_authorities => number_with_delimiter(PublicBody.visible.count)) %> <ul> - <% for popular_body in popular_bodies %> + <% popular_bodies.each do |popular_body| %> <li><%=public_body_link(popular_body)%> <%= n_('{{count}} request', '{{count}} requests', popular_body.info_requests_count, :count => popular_body.info_requests_count) %> </li> diff --git a/app/views/general/_frontpage_requests_list.html.erb b/app/views/general/_frontpage_requests_list.html.erb index d7d9184c4..39187f3f0 100644 --- a/app/views/general/_frontpage_requests_list.html.erb +++ b/app/views/general/_frontpage_requests_list.html.erb @@ -8,9 +8,10 @@ <% end %> </h3> <%= _("{{site_name}} users have made {{number_of_requests}} requests, including:", - :site_name => site_name, :number_of_requests => InfoRequest.visible.count) %> + :site_name => site_name, + :number_of_requests => number_with_delimiter(InfoRequest.visible.count)) %> <ul> - <% for event in @request_events %> + <% @request_events.each do |event| %> <li> <% if @request_events_all_successful %> <%= _("{{public_body_link}} answered a request about", diff --git a/app/views/general/_frontpage_search_box.html.erb b/app/views/general/_frontpage_search_box.html.erb index 890602416..f77bd97fc 100644 --- a/app/views/general/_frontpage_search_box.html.erb +++ b/app/views/general/_frontpage_search_box.html.erb @@ -2,7 +2,8 @@ <%= _("Search over<br/> <strong>{{number_of_requests}} requests</strong> <span>and</span><br/> <strong>{{number_of_authorities}} authorities</strong>", - :number_of_requests => InfoRequest.visible.count, :number_of_authorities => PublicBody.visible.count) %> + :number_of_requests => number_with_delimiter(InfoRequest.visible.count), + :number_of_authorities => number_with_delimiter(PublicBody.visible.count)) %> </h2> <form id="search_form" method="post" action="<%= search_redirect_path %>"> <div> diff --git a/app/views/public_body/show.html.erb b/app/views/public_body/show.html.erb index a9c50e657..9352747ea 100644 --- a/app/views/public_body/show.html.erb +++ b/app/views/public_body/show.html.erb @@ -127,7 +127,10 @@ <% if @xapian_requests.results.empty? %> <p><% _('There were no requests matching your query.') %></p> <% else %> - <p> <%= _('Only requests made using {{site_name}} are shown.', :site_name => site_name) %></p> + <p> + <%= _('Only requests made using {{site_name}} are shown.', :site_name => site_name) %> + <%= link_to _('?'), help_about_path %> + </p> <% end %> <% else %> diff --git a/app/views/request/upload_response.html.erb b/app/views/request/upload_response.html.erb index f5fd6f000..f07af34d5 100644 --- a/app/views/request/upload_response.html.erb +++ b/app/views/request/upload_response.html.erb @@ -9,7 +9,9 @@ <%= foi_error_messages_for :comment %> - <h1><%= _('Respond to the FOI request')%> '<%=request_link(@info_request)%>'<% _(' made by ')%><%=user_link(@info_request.user) %></h1> + <h1><%= _("Respond to the FOI request '{{request}}' made by {{user}}", + :request => request_link(@info_request), + :user => user_link(@info_request.user)) %></h1> <p> <%= raw(_('Your response will <strong>appear on the Internet</strong>, <a href="{{url}}">read why</a> and answers to other questions.', :url => help_officers_path.html_safe)) %> @@ -48,5 +50,3 @@ </p> <% end %> <% end %> - - diff --git a/config/packages b/config/packages index 9a07c5f20..fda09cbc1 100644 --- a/config/packages +++ b/config/packages @@ -39,3 +39,4 @@ sqlite3 libsqlite3-dev libicu-dev memcached +ttf-bitstream-vera diff --git a/config/packages.debian-squeeze b/config/packages.debian-squeeze index 6cdf2f9d6..d82d66324 100644 --- a/config/packages.debian-squeeze +++ b/config/packages.debian-squeeze @@ -37,3 +37,4 @@ libsqlite3-dev libicu-dev postgresql postgresql-client +ttf-bitstream-vera diff --git a/config/packages.ubuntu-precise b/config/packages.ubuntu-precise index 177d504e2..68911359a 100644 --- a/config/packages.ubuntu-precise +++ b/config/packages.ubuntu-precise @@ -33,3 +33,4 @@ libsqlite3-dev libicu-dev postgresql postgresql-client +ttf-bitstream-vera diff --git a/db/migrate/20140528110536_update_track_things_index.rb b/db/migrate/20140528110536_update_track_things_index.rb new file mode 100644 index 000000000..55ee0b70b --- /dev/null +++ b/db/migrate/20140528110536_update_track_things_index.rb @@ -0,0 +1,17 @@ +class UpdateTrackThingsIndex < ActiveRecord::Migration + + def up + if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" + execute "ALTER TABLE track_things_sent_emails DROP CONSTRAINT fk_track_request_public_body" + execute "ALTER TABLE track_things_sent_emails ADD CONSTRAINT fk_track_request_public_body FOREIGN KEY (public_body_id) REFERENCES public_bodies(id)" + end + end + + def down + if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" + execute "ALTER TABLE track_things_sent_emails DROP CONSTRAINT fk_track_request_public_body" + execute "ALTER TABLE track_things_sent_emails ADD CONSTRAINT fk_track_request_public_body FOREIGN KEY (user_id) REFERENCES users(id)" + end + end + +end diff --git a/doc/INSTALL.md b/doc/INSTALL.md index 04cdb1352..f6563be99 100644 --- a/doc/INSTALL.md +++ b/doc/INSTALL.md @@ -255,7 +255,7 @@ Make sure that the user specified in database.yml exists, and has full permissions on these databases. As they need the ability to turn off constraints whilst running the tests they also need to be a superuser. If you don't want your database user to be a superuser, you can add a line -`disable_constraints: false` to the test config in database.yml, as seen in database.yml-example +`constraint_disabling: false` to the test config in database.yml, as seen in database.yml-example You can create a `foi` user from the command line, thus: diff --git a/lib/tasks/cleanup.rake b/lib/tasks/cleanup.rake new file mode 100644 index 000000000..9a8be9521 --- /dev/null +++ b/lib/tasks/cleanup.rake @@ -0,0 +1,20 @@ +namespace :cleanup do + + desc 'Clean up all message redelivery and destroy actions from the holding pen to make admin actions there faster' + task :holding_pen => :environment do + dryrun = ENV['DRYRUN'] != '0' + if dryrun + $stderr.puts "This is a dryrun - nothing will be deleted" + end + holding_pen = InfoRequest.find_by_url_title('holding_pen') + old_events = holding_pen.info_request_events.find_each(:conditions => ['event_type in (?)', + ['redeliver_incoming', + 'destroy_incoming']]) do |event| + puts event.inspect + if ! dryrun + event.destroy + end + end + end + +end diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb index 63989baaa..6afbf24d1 100644 --- a/spec/controllers/public_body_controller_spec.rb +++ b/spec/controllers/public_body_controller_spec.rb @@ -184,6 +184,11 @@ describe PublicBodyController, "when listing bodies" do assigns[:public_bodies].should == [ public_bodies(:geraldine_public_body) ] end + it "should support simple searching of bodies by short_name" do + get :list, :public_body_query => 'DfH' + assigns[:public_bodies].should == [ public_bodies(:humpadink_public_body) ] + end + it "should support simple searching of bodies by notes" do get :list, :public_body_query => 'Albatross' assigns[:public_bodies].should == [ public_bodies(:humpadink_public_body) ] |