diff options
| author | hukl <contact@smyck.org> | 2009-02-21 17:36:09 +0100 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-02-21 17:36:09 +0100 |
| commit | 41448123069858d754931d136d90ea2665d8a8be (patch) | |
| tree | 7eddf0f51aa4120bc2b5757bc712f9489523e3f1 /lib/tasks | |
| parent | 55800bf0565f392a48b6d3a673da60525aad423b (diff) | |
added importer for authors and adding proper authors
to imported pages
Diffstat (limited to 'lib/tasks')
| -rw-r--r-- | lib/tasks/development_init.rake | 24 |
1 files changed, 24 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 @@ | |||
| 1 | require 'csv' | ||
| 2 | |||
| 1 | namespace :cccms do | 3 | namespace :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") |
