1 class OldWayController < 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_way, :except => [ :history ]
12 after_filter :compress_output
13 around_filter :api_call_handle_error, :api_call_timeout
16 way = Way.find(params[:id].to_i)
18 doc = OSM::API.new.get_xml_doc
20 visible_ways = if @user and @user.moderator? and params[:show_redactions] == "true"
23 way.old_ways.unredacted
26 visible_ways.each do |old_way|
27 doc.root << old_way.to_xml_node
30 render :text => doc.to_s, :content_type => "text/xml"
34 if @old_way.redacted? and not (@user and @user.moderator? and params[:show_redactions] == "true")
35 render :nothing => true, :status => :forbidden
38 response.last_modified = @old_way.timestamp
40 doc = OSM::API.new.get_xml_doc
41 doc.root << @old_way.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 way 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_way.redact!(redaction)
57 # if no redaction ID was provided, then this is an unredact
62 # just return an empty 200 OK for success
63 render :nothing => true
69 @old_way = OldWay.where(:way_id => params[:id], :version => params[:version]).first
71 render :nothing => true, :status => :not_found