X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/bed9cd00ed166ce346da4b8a9b654ddf86e64e70..5449cf4adcc1fad4b9f43426e6d3e4a8f65e6fbb:/app/controllers/amf_controller.rb diff --git a/app/controllers/amf_controller.rb b/app/controllers/amf_controller.rb index 331487a93..de3c7583b 100644 --- a/app/controllers/amf_controller.rb +++ b/app/controllers/amf_controller.rb @@ -41,7 +41,7 @@ class AmfController < ApplicationController include MapBoundary session :off - before_filter :check_write_availability + before_filter :check_api_writable # Main AMF handlers: process the raw AMF string (using AMF library) and # calls each action (private method) accordingly. @@ -157,7 +157,7 @@ class AmfController < ApplicationController cs.tags = cstags cs.user_id = user.id # smsm1 doesn't like the next two lines and thinks they need to be abstracted to the model more/better - cs.created_at = Time.now + cs.created_at = Time.now.getutc cs.closed_at = cs.created_at + Changeset::IDLE_TIMEOUT cs.save_with_tags! return [0,cs.id] @@ -298,12 +298,19 @@ class AmfController < ApplicationController old_way = OldWay.find(:first, :conditions => ['visible = ? AND id = ?', true, id], :order => 'version DESC') points = old_way.get_nodes_undelete unless old_way.nil? else - # revert - timestamp = DateTime.strptime(timestamp, "%d %b %Y, %H:%M:%S") - old_way = OldWay.find(:first, :conditions => ['id = ? AND timestamp <= ?', id, timestamp], :order => 'timestamp DESC') - points = old_way.get_nodes_revert(timestamp) unless old_way.nil? - if !old_way.visible - return [-1, "Sorry, the way was deleted at that time - please revert to a previous version."] + begin + # revert + timestamp = DateTime.strptime(timestamp.to_s, "%d %b %Y, %H:%M:%S") + old_way = OldWay.find(:first, :conditions => ['id = ? AND timestamp <= ?', id, timestamp], :order => 'timestamp DESC') + unless old_way.nil? + points = old_way.get_nodes_revert(timestamp) + if !old_way.visible + return [-1, "Sorry, the way was deleted at that time - please revert to a previous version."] + end + end + rescue ArgumentError + # thrown by date parsing method. leave old_way as nil for + # the superb error handler below. end end @@ -483,8 +490,8 @@ class AmfController < ApplicationController new_relation.changeset_id = changeset_id new_relation.version = version - - if id <= 0 + # NOTE: id or relid here? id doesn't seem to be set above + if relid <= 0 # We're creating the node new_relation.create_with_history(user) elsif visible