From: Christopher Schmidt Date: Sun, 11 May 2008 21:18:42 +0000 (+0000) Subject: add support for closing changesets X-Git-Tag: live~7601^2~354 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/6f1aad0d0431703cd834e2b29becf20fcbac4dab add support for closing changesets --- diff --git a/app/controllers/changeset_controller.rb b/app/controllers/changeset_controller.rb index 3e88eeec3..9994a6b1e 100644 --- a/app/controllers/changeset_controller.rb +++ b/app/controllers/changeset_controller.rb @@ -54,6 +54,21 @@ class ChangesetController < ApplicationController render :nothing => true, :status => :not_found end end + + def close + begin + if not request.put? + render :nothing => true, :status => :method_not_allowed + return + end + changeset = Changeset.find(params[:id]) + changeset.open = false + changeset.save + render :nothing => true + rescue ActiveRecord::RecordNotFound + render :nothing => true, :status => :not_found + end + end def upload if not request.put? diff --git a/config/routes.rb b/config/routes.rb index 9196fae1b..581310068 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,6 +3,7 @@ ActionController::Routing::Routes.draw do |map| # API map.connect "api/#{API_VERSION}/changeset/create", :controller => 'changeset', :action => 'create' map.connect "api/#{API_VERSION}/changeset/:id", :controller => 'changeset', :action => 'read' + map.connect "api/#{API_VERSION}/changeset/:id/close", :controller => 'changeset', :action => 'close' map.connect "api/#{API_VERSION}/changeset/upload", :controller => 'changeset', :action => 'upload' map.connect "api/#{API_VERSION}/node/create", :controller => 'node', :action => 'create'