summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhukl <contact@smyck.org>2009-02-22 16:03:09 +0100
committerhukl <contact@smyck.org>2009-02-22 16:03:09 +0100
commit955524ef5e5165a71c67b66abaad2c9e2797efd6 (patch)
tree1a4573aa9c1e87d8a788f79ac49d8986d0465f77
parentcea7054a33cf589a275e5cb9143d998782cbbdcf (diff)
cloning tags from heads to new drafts. splitted the find_or_create_draft method to make it easier to read.
fixed a bug in the importer which caused tag loss
-rw-r--r--app/models/node.rb33
-rw-r--r--lib/update_importer.rb3
2 files changed, 21 insertions, 15 deletions
diff --git a/app/models/node.rb b/app/models/node.rb
index 2820f30..b04aeba 100644
--- a/app/models/node.rb
+++ b/app/models/node.rb
@@ -60,22 +60,27 @@ class Node < ActiveRecord::Base
60 elsif draft && draft.user != user 60 elsif draft && draft.user != user
61 raise "Page is locked" 61 raise "Page is locked"
62 else 62 else
63 # TODO clone tags later on 63 create_new_draft user
64 p = self.pages.create! 64 end
65 65 end
66 I18n.available_locales.each do |l| 66
67 next if l == :root 67 def create_new_draft user
68 I18n.locale = l 68 p = self.pages.create!
69 69
70 p.title = self.head.title 70 p.tag_list = self.head.tag_list.join(", ")
71 p.abstract = self.head.abstract 71
72 p.body = self.head.body 72 I18n.available_locales.each do |l|
73 end 73 next if l == :root
74 I18n.locale = l
74 75
75 p.user = user 76 p.title = self.head.title
76 p.save 77 p.abstract = self.head.abstract
77 p 78 p.body = self.head.body
78 end 79 end
80
81 p.user = user
82 p.save
83 p
79 end 84 end
80 85
81 def publish_draft! 86 def publish_draft!
diff --git a/lib/update_importer.rb b/lib/update_importer.rb
index 49614b4..0cc07fe 100644
--- a/lib/update_importer.rb
+++ b/lib/update_importer.rb
@@ -114,9 +114,10 @@ class UpdateImporter
114 if (flags = xhtml.elements['flags']) && page 114 if (flags = xhtml.elements['flags']) && page
115 page.tag_list.add("event") if flags.attributes['calendar'] 115 page.tag_list.add("event") if flags.attributes['calendar']
116 page.tag_list.add("pressemitteilung") if flags.attributes['pm'] 116 page.tag_list.add("pressemitteilung") if flags.attributes['pm']
117 page.save!
118 end 117 end
119 118
119 page.save!
120
120 if node.head.nil? && page 121 if node.head.nil? && page
121 node.head = page 122 node.head = page
122 node.save! 123 node.save!