various relations fixes
This commit is contained in:
parent
ab7f4cd88e
commit
112950ca3a
3 changed files with 19 additions and 1 deletions
|
@ -589,6 +589,21 @@ class AmfController < ApplicationController
|
||||||
uid=getuserid(usertoken)
|
uid=getuserid(usertoken)
|
||||||
if !uid then return -1,"You are not logged in, so the way could not be deleted." end
|
if !uid then return -1,"You are not logged in, so the way could not be deleted." end
|
||||||
|
|
||||||
|
# FIXME
|
||||||
|
# the next bit removes the way from any relations
|
||||||
|
# the delete_with_relations_and_nodes_and_history method should do this,
|
||||||
|
# but at present it just throws a 'precondition failed'
|
||||||
|
way=way.to_i
|
||||||
|
db_now='@now'+(rand*100).to_i.to_s+uid.to_s+id.to_i.abs.to_s+Time.new.to_i.to_s
|
||||||
|
db_uqn='unin'+(rand*100).to_i.to_s+uid.to_s+way.to_i.abs.to_s+Time.new.to_i.to_s
|
||||||
|
ActiveRecord::Base.connection.execute("SET #{db_now}=NOW()")
|
||||||
|
createuniquenodes(way,db_uqn,[])
|
||||||
|
deleteuniquenoderelations(db_uqn,uid,db_now)
|
||||||
|
deleteitemrelations(way_id,'way',uid,db_now)
|
||||||
|
ActiveRecord::Base.connection.execute("DROP TEMPORARY TABLE #{db_uqn}")
|
||||||
|
# end of FIXME
|
||||||
|
|
||||||
|
# now delete the way
|
||||||
user = User.find(uid)
|
user = User.find(uid)
|
||||||
way = Way.find(way_id)
|
way = Way.find(way_id)
|
||||||
way.delete_with_relations_and_nodes_and_history(user)
|
way.delete_with_relations_and_nodes_and_history(user)
|
||||||
|
|
|
@ -210,10 +210,13 @@ class Way < ActiveRecord::Base
|
||||||
# Delete the way and it's relations, but don't really delete it - set its visibility to false and update the history etc to maintain wiki-like functionality.
|
# Delete the way and it's relations, but don't really delete it - set its visibility to false and update the history etc to maintain wiki-like functionality.
|
||||||
def delete_with_relations_and_history(user)
|
def delete_with_relations_and_history(user)
|
||||||
if self.visible
|
if self.visible
|
||||||
# omg FIXME
|
# FIXME
|
||||||
|
# this should actually delete the relations,
|
||||||
|
# not just throw a PreconditionFailed if it's a member of a relation!!
|
||||||
if RelationMember.find(:first, :joins => "INNER JOIN current_relations ON current_relations.id=current_relation_members.id",
|
if RelationMember.find(:first, :joins => "INNER JOIN current_relations ON current_relations.id=current_relation_members.id",
|
||||||
:conditions => [ "visible = 1 AND member_type='way' and member_id=?", self.id])
|
:conditions => [ "visible = 1 AND member_type='way' and member_id=?", self.id])
|
||||||
raise OSM::APIPreconditionFailedError
|
raise OSM::APIPreconditionFailedError
|
||||||
|
# end FIXME
|
||||||
else
|
else
|
||||||
self.user_id = user.id
|
self.user_id = user.id
|
||||||
self.tags = []
|
self.tags = []
|
||||||
|
|
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue