1 class OldNodeController < ApplicationController
4 skip_before_filter :verify_authenticity_token
5 before_filter :setup_user_auth, :only => [ :history, :version ]
6 before_filter :authorize, :only => [ :redact ]
7 before_filter :authorize_moderator, :only => [ :redact ]
8 before_filter :require_allow_write_api, :only => [ :redact ]
9 before_filter :check_api_readable
10 before_filter :check_api_writable, :only => [ :redact ]
11 before_filter :lookup_old_node, :except => [ :history ]
12 after_filter :compress_output
13 around_filter :api_call_handle_error, :api_call_timeout
16 node = Node.find(params[:id].to_i)
18 doc = OSM::API.new.get_xml_doc
20 visible_nodes = if @user and @user.moderator? and params[:show_redactions] == "true"
23 node.old_nodes.unredacted
26 visible_nodes.each do |old_node|
27 doc.root << old_node.to_xml_node
30 render :text => doc.to_s, :content_type => "text/xml"
34 if @old_node.redacted? and (@user.nil? or not @user.moderator?) and not params[:show_redactions] == "true"
35 render :nothing => true, :status => :forbidden
38 response.last_modified = @old_node.timestamp
40 doc = OSM::API.new.get_xml_doc
41 doc.root << @old_node.to_xml_node
43 render :text => doc.to_s, :content_type => "text/xml"
48 redaction_id = params['redaction']
49 unless redaction_id.nil?
50 # if a redaction ID was specified, then set this node to
51 # be redacted in that redaction. (TODO: check that the
52 # user doing the redaction owns the redaction object too)
53 redaction = Redaction.find(redaction_id.to_i)
54 @old_node.redact!(redaction)
57 # if no redaction ID was provided, then this is an unredact
59 @old_node.redact!(nil)
62 # just return an empty 200 OK for success
63 render :nothing => true
69 @old_node = OldNode.where(:node_id => params[:id], :version => params[:version]).first
72 #raise OSM::APINotFoundError.new
73 # but i get errors, so i'm getting very fed up and doing this instead
74 render :nothing => true, :status => :not_found