aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2013-11-27 12:53:13 +0000
committerLouise Crow <louise.crow@gmail.com>2013-12-04 09:32:45 +0000
commit0f43f36254c9bbd1a66f5fd0951d5c2517581e4d (patch)
tree49190077f7ce5ab895f991054832ec70bf377440
parentf31ff5e5cfd6247338ad769c713a7f21af4a0623 (diff)
Display batch requests for user on 'my requests' page
This is the most rudimentary possible way to give them access to the batch request urls, pending #1239
-rw-r--r--app/controllers/user_controller.rb3
-rw-r--r--app/models/user.rb1
-rw-r--r--app/views/info_request_batch/_info_request_batch.html.erb15
-rw-r--r--app/views/user/show.html.erb11
-rw-r--r--spec/controllers/user_controller_spec.rb6
5 files changed, 34 insertions, 2 deletions
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
index 175425280..8d6522923 100644
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/user_controller.rb
@@ -26,12 +26,15 @@ class UserController < ApplicationController
if params[:view].nil?
@show_requests = true
@show_profile = true
+ @show_batches = false
elsif params[:view] == 'profile'
@show_profile = true
@show_requests = false
+ @show_batches = false
elsif params[:view] == 'requests'
@show_profile = false
@show_requests = true
+ @show_batches = true
end
@display_user = User.find(:first, :conditions => [ "url_name = ? and email_confirmed = ?", params[:url_name], true ])
diff --git a/app/models/user.rb b/app/models/user.rb
index 730550301..e63ce8129 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -42,6 +42,7 @@ class User < ActiveRecord::Base
has_many :comments, :order => 'created_at desc'
has_one :profile_photo
has_many :censor_rules, :order => 'created_at desc'
+ has_many :info_request_batches, :order => 'created_at desc'
attr_accessor :password_confirmation, :no_xapian_reindex
validates_confirmation_of :password, :message => _("Please enter the same password twice")
diff --git a/app/views/info_request_batch/_info_request_batch.html.erb b/app/views/info_request_batch/_info_request_batch.html.erb
new file mode 100644
index 000000000..86ef90654
--- /dev/null
+++ b/app/views/info_request_batch/_info_request_batch.html.erb
@@ -0,0 +1,15 @@
+<div class="request_listing">
+ <div class="request_left">
+ <span class="head">
+ <%= link_to highlight_words(info_request_batch.title, @highlight_words), info_request_batch_path(info_request_batch) %>
+ </span>
+ <div class="requester">
+ <%= _('Batch created by {{info_request_user}} on {{date}}.', :info_request_user => user_link_absolute(info_request_batch.user),:date=>simple_date(info_request_batch.created_at)) %>
+ </div>
+ </div>
+ <div class="request_right">
+ <span class="desc">
+ <%= excerpt(info_request_batch.body, '', :radius => 150) %>
+ </span>
+ </div>
+</div>
diff --git a/app/views/user/show.html.erb b/app/views/user/show.html.erb
index c9862effe..76ecdeda0 100644
--- a/app/views/user/show.html.erb
+++ b/app/views/user/show.html.erb
@@ -105,6 +105,17 @@
<div style="clear:both"></div>
<% end %>
+<% if @show_batches %>
+
+ <% if @is_you && !@display_user.info_request_batches.empty? %>
+ <h2 class="batch_results" id="batch_requests">
+ <%= n_('Your {{count}} batch requests', 'Your {{count}} batch requests', @display_user.info_request_batches.size, :count => @display_user.info_request_batches.size) %>
+ </h2>
+ <%= render :partial => 'info_request_batch/info_request_batch', :collection => @display_user.info_request_batches %>
+ <% end %>
+
+<% end %>
+
<% if @show_requests %>
<div id="user_profile_search">
<%= form_tag(show_user_url, :method => "get", :id=>"search_form") do %>
diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb
index 7a9981a04..cf361d898 100644
--- a/spec/controllers/user_controller_spec.rb
+++ b/spec/controllers/user_controller_spec.rb
@@ -58,9 +58,10 @@ describe UserController, "when showing a user" do
get :show, {:url_name => @user.url_name, :view => 'profile'}, {:user_id => @user.id}
end
- it 'should not show requests but should show account options' do
+ it 'should not show requests, or batch requests, but should show account options' do
make_request
response.body.should_not match(/Freedom of Information requests made by you/)
+ assigns[:show_batches].should be_false
response.body.should include("Change your password")
end
@@ -74,9 +75,10 @@ describe UserController, "when showing a user" do
get :show, {:url_name => @user.url_name, :view => 'requests'}, {:user_id => @user.id}
end
- it 'should show requests but no account options' do
+ it 'should show requests, batch requests, but no account options' do
make_request
response.body.should match(/Freedom of Information requests made by you/)
+ assigns[:show_batches].should be_true
response.body.should_not include("Change your password")
end