Commit 4dbbc3e2edc3985c685e0510aa2c906b96900977

Authored by Joenio Costa
1 parent 379446e2

Script to create some sample articles

script/sample-articles 0 → 100755
... ... @@ -0,0 +1,37 @@
  1 +#!/usr/bin/env ruby
  2 +require File.dirname(__FILE__) + '/../config/environment'
  3 +
  4 +# tourn on autoflush
  5 +STDOUT.sync = true
  6 +
  7 +profiles = Profile.all
  8 +SUBJECTS = ['got a new car', 'release a new version of project X', "doesn't like wales no more", "doesn't use free-software no more"]
  9 +TAGS = ['free-software', 'noosfero', 'development', 'rails', 'ruby']
  10 +
  11 +print "Creating some TinyMce articles: "
  12 +for subject in SUBJECTS
  13 + rand(20).times do |i|
  14 + profile = profiles.rand
  15 + profile.articles << TinyMceArticle.new(
  16 + :name => "%s #{subject}" % profile.name,
  17 + :body => "%s #{subject}" % profile.name,
  18 + :tag_list => [TAGS.rand, TAGS.rand]
  19 + )
  20 + print '.'
  21 + end
  22 +end
  23 +puts ' done!'
  24 +
  25 +print "Creating some galleries: "
  26 +for subject in SUBJECTS
  27 + rand(20).times do |i|
  28 + profile = profiles.rand
  29 + profile.articles << Gallery.new(
  30 + :name => "Gallery %s #{subject}" % profile.name,
  31 + :body => "Gallery %s #{subject}" % profile.name,
  32 + :tag_list => [TAGS.rand, TAGS.rand]
  33 + )
  34 + print '.'
  35 + end
  36 +end
  37 +puts ' done!'
... ...
script/sample-data
... ... @@ -16,3 +16,4 @@ system(&#39;./script/sample-profiles&#39;)
16 16 system('./script/sample-categories')
17 17 system('./script/sample-enterprises')
18 18 system('./script/sample-products')
  19 +system('./script/sample-articles')
... ...
script/sample-profiles
... ... @@ -112,3 +112,11 @@ ze = User.create!({
112 112 }).person
113 113 environment.add_admin(ze)
114 114  
  115 +admin = User.create!({
  116 + :login => "adminuser",
  117 + :email => 'adminuser@localhost.localdomain',
  118 + :password => 'admin',
  119 + :password_confirmation => 'admin',
  120 + :environment => environment,
  121 +}).person
  122 +environment.add_admin(admin)
... ...