aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorfrancis <francis>2007-10-24 11:39:37 +0000
committerfrancis <francis>2007-10-24 11:39:37 +0000
commitbc3b0c2e181697f240d3f8c863c4cdb03d4ca88d (patch)
tree2ab885540aa8a6586848f16ad719aa396d8146c4 /app/models
parent8277d14fc923089bef47ac92520fabec3dea64b7 (diff)
Read in mySociety style configuration file, if it is there (use sensible defaults if not).
Actually send request to public body, or fake address on staging site. Fix minor bug with sending front page form public body to new request page.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/outgoing_message.rb15
-rw-r--r--app/models/request_mailer.rb12
2 files changed, 17 insertions, 10 deletions
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