diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/application.rb | 6 | ||||
-rw-r--r-- | app/controllers/request_controller.rb | 8 | ||||
-rw-r--r-- | app/models/outgoing_message.rb | 15 | ||||
-rw-r--r-- | app/models/request_mailer.rb | 12 | ||||
-rw-r--r-- | app/views/layouts/default.rhtml | 7 | ||||
-rw-r--r-- | app/views/request_mailer/initial_request.rhtml | 7 |
6 files changed, 37 insertions, 18 deletions
diff --git a/app/controllers/application.rb b/app/controllers/application.rb index e86fe7338..0241ec66e 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -6,7 +6,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: application.rb,v 1.15 2007-10-16 21:17:14 louise Exp $ +# $Id: application.rb,v 1.16 2007-10-24 11:39:37 francis Exp $ class ApplicationController < ActionController::Base @@ -138,5 +138,7 @@ class ApplicationController < ActionController::Base return request.env["REMOTE_USER"] end end - end + + + diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index dfc614e59..0f0a7167c 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.5 2007-10-16 21:17:14 louise Exp $ +# $Id: request_controller.rb,v 1.6 2007-10-24 11:39:37 francis Exp $ class RequestController < ApplicationController @@ -16,12 +16,13 @@ class RequestController < ApplicationController @info_request_pages, @info_requests = paginate :info_requests, :per_page => 25, :order => "created_at desc" end - def frontpage end # Form for creating new request def new + # Read parameters in - public body can be passed from front page + @info_request = InfoRequest.new(params[:info_request]) end # Page new form posts to @@ -41,7 +42,8 @@ class RequestController < ApplicationController elsif authenticated? @info_request.user = authenticated_user @info_request.save - flash[:notice] = "Your Freedom of Information request has been created." + @outgoing_message.send_message + flash[:notice] = "Your Freedom of Information request has been created and sent on its way." redirect_to request_url(:id => @info_request) end diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb index ed2b415ae..4ed0f58ee 100644 --- a/app/models/outgoing_message.rb +++ b/app/models/outgoing_message.rb @@ -5,7 +5,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.5 2007-10-16 08:57:32 francis Exp $ +# $Id: outgoing_message.rb,v 1.6 2007-10-24 11:39:37 francis Exp $ class OutgoingMessage < ActiveRecord::Base belongs_to :info_request @@ -16,15 +16,20 @@ class OutgoingMessage < ActiveRecord::Base validates_inclusion_of :message_type, :in => ['initial_request'] #, 'complaint'] + # Deliver outgoing message + # Note: You can test this from script/console with, say: + # InfoRequest.find(1).outgoing_messages[0].send_message def send_message if message_type == 'initial_request' if status == 'ready' - # test this with: - # InfoRequest.find(1).outgoing_messages[0].send_message - RequestMailer.deliver_initial_request(info_request, self) + sent_at = Time.now + status = 'sent' + save + elsif status == 'sent' + raise "Message id #{id} has already been sent" else - raise "Message id #{id} not ready for send_message" + raise "Message id #{id} not in state for send_message" end else raise "Message id #{id} has type '#{message_type}' which send_message can't handle" diff --git a/app/models/request_mailer.rb b/app/models/request_mailer.rb index c6b99159e..0e1c2be12 100644 --- a/app/models/request_mailer.rb +++ b/app/models/request_mailer.rb @@ -4,15 +4,17 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: request_mailer.rb,v 1.1 2007-10-16 08:57:32 francis Exp $ +# $Id: request_mailer.rb,v 1.2 2007-10-24 11:39:37 francis Exp $ class RequestMailer < ActionMailer::Base def initial_request(info_request, outgoing_message) - @from = 'francis@flourish.org' # XXX - @recipients = 'frabcus@fastmail.fm' - # XXX check with staging site - #@recipients = info_request.public_body.request_email + @from = info_request.user.email + if MySociety::Config.getbool("STAGING_SITE", 1) + @recipients = @from + else + @recipients = info_request.public_body.request_email + end @subject = 'Freedom of Information Request - ' + info_request.title @body = {:info_request => info_request, :outgoing_message => outgoing_message} end diff --git a/app/views/layouts/default.rhtml b/app/views/layouts/default.rhtml index b645876e7..d480d82e9 100644 --- a/app/views/layouts/default.rhtml +++ b/app/views/layouts/default.rhtml @@ -6,9 +6,14 @@ <%= stylesheet_link_tag 'main' %> </head> <body> + <% if MySociety::Config.getbool("STAGING_SITE", 1) %> + <div id="staging"> + This is a test version of the site. FOI requests will not be sent to real public bodies. + </div> + <% end %> <div id="header"> <h1> - <a href="/">Government Spy</a> + <a href="/">GovernmentSpy</a> <span id="beta">Beta</span> </h1> <div id="tagline">Freeing your information from them</div> diff --git a/app/views/request_mailer/initial_request.rhtml b/app/views/request_mailer/initial_request.rhtml index 795773c74..14f2d184f 100644 --- a/app/views/request_mailer/initial_request.rhtml +++ b/app/views/request_mailer/initial_request.rhtml @@ -2,6 +2,9 @@ Dear <%= @info_request.public_body.name %>, <%= @outgoing_message.body %> ------------ +-- -This message was sent using FOIFA. Blah. +Sent using GovernmentSpy, a project of UKCOD, registered charity number +1076346. If this is not the correct address for Freedom of Information +requests, please let us know by contacting team@governmentspy and we'll make +sure future ones go to the right place. |