aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/info_request.rb
diff options
context:
space:
mode:
authorFrancis Irving <francis@mysociety.org>2010-10-20 15:58:58 +0100
committerFrancis Irving <francis@mysociety.org>2010-10-20 15:58:58 +0100
commit7b85b81d1076169a9b01c301545f0f9192540f97 (patch)
tree07b9afb00dd2c2604025e5ff79a51bd0296d1c28 /app/models/info_request.rb
parente36720f39d8e8e89f5adf396aa76cd2509574da3 (diff)
Return more info in request JSON response.
Diffstat (limited to 'app/models/info_request.rb')
-rw-r--r--app/models/info_request.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index b485bd80e..6b9e7b674 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -957,6 +957,44 @@ public
end
return info_request
end
+
+ def json_for_api
+ return {
+ :id => self.id,
+ :url_title => self.url_title,
+ :title => self.title,
+ :user => self.user.json_for_api,
+ :public_body => self.public_body.json_for_api,
+ :created_at => self.created_at,
+ :updated_at => self.updated_at,
+ :described_state => self.described_state,
+ :awaiting_description => self.awaiting_description ,
+ :prominence => self.prominence,
+ :law_used => self.law_used,
+ :tags => self.tag_array,
+
+ # not sure we need to make these, mainly anti-spam, admin params public
+ # allow_new_responses_from
+ # handle_rejected_responses
+
+ :info_request_events => self.info_request_events.map { |e| {
+ # XXX this code is partly duplicated with the track controller
+ :id => e.id,
+ :event_type => e.event_type,
+ # params_yaml has possibly sensitive data in it, don't include it
+ :created_at => e.created_at,
+ :described_state => e.described_state,
+ :calculated_state => e.calculated_state,
+ :last_described_at => e.last_described_at,
+ :incoming_message_id => e.incoming_message_id,
+ :outgoing_message_id => e.outgoing_message_id,
+ :comment_id => e.comment_id,
+ # XXX would be nice to add links here, but alas the
+ # code to make them is in views only. See views/request/details.rhtml
+ } }
+
+ }
+ end
end