aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/info_request.rb
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2013-10-24 16:00:10 +0100
committerLouise Crow <louise.crow@gmail.com>2013-12-04 09:32:42 +0000
commitcf11b959899d54cf3c7f4e018f11c2c89c83d4af (patch)
tree0508899f4581155e77940fb099d1a3c0bc3dc042 /app/models/info_request.rb
parentaf739bfb229c66655c86d588ad37920f3584973f (diff)
Simple code for the happy path
Create the batch and associate new requests with it, send the outgoing messages, and redirect to a page for the new batch.
Diffstat (limited to 'app/models/info_request.rb')
-rw-r--r--app/models/info_request.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 3c3afe0ea..b990f4b41 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -936,6 +936,20 @@ public
self.idhash = InfoRequest.hash_from_id(self.id)
end
+ def InfoRequest.create_from_attributes(info_request_atts, outgoing_message_atts, user=nil)
+ info_request = new(info_request_atts)
+ default_message_params = {
+ :status => 'ready',
+ :message_type => 'initial_request',
+ :what_doing => 'normal_sort'
+ }
+ outgoing_message = OutgoingMessage.new(outgoing_message_atts.merge(default_message_params))
+ info_request.outgoing_messages << outgoing_message
+ outgoing_message.info_request = info_request
+ info_request.user = user
+ info_request
+ end
+
def InfoRequest.hash_from_id(id)
return Digest::SHA1.hexdigest(id.to_s + AlaveteliConfiguration::incoming_email_secret)[0,8]
end