1 # this class pulls together the logic for all the old_* controllers
2 # into one place. as it turns out, the API methods for historical
3 # nodes, ways and relations are basically identical.
5 class OldElementsController < ApiController
6 before_action :check_api_writable, :only => [:redact]
7 before_action :setup_user_auth, :only => [:history, :show]
8 before_action :authorize, :only => [:redact]
12 before_action :lookup_old_element, :except => [:history]
13 before_action :lookup_old_element_versions, :only => [:history]
15 before_action :set_request_formats, :except => [:redact]
18 # the .where() method used in the lookup_old_element_versions
19 # call won't throw an error if no records are found, so we have
20 # to do that ourselves.
21 raise OSM::APINotFoundError if @elements.empty?
23 # determine visible elements
24 @elems = if show_redactions?
31 respond_to do |format|
38 if @old_element.redacted? && !show_redactions?
42 response.last_modified = @old_element.timestamp
45 respond_to do |format|
53 redaction_id = params["redaction"]
55 # if no redaction ID was provided, then this is an unredact
57 @old_element.redact!(nil)
59 # if a redaction ID was specified, then set this element to
60 # be redacted in that redaction.
61 redaction = Redaction.find(redaction_id.to_i)
62 @old_element.redact!(redaction)
65 # just return an empty 200 OK for success
72 current_user&.moderator? && params[:show_redactions] == "true"