diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/request_controller.rb | 52 | ||||
-rw-r--r-- | app/models/user.rb | 11 | ||||
-rw-r--r-- | app/views/request/_after_actions.rhtml | 28 | ||||
-rw-r--r-- | app/views/request/_describe_state.rhtml | 34 | ||||
-rw-r--r-- | app/views/request/_sidebar.rhtml | 36 | ||||
-rw-r--r-- | app/views/request/show.rhtml | 67 |
6 files changed, 123 insertions, 105 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index d0c12dc28..ae4f3a229 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -4,7 +4,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: request_controller.rb,v 1.154 2009-04-03 14:22:02 louise Exp $ +# $Id: request_controller.rb,v 1.155 2009-04-07 10:32:54 louise Exp $ class RequestController < ApplicationController @@ -24,16 +24,21 @@ 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 - @is_owning_user = !authenticated_user.nil? && (authenticated_user.id == @info_request.user_id || authenticated_user.owns_every_request?) + @update_status = params[:update_status] ? true : false + @is_owning_user = @info_request.is_owning_user?(authenticated_user) + + if @update_status + return if !@is_owning_user && !authenticated_as_user?(@info_request.user, + :web => "To update the status of this FOI request", + :email => "Then you can update the status of your request to " + @info_request.public_body.name + ".", + :email_subject => "Update the status of your request to " + @info_request.public_body.name + ) + end + @events_needing_description = @info_request.events_needing_description - last_event = @events_needing_description[-1] - @last_info_request_event_id = last_event.nil? ? 0 : last_event.id + @last_info_request_event_id = @info_request.last_event_id_needing_description @new_responses_count = @events_needing_description.select {|i| i.event_type == 'response'}.size - # special case that an admin user can edit requires_admin requests - @requires_admin_describe = (InfoRequest.requires_admin_states.include?(@info_request.described_state)) && !authenticated_user.nil? && authenticated_user.requires_admin_power? - # Sidebar stuff limit = 3 # ... requests that have similar imporant terms @@ -240,23 +245,9 @@ class RequestController < ApplicationController return end - # special case that an admin user can edit requires_admin requests - @requires_admin_describe = (InfoRequest.requires_admin_states.include?(@info_request.described_state)) && !authenticated_user.nil? && authenticated_user.requires_admin_power? - - if !@info_request.awaiting_description && !@requires_admin_describe - flash[:notice] = "The status of this request is up to date." - if !params[:submitted_describe_state].nil? - flash[:notice] = "The status of this request was made up to date elsewhere while you were filling in the form." - end - redirect_to request_url(@info_request) - return - end - - @collapse_quotes = params[:unfold] ? false : true + @is_owning_user = @info_request.is_owning_user?(authenticated_user) @events_needing_description = @info_request.events_needing_description - last_event = @events_needing_description[-1] - @last_info_request_event_id = last_event.nil? ? 0 : last_event.id - @is_owning_user = !authenticated_user.nil? && (authenticated_user.id == @info_request.user_id || authenticated_user.owns_every_request?) + @last_info_request_event_id = @info_request.last_event_id_needing_description @new_responses_count = @events_needing_description.select {|i| i.event_type == 'response'}.size # Check authenticated, and parameters set. We check is_owning_user @@ -284,6 +275,12 @@ class RequestController < ApplicationController # Make the state change @info_request.set_described_state(params[:incoming_message][:described_state]) + + if User.owns_every_request?(authenticated_user) + flash[:notice] = '<p>The request status has been updated</p>' + redirect_to request_url(@info_request) + return + end # Display appropriate next page (e.g. help for complaint etc.) if @info_request.calculate_status == 'waiting_response' @@ -316,7 +313,7 @@ class RequestController < ApplicationController redirect_to unhappy_url(@info_request) elsif @info_request.calculate_status == 'waiting_clarification' flash[:notice] = "Please write your follow up message containing the necessary clarifications below." - redirect_to show_response_url(:id => @info_request.id, :incoming_message_id => @events_needing_description[-1].params[:incoming_message_id]) + redirect_to respond_to_last_url(@info_request) elsif @info_request.calculate_status == 'gone_postal' redirect_to respond_to_last_url(@info_request) + "?gone_postal=1" elsif @info_request.calculate_status == 'internal_review' @@ -328,6 +325,9 @@ class RequestController < ApplicationController elsif @info_request.calculate_status == 'requires_admin' flash[:notice] = "Please use the form below to tell us more." redirect_to help_general_url(:action => 'contact') + elsif @info_request.calculate_status == 'user_withdrawn' + flash[:notice] = "Thanks for letting us know that you've withdrawn your request. Please add an annotation below to let other people know why you withdrew it." + redirect_to request_url(@info_request) else raise "unknown calculate_status " + @info_request.calculate_status end @@ -366,7 +366,7 @@ class RequestController < ApplicationController set_last_request(@info_request) @collapse_quotes = params[:unfold] ? false : true - @is_owning_user = !authenticated_user.nil? && (authenticated_user.id == @info_request.user_id || authenticated_user.owns_every_request?) + @is_owning_user = @info_request.is_owning_user?(authenticated_user) @gone_postal = params[:gone_postal] ? true : false if !@is_owning_user @gone_postal = false diff --git a/app/models/user.rb b/app/models/user.rb index be27e8f95..c281d7f18 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -23,7 +23,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: user.rb,v 1.86 2009-04-06 09:30:26 louise Exp $ +# $Id: user.rb,v 1.87 2009-04-07 10:32:54 louise Exp $ require 'digest/sha1' @@ -60,6 +60,7 @@ class User < ActiveRecord::Base # format it here as no datetime support in Xapian's value ranges return self.created_at.strftime("%Y%m%d%H%M%S") end + def variety "user" end @@ -210,13 +211,9 @@ class User < ActiveRecord::Base def owns_every_request? self.admin_level == 'super' end - # Can the user edit status of requires_admin requests from main website? - def requires_admin_power? - self.admin_level == 'super' - end - def self.requires_admin_power?(user) - !user.nil? && user.requires_admin_power? + def self.owns_every_request?(user) + !user.nil? && user.owns_every_request? end # Does the user get "(admin)" links on each page on the main site? diff --git a/app/views/request/_after_actions.rhtml b/app/views/request/_after_actions.rhtml new file mode 100644 index 000000000..aa6411453 --- /dev/null +++ b/app/views/request/_after_actions.rhtml @@ -0,0 +1,28 @@ +<div id="after_actions"> + + <h2>Things to do with this request</h2> + + <div id="anyone_actions"> + <%= link_to "Add an annotation", new_comment_url(:url_title => @info_request.url_title) %> (to help + the requester or others) + </div> + + <div id="owner_actions"> + <strong><%=h @info_request.user.name %> only:</strong> + <% if @last_response.nil? %> + <%= link_to "Send follow up to " + RequestMailer.name_for_followup(@info_request, @last_response), show_response_no_followup_url(:id => @info_request.id, :incoming_message_id => nil) + "#followup" %> + <% else %> + <%= link_to "Reply to " + RequestMailer.name_for_followup(@info_request, @last_response), show_response_url(:id => @info_request.id, :incoming_message_id => @last_response.id) + "#followup" %> + <% end %> + | + <%= link_to "Update the status of this request", request_url(@info_request, :update_status => 1) %> + | + <%= link_to "Request an internal review", show_response_no_followup_url(:id => @info_request.id, :incoming_message_id => nil) + "?internal_review=1#followup" %> + </div> + + <div id="public_body_actions"> + <strong><%=h @info_request.public_body.name %> only:</strong> + <%= link_to "Respond to request", upload_response_url(:url_title => @info_request.url_title) %> + </div> + +</div>
\ No newline at end of file diff --git a/app/views/request/_describe_state.rhtml b/app/views/request/_describe_state.rhtml index d6e24c453..8b3ac2cf3 100644 --- a/app/views/request/_describe_state.rhtml +++ b/app/views/request/_describe_state.rhtml @@ -1,4 +1,5 @@ -<% if @is_owning_user || @requires_admin_describe %> +<% if @is_owning_user %> + <% form_for(:incoming_message, @info_request, :url => describe_state_url(:id => @info_request.id)) do |f| %> <h2>What best describes the status of this request now?</h2> @@ -25,6 +26,13 @@ </div> <% end %> + <% if @update_status && @info_request.described_state != 'internal_review' %> + <div> + <%= radio_button "incoming_message", "described_state", "internal_review", :id => 'internal_review' + id_suffix %> + <label for="internal_review<%=id_suffix%>">I'm waiting for an <strong>internal review</strong> response</label> + </div> + <% end %> + <div> <%= radio_button "incoming_message", "described_state", "gone_postal", :id => 'gone_postal' + id_suffix %> <label for="gone_postal<%=id_suffix%>">They are going to reply <strong>by post</strong></label> @@ -61,14 +69,22 @@ I've received an <strong>error message</strong> </label> </div> -<!-- <div> - <%= radio_button "incoming_message", "described_state", "requires_admin", :id => 'requires_admin' + id_suffix %> - <label for="requires_admin<%=id_suffix%>"> - <strong>None</strong> of the above - </label> - </div> --> - - + <% if @update_status %> + <div> + <%= radio_button "incoming_message", "described_state", "requires_admin", :id => 'requires_admin' + id_suffix %> + <label for="error_message<%=id_suffix%>"> + This request <strong>requires administrator attention</strong> + </label> + </div> + + <div> + <%= radio_button "incoming_message", "described_state", "user_withdrawn", :id => 'user_withdrawn' + id_suffix %> + <label for="user_withdrawn<%=id_suffix%>"> + I would like to <strong>withdraw this request</strong> + </label> + </div> + <% end %> + <hr> <p> diff --git a/app/views/request/_sidebar.rhtml b/app/views/request/_sidebar.rhtml new file mode 100644 index 000000000..0cb9207d8 --- /dev/null +++ b/app/views/request/_sidebar.rhtml @@ -0,0 +1,36 @@ +<div id="request_sidebar"> + <h2>Track this request</h2> + <%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => @info_request.user == @user, :location => 'sidebar' } %> + + <h2>Act on what you've learnt</h2> + <div class="act_link"> + <%= link_to '<img src="/images/writetothem.png" alt="" class="rss">', "http://www.writetothem.com"%> + <%= link_to 'Write to your politician', "http://www.writetothem.com"%> + </div> + <div class="act_link"> + <%= link_to '<img src="/images/pledgebank.png" alt="" class="rss">', "http://www.pledgebank.com"%> + <%= link_to 'Pledge with others', "http://www.pledgebank.com"%> + </div> + <div class="act_link"> + <%= link_to '<img src="/images/petitions.png" alt="" class="rss">', "http://petitions.number10.gov.uk"%> + <%= link_to 'Petition the PM', "http://petitions.number10.gov.uk"%> + </div> + <div class="act_link"> + <%= link_to '<img src="/images/wordpress.png" alt="" class="rss">', "http://wordpress.com/"%> + <%= link_to 'Start your own blog', "http://wordpress.com/"%> + </div> + + <% if !@xapian_similar.nil? && @xapian_similar.results.size > 0 %> + <h2>Similar requests</h2> + <% for result in @xapian_similar.results %> + <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %> + <% end %> + <% if @xapian_similar_more %> + <p><%= link_to "More similar requests", request_similar_url(@info_request) %></p> + <% end %> + <!-- Important terms: <%= @xapian_similar.important_terms.join(" ") %> --> + <% end %> + + <p><a href="/help/about#commercial">Are you the owner of + any commercial copyright on this page?</a></p> +</div>
\ No newline at end of file diff --git a/app/views/request/show.rhtml b/app/views/request/show.rhtml index b86b92800..fa9c8f4a7 100644 --- a/app/views/request/show.rhtml +++ b/app/views/request/show.rhtml @@ -1,48 +1,12 @@ <% @title = h(@info_request.title) %> -<% if @info_request.awaiting_description || @requires_admin_describe %> +<% if @update_status || @info_request.awaiting_description %> <div class="describe_state_form" id="describe_state_form_1"> <%= render :partial => 'describe_state', :locals => { :id_suffix => "1" } %> </div> <% end %> -<div id="request_sidebar"> - <h2>Track this request</h2> - <%= render :partial => 'track/tracking_links', :locals => { :track_thing => @track_thing, :own_request => @info_request.user == @user, :location => 'sidebar' } %> - - <h2>Act on what you've learnt</h2> - <div class="act_link"> - <%= link_to '<img src="/images/writetothem.png" alt="" class="rss">', "http://www.writetothem.com"%> - <%= link_to 'Write to your politician', "http://www.writetothem.com"%> - </div> - <div class="act_link"> - <%= link_to '<img src="/images/pledgebank.png" alt="" class="rss">', "http://www.pledgebank.com"%> - <%= link_to 'Pledge with others', "http://www.pledgebank.com"%> - </div> - <div class="act_link"> - <%= link_to '<img src="/images/petitions.png" alt="" class="rss">', "http://petitions.number10.gov.uk"%> - <%= link_to 'Petition the PM', "http://petitions.number10.gov.uk"%> - </div> - <div class="act_link"> - <%= link_to '<img src="/images/wordpress.png" alt="" class="rss">', "http://wordpress.com/"%> - <%= link_to 'Start your own blog', "http://wordpress.com/"%> - </div> - - <% if !@xapian_similar.nil? && @xapian_similar.results.size > 0 %> - <h2>Similar requests</h2> - <% for result in @xapian_similar.results %> - <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %> - <% end %> - <% if @xapian_similar_more %> - <p><%= link_to "More similar requests", request_similar_url(@info_request) %></p> - <% end %> - <!-- Important terms: <%= @xapian_similar.important_terms.join(" ") %> --> - <% end %> - - <p><a href="/help/about#commercial">Are you the owner of - any commercial copyright on this page?</a></p> -</div> - +<%= render :partial => 'sidebar' %> <div id="request_main"> <h1><%=@title%></h1> @@ -98,7 +62,7 @@ <% if @is_owning_user %> <%=h @info_request.public_body.name %> is <strong>waiting for your clarification</strong>. Please - <%= link_to "send a follow up message", show_response_url(:id => @info_request.id, :incoming_message_id => @info_request.get_last_response.id) + "#followup" %>. + <%= link_to "send a follow up message", respond_to_last_url(@info_request) + '#followup' %>. <% else %> The request is <strong>waiting for clarification</strong>. If you are @@ -133,29 +97,6 @@ </div> <% end %> - <div id="after_actions"> - <h2>Things to do with this request</h2> - - <p> - <%= link_to "Add an annotation", new_comment_url(:url_title => @info_request.url_title) %> (to help - the requester or others) - </p> - - <p> - <strong><%=h @info_request.user.name %> only:</strong> - <% if @last_response.nil? %> - <%= link_to "Send follow up to " + RequestMailer.name_for_followup(@info_request, @last_response), show_response_no_followup_url(:id => @info_request.id, :incoming_message_id => nil) + "#followup" %> - <% else %> - <%= link_to "Reply to " + RequestMailer.name_for_followup(@info_request, @last_response), show_response_url(:id => @info_request.id, :incoming_message_id => @last_response.id) + "#followup" %> - <% end %> - | - <%= link_to "Request an internal review", show_response_no_followup_url(:id => @info_request.id, :incoming_message_id => nil) + "?internal_review=1#followup" %> - - <br> - - <strong><%=h @info_request.public_body.name %> only:</strong> - <%= link_to "Respond to request", upload_response_url(:url_title => @info_request.url_title) %> - </p> - </div> + <%= render :partial => 'after_actions' %> </div> |