From 1e49a44a92d32164a4204d21f85ff6908ee217cb Mon Sep 17 00:00:00 2001 From: benni Date: Fri, 6 May 2011 20:23:33 +0200 Subject: [PATCH] Added seeds.rb for an easy start. --- db/seeds.rb | 27 +++++++++++++++++++++++++++ lib/tasks/foodsoft.rake | 23 ----------------------- 2 files changed, 27 insertions(+), 23 deletions(-) create mode 100644 db/seeds.rb diff --git a/db/seeds.rb b/db/seeds.rb new file mode 100644 index 00000000..61252c54 --- /dev/null +++ b/db/seeds.rb @@ -0,0 +1,27 @@ +# Create nessecary data to start with a fresh installation + +# Create working group with full rights +administrators = Workgroup.create( + :name => "Administrators", + :description => "System administrators.", + :role_admin => true, + :role_finance => true, + :role_article_meta => true, + :role_suppliers => true, + :role_orders => true +) + +# Create admin user +admin = User.create( + :nick => "admin", + :first_name => "Anton", + :last_name => "Administrator", + :email => "admin@foo.test", + :password => "secret" +) + +# Admin joins the admin group +Membership.create(:group => administrators, :user => admin) + +# First entry for article categories +ArticleCategory.create(:name => "Other", :description => "The other stuff fits here..") \ No newline at end of file diff --git a/lib/tasks/foodsoft.rake b/lib/tasks/foodsoft.rake index d2a79847..1df5e4cd 100644 --- a/lib/tasks/foodsoft.rake +++ b/lib/tasks/foodsoft.rake @@ -2,29 +2,6 @@ # => :environment loads the environment an gives easy access to the application namespace :foodsoft do - - # "rake foodsoft:create_admin" - desc "creates Administrators-group and admin-user" - task :create_admin => :environment do - puts "Create Workgroup 'Administators'" - administrators = Workgroup.create( - :name => "Administrators", - :description => "System administrators.", - :role_admin => true, - :role_finance => true, - :role_article_meta => true, - :role_suppliers => true, - :role_orders => true - ) - - puts "Create User 'admin' with password 'secret'" - admin = User.create(:nick => "admin", :first_name => "Anton", :last_name => "Administrator", - :email => "admin@foo.test", :password => "secret") - - puts "Joining 'admin' user to 'Administrators' group" - Membership.create(:group => administrators, :user => admin) - end - desc "Notify users of upcoming tasks" task :notify_upcoming_tasks => :environment do tasks = Task.find :all, :conditions => ["done = ? AND due_date = ?", false, 1.day.from_now.to_date]