diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/request_controller.rb | 15 | ||||
-rw-r--r-- | app/models/outgoing_message.rb | 15 | ||||
-rw-r--r-- | app/views/request/new.rhtml | 5 | ||||
-rw-r--r-- | app/views/request/preview.rhtml | 32 |
4 files changed, 60 insertions, 7 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 60d12e68d..3d7e1c869 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.58 2008-02-22 13:26:36 francis Exp $ +# $Id: request_controller.rb,v 1.59 2008-02-25 11:17:29 francis Exp $ class RequestController < ApplicationController @@ -53,7 +53,7 @@ class RequestController < ApplicationController # Page new form posts to def new # First time we get to the page, just display it - if params[:submitted_new_request].nil? + if params[:submitted_new_request].nil? or params[:reedit] # Read parameters in - public body can be passed from front page if params[:public_body_id] params[:info_request] = { :public_body_id => params[:public_body_id] } @@ -90,7 +90,16 @@ class RequestController < ApplicationController # will be valid for a specific reason which we are displaying anyway. @info_request.errors.delete("outgoing_messages") render :action => 'new' - elsif authenticated?( + return + end + + # Show preview page, if it is a preview + if params[:preview].to_i == 1 + render :action => 'preview' + return + end + + if authenticated?( :web => "To send your FOI request", :email => "Then your FOI request to " + @info_request.public_body.name + " will be sent.", :email_subject => "Confirm your FOI request to " + @info_request.public_body.name diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb index 519c0be94..9c76bc03f 100644 --- a/app/models/outgoing_message.rb +++ b/app/models/outgoing_message.rb @@ -21,7 +21,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: outgoing_message.rb,v 1.29 2008-02-21 20:45:51 francis Exp $ +# $Id: outgoing_message.rb,v 1.30 2008-02-25 11:17:29 francis Exp $ class OutgoingMessage < ActiveRecord::Base belongs_to :info_request @@ -124,7 +124,18 @@ class OutgoingMessage < ActiveRecord::Base # Return body for display as HTML def get_body_for_html_display - text = body + text = self.body + text = MySociety::Format.make_clickable(text, :contract => 1) + text = text.gsub(/\n/, '<br>') + + return text + end + + # Return body for display as HTML + # XXX this is repeating code in a combination of + # views/layouts/request_mailer.rhtml and views/request_mailer/initial_request.rhtml + def get_body_for_html_preview + text = MySociety::Format.wrap_email_body(self.body.strip) text = MySociety::Format.make_clickable(text, :contract => 1) text = text.gsub(/\n/, '<br>') diff --git a/app/views/request/new.rhtml b/app/views/request/new.rhtml index 18f719264..2bf80eb1b 100644 --- a/app/views/request/new.rhtml +++ b/app/views/request/new.rhtml @@ -69,8 +69,9 @@ <div class="form_button"> <%= f.hidden_field(:public_body_id, { :value => @info_request.public_body_id } ) %> - <%= hidden_field_tag(:submitted_new_request, { :value => 1 } ) %> - <%= submit_tag "Make public Freedom of Information request >>" %> + <%= hidden_field_tag(:submitted_new_request, 1 ) %> + <%= hidden_field_tag(:preview, 1 ) %> + <%= submit_tag "Preview your public request" %> </div> <% end %> diff --git a/app/views/request/preview.rhtml b/app/views/request/preview.rhtml new file mode 100644 index 000000000..7104d65a5 --- /dev/null +++ b/app/views/request/preview.rhtml @@ -0,0 +1,32 @@ +<% @title = "Preview new FOI request to '" + h(@info_request.public_body.name) + "'" %> + +<% form_for(:info_request, @info_request, :html => { :id => 'preview_form' } ) do |f| %> + + <h1>Preview your request</h1> + + <%= f.hidden_field(:title) %> + + <% fields_for :outgoing_message do |o| %> + <p class="outgoing_message_preview"> + <strong>To:</strong> <%=h @info_request.public_body.name %> + <br><strong>Subject:</strong> <%=h @info_request.title %> + <br><br> + <%= @outgoing_message.get_body_for_html_preview %> + <%= o.hidden_field(:body) %> + </p> + <% end %> + + <strong>Note:</strong> Your request and any response will be + displayed publically on this website. + + <p> + <%= f.hidden_field(:public_body_id, { :value => @info_request.public_body_id } ) %> + <%= hidden_field_tag(:submitted_new_request, 1) %> + <%= hidden_field_tag(:preview, 0 ) %> + <%= submit_tag "Re-edit this request", :name => 'reedit' %> + <%= submit_tag "Send Freedom of Information request", :name => 'submit' %> + </p> + +<% end %> + + |