Add base old element redactions controller
This commit is contained in:
parent
d91a7cbf97
commit
84c4ed3fa8
2 changed files with 32 additions and 0 deletions
|
@ -45,6 +45,7 @@ class ApiAbility
|
|||
can :destroy, Note if scopes.include?("write_notes")
|
||||
|
||||
can :redact, [OldNode, OldWay, OldRelation] if user.terms_agreed? && scopes.include?("write_redactions")
|
||||
can [:create, :destroy], :element_version_redaction if user.terms_agreed? && scopes.include?("write_redactions")
|
||||
|
||||
can :create, UserBlock if scopes.include?("write_blocks")
|
||||
end
|
||||
|
|
31
app/controllers/api/old_elements/redactions_controller.rb
Normal file
31
app/controllers/api/old_elements/redactions_controller.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
module Api
|
||||
module OldElements
|
||||
class RedactionsController < ApiController
|
||||
before_action :check_api_writable
|
||||
before_action :authorize
|
||||
|
||||
authorize_resource :class => :element_version_redaction
|
||||
|
||||
before_action :lookup_old_element
|
||||
|
||||
def create
|
||||
redaction_id = params["redaction"]
|
||||
if redaction_id
|
||||
redaction = Redaction.find(redaction_id.to_i)
|
||||
@old_element.redact!(redaction)
|
||||
head :ok
|
||||
elsif params["allow_delete"]
|
||||
# legacy unredact if no redaction ID was provided for /api/0.6/:element_type/:id/:version/redact paths mapped here
|
||||
destroy
|
||||
else
|
||||
raise OSM::APIBadUserInput, "No redaction was given" unless redaction_id
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@old_element.redact!(nil)
|
||||
head :ok
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue