aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeb Bacon <seb.bacon@gmail.com>2012-01-26 10:20:18 +0000
committerSeb Bacon <seb.bacon@gmail.com>2012-01-26 10:20:18 +0000
commitbbbfd5c9741b998808458e0c80843549b68f4b79 (patch)
tree2c4ae679dd5e622a592de48b7ccf5fc3208241b1
parent4853aef253dd94a8d1f731910a2fb8a93ce76773 (diff)
parentb5354e661bd740e482cd3090876f9bd34164dcf3 (diff)
Merge branch 'wdtk' of github.com:sebbacon/alaveteli into wdtk
-rw-r--r--app/controllers/request_controller.rb4
-rw-r--r--app/views/public_body/show.rhtml192
-rw-r--r--public/stylesheets/main.css8
-rwxr-xr-xscript/load-sample-data12
-rwxr-xr-xscript/rebuild-xapian-index4
-rw-r--r--spec/controllers/request_controller_spec.rb38
6 files changed, 140 insertions, 118 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 75bdac2a9..a70e8d16c 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -74,8 +74,9 @@ class RequestController < ApplicationController
@info_request_events = @info_request.info_request_events
@status = @info_request.calculate_status
@collapse_quotes = params[:unfold] ? false : true
- @update_status = params[:update_status] ? true : false
+ @update_status = params[:update_status] ? true : false
@old_unclassified = @info_request.is_old_unclassified? && !authenticated_user.nil?
+ @is_owning_user = @info_request.is_owning_user?(authenticated_user)
if @update_status
return if !@is_owning_user && !authenticated_as_user?(@info_request.user,
@@ -108,7 +109,6 @@ class RequestController < ApplicationController
# For send followup link at bottom
@last_response = @info_request.get_last_response
- @is_owning_user = @info_request.is_owning_user?(authenticated_user)
respond_to do |format|
format.html { @has_json = true; render :template => 'request/show'}
format.json { render :json => @info_request.json_for_api(true) }
diff --git a/app/views/public_body/show.rhtml b/app/views/public_body/show.rhtml
index 7d37a35a7..5f20a9717 100644
--- a/app/views/public_body/show.rhtml
+++ b/app/views/public_body/show.rhtml
@@ -1,123 +1,123 @@
<% @title = h(@public_body.name) + _(" - view and make Freedom of Information requests") %>
<div id="main_content">
- <div id="header_right">
+ <div id="header_right">
<h2><%= _('Follow this authority')%></h2>
- <% follower_count = TrackThing.count(:all, :conditions => ["public_body_id = ?", @public_body.id]) %>
- <p><%= n_("There is %d person following this authority", "There are %d people following this authority", follower_count) % follower_count %></p>
+ <% follower_count = TrackThing.count(:all, :conditions => ["public_body_id = ?", @public_body.id]) %>
+ <p><%= n_("There is %d person following this authority", "There are %d people following this authority", follower_count) % follower_count %></p>
- <%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => false, :location => 'sidebar' } %>
- <h2><%= _('More about this authority')%></h2>
- <% if !@public_body.calculated_home_page.nil? %>
- <%= link_to _('Home page of authority'), @public_body.calculated_home_page %><br>
- <% end %>
- <% if !@public_body.publication_scheme.empty? %>
- <%= link_to _('Publication scheme'), @public_body.publication_scheme %><br>
- <% end %>
- <% if @public_body.has_tag?("charity") %>
- <% for tag_value in @public_body.get_tag_values("charity") %>
- <% if tag_value.match(/^SC/) %>
- <%= link_to _('Charity registration'), "http://www.oscr.org.uk/CharityIndexDetails.aspx?id=" + tag_value %><br>
- <% else %>
- <%= link_to _('Charity registration'), "http://www.charity-commission.gov.uk/SHOWCHARITY/RegisterOfCharities/CharityFramework.aspx?RegisteredCharityNumber=" + tag_value %><br>
- <% end %>
- <% end %>
- <% end %>
- <%= link_to _('View FOI email address'), view_public_body_email_url(@public_body.url_name) %><br>
- </div>
+ <%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => false, :location => 'sidebar' } %>
+ <h2><%= _('More about this authority')%></h2>
+ <% if !@public_body.calculated_home_page.nil? %>
+ <%= link_to _('Home page of authority'), @public_body.calculated_home_page %><br>
+ <% end %>
+ <% if !@public_body.publication_scheme.empty? %>
+ <%= link_to _('Publication scheme'), @public_body.publication_scheme %><br>
+ <% end %>
+ <% if @public_body.has_tag?("charity") %>
+ <% for tag_value in @public_body.get_tag_values("charity") %>
+ <% if tag_value.match(/^SC/) %>
+ <%= link_to _('Charity registration'), "http://www.oscr.org.uk/CharityIndexDetails.aspx?id=" + tag_value %><br>
+ <% else %>
+ <%= link_to _('Charity registration'), "http://www.charity-commission.gov.uk/SHOWCHARITY/RegisterOfCharities/CharityFramework.aspx?RegisteredCharityNumber=" + tag_value %><br>
+ <% end %>
+ <% end %>
+ <% end %>
+ <%= link_to _('View FOI email address'), view_public_body_email_url(@public_body.url_name) %><br>
+ </div>
- <div id="header_left">
- <p class="public-body-name-prefix"><%= _("Freedom of information requests to") %></p>
- <h1><%=h(@public_body.name)%></h1>
+ <div id="header_left">
+ <p class="public-body-name-prefix"><%= _("Freedom of information requests to") %></p>
+ <h1><%=h(@public_body.name)%></h1>
- <p class="subtitle">
- <%=@public_body.type_of_authority(true)%><% if not @public_body.short_name.empty? %>,
- <%= _('also called {{public_body_short_name}}', :public_body_short_name => h(@public_body.short_name))%><% end %>
- <% if !@user.nil? && @user.admin_page_links? %>
- (<%= link_to _("admin"), public_body_admin_url(@public_body) %>)
- <% end %>
- </p>
+ <p class="subtitle">
+ <%=@public_body.type_of_authority(true)%><% if not @public_body.short_name.empty? %>,
+ <%= _('also called {{public_body_short_name}}', :public_body_short_name => h(@public_body.short_name))%><% end %>
+ <% if !@user.nil? && @user.admin_page_links? %>
+ (<%= link_to _("admin"), public_body_admin_url(@public_body) %>)
+ <% end %>
+ </p>
- <% if @public_body.has_notes? && (@public_body.is_requestable? || @public_body.not_requestable_reason == 'bad_contact') %>
- <p><%= @public_body.notes_as_html %></p>
- <% end %>
+ <% if @public_body.has_notes? && (@public_body.is_requestable? || @public_body.not_requestable_reason == 'bad_contact') %>
+ <p><%= @public_body.notes_as_html %></p>
+ <% end %>
- <% if @public_body.eir_only? %>
- <p><%= _('You can only request information about the environment from this authority.')%></p>
- <% end %>
+ <% if @public_body.eir_only? %>
+ <p><%= _('You can only request information about the environment from this authority.')%></p>
+ <% end %>
- <div id="stepwise_make_request">
- <% if @public_body.is_requestable? || @public_body.not_requestable_reason == 'bad_contact' %>
- <% if @public_body.eir_only? %>
- <%= _('Make a new <strong>Environmental Information</strong> request')%>
+ <div id="stepwise_make_request">
+ <% if @public_body.is_requestable? || @public_body.not_requestable_reason == 'bad_contact' %>
+ <% if @public_body.eir_only? %>
+ <%= _('Make a new <strong>Environmental Information</strong> request')%>
+ <% else %>
+ <%= _('Make a new <strong>Freedom of Information</strong> request to {{public_body}}', :public_body => h(@public_body.name))%>
+ <% end %>
+ &nbsp;<%= _('<a class="link_button_green" href="{{url}}">{{text}}</a>', :url=>new_request_to_body_url(:url_name => @public_body.url_name), :text=>_("Start"))%>
+ <% elsif @public_body.has_notes? %>
+ <%= @public_body.notes_as_html %>
+ <% elsif @public_body.not_requestable_reason == 'not_apply' %>
+ <%= _('Freedom of Information law does not apply to this authority, so you cannot make
+ a request to it.')%>
+ <% elsif @public_body.not_requestable_reason == 'defunct' %>
+ <%= _('This authority no longer exists, so you cannot make a request to it.')%>
<% else %>
- <%= _('Make a new <strong>Freedom of Information</strong> request to {{public_body}}', :public_body => h(@public_body.name))%>
+ <%= _('For an unknown reason, it is not possible to make a request to this authority.')%>
<% end %>
- &nbsp;<%= _('<a class="link_button_green" href="{{url}}">{{text}}</a>', :url=>new_request_to_body_url(:url_name => @public_body.url_name), :text=>_("Start"))%>
- <% elsif @public_body.has_notes? %>
- <%= @public_body.notes_as_html %>
- <% elsif @public_body.not_requestable_reason == 'not_apply' %>
- <%= _('Freedom of Information law does not apply to this authority, so you cannot make
- a request to it.')%>
- <% elsif @public_body.not_requestable_reason == 'defunct' %>
- <%= _('This authority no longer exists, so you cannot make a request to it.')%>
- <% else %>
- <%= _('For an unknown reason, it is not possible to make a request to this authority.')%>
- <% end %>
+ </div>
</div>
- </div>
- <div id="foi_results_section">
- <% if @public_body.info_requests.size == 0 %>
- <% if @public_body.eir_only? %>
- <h2><%= _('Environmental Information Regulations requests made using this site') %></h2>
- <p>Nobody has made any Environmental Information Regulations requests to <%=h(@public_body.name)%> using this site yet.</p>
- <% else %>
- <h2><%= _('Freedom of Information requests made using this site')%></h2>
- <p><%= _('Nobody has made any Freedom of Information requests to {{public_body_name}} using this site yet.', :public_body_name => h(@public_body.name))%></p>
- <% end %>
- <% else %>
- <h2 class="foi_results">
- <% if @public_body.eir_only? %>
- <%= pluralize(@public_body.info_requests.size, "Environmental Information Regulations request made using this site") %>
+ <div id="foi_results_section">
+ <% if @public_body.info_requests.size == 0 %>
+ <% if @public_body.eir_only? %>
+ <h2><%= _('Environmental Information Regulations requests made using this site') %></h2>
+ <p>Nobody has made any Environmental Information Regulations requests to <%=h(@public_body.name)%> using this site yet.</p>
+ <% else %>
+ <h2><%= _('Freedom of Information requests made using this site')%></h2>
+ <p><%= _('Nobody has made any Freedom of Information requests to {{public_body_name}} using this site yet.', :public_body_name => h(@public_body.name))%></p>
+ <% end %>
<% else %>
- <% if @public_body.info_requests.size > 4 %>
- <%= n_('Search within the %d Freedom of Information requests to %s', 'Search within the %d Freedom of Information requests made to %s', @public_body.info_requests.size) % [@public_body.info_requests.size, @public_body.name] %>
- <% else %>
- <%= n_('%d Freedom of Information request to %s', '%d Freedom of Information requests to %s', @public_body.info_requests.size) % [@public_body.info_requests.size, @public_body.name] %>
- <% end %>
+ <h2 class="foi_results">
+ <% if @public_body.eir_only? %>
+ <%= pluralize(@public_body.info_requests.size, "Environmental Information Regulations request made using this site") %>
+ <% else %>
+ <% if @public_body.info_requests.size > 4 %>
+ <%= n_('Search within the %d Freedom of Information requests to %s', 'Search within the %d Freedom of Information requests made to %s', @public_body.info_requests.size) % [@public_body.info_requests.size, @public_body.name] %>
+ <% else %>
+ <%= n_('%d Freedom of Information request to %s', '%d Freedom of Information requests to %s', @public_body.info_requests.size) % [@public_body.info_requests.size, @public_body.name] %>
+ <% end %>
+ <% end %>
+ <%= @page_desc %>
+ </h2>
+ <a name="results"></a>
+
+ <% if @public_body.info_requests.size > 4 %>
+ <%= render :partial => 'request/request_filter_form' %>
+ <% end %>
<% end %>
- <%= @page_desc %>
- </h2>
- <a name="results"></a>
-
- <% if @public_body.info_requests.size > 4 %>
- <%= render :partial => 'request/request_filter_form' %>
- <% end %>
- <% end %>
- <div style="clear:both">&nbsp;</div>
- <% if !@xapian_requests.nil? %>
+ <div style="clear:both">&nbsp;</div>
+ <% if !@xapian_requests.nil? %>
<% for result in @xapian_requests.results %>
<%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %>
<% end %>
- <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @public_body.info_requests.size) %>
+ <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @xapian_requests.matches_estimated) %>
- <% 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>
- <% end %>
+ <% 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>
+ <% end %>
- <% else %>
- <% if @public_body.eir_only? %>
- <h2><%= _('Environmental Information Regulations requests made') %></h2>
- <% else %>
- <h2> <%= _('Freedom of Information requests made')%></h2>
+ <% else %>
+ <% if @public_body.eir_only? %>
+ <h2><%= _('Environmental Information Regulations requests made') %></h2>
+ <% else %>
+ <h2> <%= _('Freedom of Information requests made')%></h2>
+ <% end %>
+ <p> <%= _('The search index is currently offline, so we can\'t show the Freedom of Information requests that have been made to this authority.')%></p>
<% end %>
- <p> <%= _('The search index is currently offline, so we can\'t show the Freedom of Information requests that have been made to this authority.')%></p>
- <% end %>
</div>
</div>
diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css
index 8a7a3563a..cd617c115 100644
--- a/public/stylesheets/main.css
+++ b/public/stylesheets/main.css
@@ -711,13 +711,13 @@ padding:0.5em 0;
background-color:#fc9;
border:solid 2px #f60;
border-top:none;
-opacity:0.97px;
--moz-border-radius-bottomleft:10px;
--moz-border-radius-bottomright:10px;
+opacity:0.97;
+border-bottom-left-radius:10px;
+border-bottom-right-radius:10px;
position:fixed;
width:70%;
left:15%;
-z-index:200;
+z-index:2000;
max-height:95%;
overflow:auto;
padding:4px;
diff --git a/script/load-sample-data b/script/load-sample-data
index 0521ef849..84b8a28eb 100755
--- a/script/load-sample-data
+++ b/script/load-sample-data
@@ -6,7 +6,15 @@
LOC=`dirname $0`
rake --silent spec:db:fixtures:load
-"$LOC/runner" 'puts File.expand_path(File.dirname(__FILE__) + "/spec/spec_helper"); require File.expand_path(File.dirname(__FILE__) + "/spec/spec_helper"); RawEmail.all().each {|email| email.data = load_file_fixture("useless_raw_email.email")}'
+"$LOC/runner" /dev/stdin <<END
+env = ENV["RAILS_ENV"]
+require "spec/spec_helper.rb" # Sets RAILS_ENV to 'test'
+ENV["RAILS_ENV"] = env
+RawEmail.all().each do |email|
+ puts "Writing #{email.filepath}"
+ email.data = load_file_fixture("useless_raw_email.email")
+end
+END
-echo "Loaded fixtures." \ No newline at end of file
+echo "Loaded fixtures."
diff --git a/script/rebuild-xapian-index b/script/rebuild-xapian-index
index 11e4a46be..5986f5259 100755
--- a/script/rebuild-xapian-index
+++ b/script/rebuild-xapian-index
@@ -1,6 +1,4 @@
#!/bin/bash
cd `dirname $0`
-rake --silent xapian:rebuild_index models="PublicBody User InfoRequestEvent"
-
-
+rake --silent "$@" xapian:rebuild_index models="PublicBody User InfoRequestEvent"
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index a0ea9bb48..055c9b3d4 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -108,24 +108,40 @@ describe RequestController, "when showing one request" do
describe 'when handling an update_status parameter' do
-
- before do
- mock_request = mock_model(InfoRequest, :url_title => 'test_title',
- :title => 'test title',
- :null_object => true)
- InfoRequest.stub!(:find_by_url_title).and_return(mock_request)
- end
-
it 'should assign the "update status" flag to the view as true if the parameter is present' do
- get :show, :url_title => 'test_title', :update_status => 1
+ get :show, :url_title => 'why_do_you_have_such_a_fancy_dog', :update_status => 1
assigns[:update_status].should be_true
end
- it 'should assign the "update status" flag to the view as true if the parameter is present' do
- get :show, :url_title => 'test_title'
+ it 'should assign the "update status" flag to the view as false if the parameter is not present' do
+ get :show, :url_title => 'why_do_you_have_such_a_fancy_dog'
assigns[:update_status].should be_false
end
+ it 'should require login' do
+ session[:user_id] = nil
+ get :show, :url_title => 'why_do_you_have_such_a_fancy_dog', :update_status => 1
+ post_redirect = PostRedirect.get_last_post_redirect
+ response.should redirect_to(:controller => 'user', :action => 'signin', :token => post_redirect.token)
+ end
+
+ it 'should work if logged in as the requester' do
+ session[:user_id] = users(:bob_smith_user).id
+ get :show, :url_title => 'why_do_you_have_such_a_fancy_dog', :update_status => 1
+ response.should render_template "request/show"
+ end
+
+ it 'should not work if logged in as not the requester' do
+ session[:user_id] = users(:silly_name_user).id
+ get :show, :url_title => 'why_do_you_have_such_a_fancy_dog', :update_status => 1
+ response.should render_template "user/wrong_user"
+ end
+
+ it 'should work if logged in as an admin user' do
+ session[:user_id] = users(:admin_user).id
+ get :show, :url_title => 'why_do_you_have_such_a_fancy_dog', :update_status => 1
+ response.should render_template "request/show"
+ end
end
describe 'when handling incoming mail' do