Added seeds.rb for an easy start.
This commit is contained in:
parent
50a45cfa7d
commit
1e49a44a92
2 changed files with 27 additions and 23 deletions
27
db/seeds.rb
Normal file
27
db/seeds.rb
Normal file
|
@ -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..")
|
|
@ -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]
|
||||
|
|
Loading…
Reference in a new issue