aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/admin_censor_rule_controller.rb2
-rw-r--r--app/controllers/api_controller.rb52
-rw-r--r--app/controllers/application_controller.rb4
3 files changed, 58 insertions, 0 deletions
diff --git a/app/controllers/admin_censor_rule_controller.rb b/app/controllers/admin_censor_rule_controller.rb
index 52df8dfc1..ec86cdf8e 100644
--- a/app/controllers/admin_censor_rule_controller.rb
+++ b/app/controllers/admin_censor_rule_controller.rb
@@ -31,6 +31,8 @@ class AdminCensorRuleController < AdminController
redirect_to admin_url('request/show/' + @censor_rule.info_request.id.to_s)
elsif !@censor_rule.user.nil?
redirect_to admin_url('user/show/' + @censor_rule.user.id.to_s)
+ elsif @censor_rule.regexp?
+ redirect_to admin_url('')
else
raise "internal error"
end
diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb
index 524aa44b7..4db07b4c9 100644
--- a/app/controllers/api_controller.rb
+++ b/app/controllers/api_controller.rb
@@ -155,6 +155,58 @@ class ApiController < ApplicationController
head :no_content
end
+ def body_request_events
+ feed_type = params[:feed_type]
+ raise PermissionDenied.new("#{@public_body.id} != #{params[:id]}") if @public_body.id != params[:id].to_i
+
+ @events = InfoRequestEvent.find_by_sql([
+ %(select info_request_events.*
+ from info_requests
+ join info_request_events on info_requests.id = info_request_events.info_request_id
+ where info_requests.public_body_id = ?
+ and info_request_events.event_type in (
+ 'sent', 'followup_sent', 'resent', 'followup_resent'
+ )
+ order by info_request_events.created_at desc
+ ), @public_body.id
+ ])
+ if feed_type == "atom"
+ render :template => "api/request_events.atom", :layout => false
+ elsif feed_type == "json"
+ # For the JSON feed, we take a "since" parameter that allows the client
+ # to restrict to events more recent than a certain other event
+ if params[:since_event_id]
+ @since_event_id = params[:since_event_id].to_i
+ end
+ @event_data = []
+ @events.each do |event|
+ break if event.id == @since_event_id
+
+ request = event.info_request
+ this_event = {
+ :request_id => request.id,
+ :event_id => event.id,
+ :created_at => event.created_at.iso8601,
+ :event_type => event.event_type,
+ :request_url => main_url(request_url(request)),
+ :request_email => request.incoming_email,
+ :title => request.title,
+ :body => event.outgoing_message.body,
+
+ :user_name => request.user_name,
+ }
+ if request.user
+ this_event[:user_url] = main_url(user_url(request.user))
+ end
+
+ @event_data.push(this_event)
+ end
+ render :json => @event_data
+ else
+ raise ActiveRecord::RecordNotFound.new("Unrecognised feed type: #{feed_type}")
+ end
+ end
+
protected
def check_api_key
raise "Missing required parameter 'k'" if params[:k].nil?
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 41adf1848..11f21025c 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -27,6 +27,7 @@ class ApplicationController < ActionController::Base
before_filter :check_in_post_redirect
before_filter :session_remember_me
before_filter :set_vary_header
+ before_filter :set_popup_banner
# scrub sensitive parameters from the logs
filter_parameter_logging :password
@@ -553,6 +554,9 @@ class ApplicationController < ActionController::Base
return country
end
+ def set_popup_banner
+ @popup_banner = render_to_string(:partial => "general/popup_banner").strip
+ end
# URL generating functions are needed by all controllers (for redirects),
# views (for links) and mailers (for use in emails), so include them into
# all of all.