diff options
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/public_body_controller.rb | 20 | ||||
-rw-r--r-- | app/controllers/request_controller.rb | 40 |
2 files changed, 60 insertions, 0 deletions
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb index 560206900..0a2e72a5a 100644 --- a/app/controllers/public_body_controller.rb +++ b/app/controllers/public_body_controller.rb @@ -47,6 +47,26 @@ class PublicBodyController < ApplicationController @track_thing = TrackThing.create_track_for_public_body(@public_body) @feed_autodetect = [ { :url => do_track_url(@track_thing, 'feed'), :title => @track_thing.params[:title_in_rss] } ] + + respond_to do |format| + format.html { @has_json = true } + format.json { + render :json => { + :id => @public_body.id, + :url_name => @public_body.url_name, + :name => @public_body.name, + :short_name => @public_body.short_name, + # :request_email # we hide this behind a captcha, to stop people doing bulk requests easily + :created_at => @public_body.created_at, + :updated_at => @public_body.updated_at, + # :version, :last_edit_editor, :last_edit_comment # history, not done yet + :home_page => @public_body.calculated_home_page, + :notes => @public_body.notes, + :publication_scheme => @public_body.publication_scheme, + :tags => @public_body.tag_array, + } + } + end end def view_email diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 7626e5ad2..167667725 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -68,6 +68,46 @@ class RequestController < ApplicationController # For send followup link at bottom @last_response = @info_request.get_last_response + + respond_to do |format| + format.html { @has_json = true } + format.json { + render :json => { + :id => @info_request.id, + :url_title => @info_request.url_title, + :title => @info_request.title, + :user => @info_request.user.url_name, + :public_body => @info_request.public_body.url_name, + :created_at => @info_request.created_at, + :updated_at => @info_request.updated_at, + :described_state => @info_request.described_state, + :awaiting_description => @info_request.awaiting_description , + :prominence => @info_request.prominence, + :law_used => @info_request.law_used, + :tags => @info_request.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 => @info_request_events.map { |e| { + :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 # Extra info about a request, such as event history |