summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorhukl <contact@smyck.org>2009-02-21 17:36:09 +0100
committerhukl <contact@smyck.org>2009-02-21 17:36:09 +0100
commit41448123069858d754931d136d90ea2665d8a8be (patch)
tree7eddf0f51aa4120bc2b5757bc712f9489523e3f1 /lib
parent55800bf0565f392a48b6d3a673da60525aad423b (diff)
added importer for authors and adding proper authors
to imported pages
Diffstat (limited to 'lib')
-rw-r--r--lib/tasks/development_init.rake24
-rw-r--r--lib/update_importer.rb5
2 files changed, 29 insertions, 0 deletions
diff --git a/lib/tasks/development_init.rake b/lib/tasks/development_init.rake
index 7c732d2..886474b 100644
--- a/lib/tasks/development_init.rake
+++ b/lib/tasks/development_init.rake
@@ -1,3 +1,5 @@
1require 'csv'
2
1namespace :cccms do 3namespace :cccms do
2 4
3 desc "Create admin:foobar user:password" 5 desc "Create admin:foobar user:password"
@@ -10,6 +12,28 @@ namespace :cccms do
10 ) 12 )
11 end 13 end
12 14
15 desc "Import the authors"
16 task :import_authors => :environment do |t|
17 I18n.locale = :en
18 @parsed_file = CSV::Reader.parse(File.open("#{RAILS_ROOT}/db/authors.csv"))
19
20 @parsed_file.each_with_index do |row, index|
21 next if row[0].nil?
22
23 unless author = User.find_by_login(row[0])
24 puts "#{row[0]} >> #{row[2]}"
25 author = User.create!(
26 :login => row[0],
27 #:realname => row[1],
28 :email => row[2],
29 :password => "foobartrallala",
30 :password_confirmation => "foobartrallala"
31 )
32 end
33
34 end
35 end
36
13 desc "Import the old XML Files" 37 desc "Import the old XML Files"
14 task :import_updates => :environment do |t| 38 task :import_updates => :environment do |t|
15 i = UpdateImporter.new("#{RAILS_ROOT}/db/updates") 39 i = UpdateImporter.new("#{RAILS_ROOT}/db/updates")
diff --git a/lib/update_importer.rb b/lib/update_importer.rb
index 1fcf40e..49614b4 100644
--- a/lib/update_importer.rb
+++ b/lib/update_importer.rb
@@ -99,6 +99,11 @@ class UpdateImporter
99 99
100 end 100 end
101 101
102 if xhtml.elements['author']
103 user = User.find_by_login(xhtml.elements['author'].get_text.to_s)
104 page.user = user
105 end
106
102 page.published_at = date.to_time 107 page.published_at = date.to_time
103 page.save! 108 page.save!
104 109