diff options
author | Francis Irving <francis@mysociety.org> | 2010-10-20 16:20:44 +0100 |
---|---|---|
committer | Francis Irving <francis@mysociety.org> | 2010-10-20 16:20:44 +0100 |
commit | 27cb7d82e63f00e947b81953e19e153575d402ad (patch) | |
tree | fd344b7abba12c381f0b4dfe311c5a19608d0728 /app/models/info_request.rb | |
parent | 7b85b81d1076169a9b01c301545f0f9192540f97 (diff) |
Show more appropriate info about users/bodies everywhere in JSON.
Diffstat (limited to 'app/models/info_request.rb')
-rw-r--r-- | app/models/info_request.rb | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 6b9e7b674..f35ef7f7d 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -958,13 +958,11 @@ public return info_request end - def json_for_api - return { + def json_for_api(deep) + ret = { :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, @@ -976,24 +974,14 @@ public # 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 - } } - } + + if deep + ret[:user] = self.user.json_for_api + ret[:public_body] = self.public_body.json_for_api + ret[:info_request_events] = self.info_request_events.map { |e| e.json_for_api(false) } + end + return ret end end |