]> git.openstreetmap.org Git - rails.git/blob - app/controllers/api/changesets/closes_controller.rb
Merge remote-tracking branch 'upstream/pull/5972'
[rails.git] / app / controllers / api / changesets / closes_controller.rb
1 module Api
2   module Changesets
3     class ClosesController < ApiController
4       before_action :check_api_writable
5       before_action :authorize
6
7       authorize_resource :class => Changeset
8
9       before_action :require_public_data
10
11       # Helper methods for checking consistency
12       include ConsistencyValidations
13
14       ##
15       # marks a changeset as closed. this may be called multiple times
16       # on the same changeset, so is idempotent.
17       def update
18         changeset = Changeset.find(params[:changeset_id])
19         check_changeset_consistency(changeset, current_user)
20
21         # to close the changeset, we'll just set its closed_at time to
22         # now. this might not be enough if there are concurrency issues,
23         # but we'll have to wait and see.
24         changeset.set_closed_time_now
25
26         changeset.save!
27         head :ok
28       end
29     end
30   end
31 end