]> git.openstreetmap.org Git - rails.git/commitdiff
rails way bits
authorSteve Coast <steve@asklater.com>
Mon, 27 Nov 2006 10:35:10 +0000 (10:35 +0000)
committerSteve Coast <steve@asklater.com>
Mon, 27 Nov 2006 10:35:10 +0000 (10:35 +0000)
app/controllers/old_way_controller.rb
app/controllers/old_way_segment_controller.rb [new file with mode: 0644]
app/controllers/old_way_tag_controller.rb [new file with mode: 0644]
app/controllers/way_controller.rb
app/helpers/old_way_segment_helper.rb [new file with mode: 0644]
app/helpers/old_way_tag_helper.rb [new file with mode: 0644]
app/models/old_way.rb

index 7fbed26ea4c5e1230af08f68ec0f96f33401b94c..9c3a257c47154de102a3651ee1cb1fdba3016159 100644 (file)
@@ -1,2 +1,4 @@
 class OldWayController < ApplicationController
+
+
 end
diff --git a/app/controllers/old_way_segment_controller.rb b/app/controllers/old_way_segment_controller.rb
new file mode 100644 (file)
index 0000000..4e9404c
--- /dev/null
@@ -0,0 +1,2 @@
+class OldWaySegmentController < ApplicationController
+end
diff --git a/app/controllers/old_way_tag_controller.rb b/app/controllers/old_way_tag_controller.rb
new file mode 100644 (file)
index 0000000..02c1e2e
--- /dev/null
@@ -0,0 +1,2 @@
+class OldWayTagController < ApplicationController
+end
index 49a3b3bfec3d7de50266e9dce7dbc29b1a67c40a..2fd4390e49162e7102965921c796f8ec7934b5fd 100644 (file)
@@ -10,8 +10,6 @@ class WayController < ApplicationController
       if way
         way.user_id = @user.id
         if way.save_with_history
-
-
           render :text => way.id
         else
           render :nothing => true, :status => 500
@@ -52,7 +50,5 @@ class WayController < ApplicationController
       way.save_with_history
 
     end
   end
-
 end
diff --git a/app/helpers/old_way_segment_helper.rb b/app/helpers/old_way_segment_helper.rb
new file mode 100644 (file)
index 0000000..8299bdd
--- /dev/null
@@ -0,0 +1,2 @@
+module OldWaySegmentHelper
+end
diff --git a/app/helpers/old_way_tag_helper.rb b/app/helpers/old_way_tag_helper.rb
new file mode 100644 (file)
index 0000000..c23661b
--- /dev/null
@@ -0,0 +1,2 @@
+module OldWayTagHelper
+end
index 3f978d3d407ad88ca44bcaf7d9586c61ddbd8db9..1aac4ebff8e7736117aa0b8d5e9c0911a1a5b13d 100644 (file)
@@ -8,7 +8,58 @@ class OldWay < ActiveRecord::Base
     old_way.user_id = way.user_id
     old_way.timestamp = way.timestamp
     old_way.id = way.id
+    old_way.segs = way.segs
+    old_way.tags = way.tags
     return old_way
   end
 
+  def save
+    t = Time.now
+    self.timestamp = t
+    self.save
+    
+    WayTag.delete_all(['id = ?', self.id])
+
+    self.tags.each do |k,v|
+      tag = WayTag.new
+      tag.k = k
+      tag.v = v
+      tag.id = self.id
+      tag.save
+    end
+
+    WaySegment.delete_all(['id = ?', self.id])
+    
+    i = 0
+    self.segs.each do |n|
+      seg = WaySegment.new
+      seg.id = self.id
+      seg.segment_id = n
+      seg.sequence_id = i
+      seg.save
+      i += 1
+    end
+
+    old_way = OldWay.from_way(self)
+    old_way.save
+  end
+
+  def segs
+    @segs = Array.new unless @segs
+    @segs
+  end
+
+  def tags
+    @tags = Hash.new unless @tags
+    @tags
+  end
+
+  def segs=(s)
+    @segs = s
+  end
+
+  def tags=(t)
+    @tags = t
+  end
+
 end