summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/chaos_importer.rb25
-rw-r--r--lib/tasks/development_init.rake31
2 files changed, 18 insertions, 38 deletions
diff --git a/lib/chaos_importer.rb b/lib/chaos_importer.rb
index f8e98f5..74e0bbe 100644
--- a/lib/chaos_importer.rb
+++ b/lib/chaos_importer.rb
@@ -73,7 +73,9 @@ class ChaosImporter
73 puts node.unique_name 73 puts node.unique_name
74 end 74 end
75 75
76 puts ">> Publishing Drafts"
76 Node.all.each {|node| node.publish_draft!} 77 Node.all.each {|node| node.publish_draft!}
78 puts ">> Finished"
77 end 79 end
78 80
79 def lang_from_path path 81 def lang_from_path path
@@ -90,20 +92,13 @@ class ChaosImporter
90 end 92 end
91 93
92 def find_or_create_author update 94 def find_or_create_author update
93 # login = update.xml.at("//author").content rescue "webmaster" 95 login = update.xml.at("//author").content rescue "webmaster"
94 # puts login 96
95 97 unless author = User.find_by_login(login.downcase)
96 # password = Digest::SHA1.hexdigest("#{Time.now+rand(100).days}") 98 author = User.find_by_login("webmaster")
97 # unless author = User.find_by_login(login) 99 end
98 # author = User.create!(
99 # :login => login,
100 # :email => "#{login}@example.com",
101 # :password => password,
102 # :password_confirmation => password
103 # )
104 # end
105 100
106 # author 101 author
107 end 102 end
108 103
109 def find_or_create_node update 104 def find_or_create_node update
@@ -136,10 +131,6 @@ class ChaosImporter
136 :body => extract_body(html) 131 :body => extract_body(html)
137 } 132 }
138 133
139 if draft.node.slug == "wahlcomputer-hessen"
140 puts "#{I18n.locale} >>> #{lang} >>> #{options[:title]}"
141 end
142
143 draft.update_attributes options 134 draft.update_attributes options
144 draft 135 draft
145 end 136 end
diff --git a/lib/tasks/development_init.rake b/lib/tasks/development_init.rake
index 789cdf6..00ef83a 100644
--- a/lib/tasks/development_init.rake
+++ b/lib/tasks/development_init.rake
@@ -3,7 +3,12 @@ require 'csv'
3namespace :cccms do 3namespace :cccms do
4 4
5 desc "Setup everythin" 5 desc "Setup everythin"
6 task :setup_environment => [:create_admin_user, :import_updates, :create_home_page] do |t| 6 task :setup_environment => [
7 :create_admin_user,
8 :import_authors,
9 :import_updates,
10 :create_home_page
11 ] do |t|
7 12
8 end 13 end
9 14
@@ -19,30 +24,14 @@ namespace :cccms do
19 24
20 desc "Import the authors" 25 desc "Import the authors"
21 task :import_authors => :environment do |t| 26 task :import_authors => :environment do |t|
22 I18n.locale = :en 27 importer = AuthorsImporter.new("#{RAILS_ROOT}/db/authors.csv")
23 @parsed_file = CSV::Reader.parse(File.open("#{RAILS_ROOT}/db/authors.csv")) 28 importer.import_authors
24
25 @parsed_file.each_with_index do |row, index|
26 next if row[0].nil?
27
28 unless author = User.find_by_login(row[0])
29 puts "#{row[0]} >> #{row[2]}"
30 author = User.create!(
31 :login => row[0],
32 #:realname => row[1],
33 :email => row[2],
34 :password => "foobartrallala",
35 :password_confirmation => "foobartrallala"
36 )
37 end
38
39 end
40 end 29 end
41 30
42 desc "Import the old XML Files" 31 desc "Import the old XML Files"
43 task :import_updates => :environment do |t| 32 task :import_updates => :environment do |t|
44 i = UpdateImporter.new("#{RAILS_ROOT}/db/updates") 33 i = ChaosImporter.new("#{RAILS_ROOT}/db/updates")
45 i.import_xml 34 i.import_updates
46 end 35 end
47 36
48 desc "Create Home Page" 37 desc "Create Home Page"