/[transports]/trunk/lib/Transports/Bootstrap.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Transports/Bootstrap.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 9 by dpavlin, Fri May 5 19:44:15 2006 UTC revision 28 by dpavlin, Fri May 26 22:28:07 2006 UTC
# Line 4  use strict; Line 4  use strict;
4  package Transports::Bootstrap;  package Transports::Bootstrap;
5  use base qw(Jifty::Bootstrap);  use base qw(Jifty::Bootstrap);
6    
7    =head1 Bootstrap application data
8    
9    Create initial data
10    
11    =cut
12    
13  sub run {  sub run {
14      my $self = shift;      my $self = shift;
15    
16          my $system_user = Transports::CurrentUser->superuser;          my $system_user = Transports::CurrentUser->superuser( _bootstrap => 1 );
17          # Try testing a create  
18          my $o = Transports::Model::User->new(current_user => $system_user);          my $u1 = Transports::Model::User->new(current_user => $system_user);
19          my ($id) = $o->create(          $u1->create(
20                  name => 'System administrator',                  name => 'System administrator',
21                  email => 'admin',                  email => 'admin@example.com',
22                  password => 'admin',                  password => 'admin',
23                    admin => 1,
24          );          );
25          # And another  
26          $o->create(          my $u2 = Transports::Model::User->new(current_user => $system_user);
27                  name => 'Foo Bar',          $u2->create(
28                  email => 'foo.bar@example.com',                  name => 'Normal User',
29                  password => 'baz123',                  email => 'user@example.com',
30                    password => 'user',
31          );          );
32    
33            my $s;
34    
35            foreach my $i ( 0 ... 5 ) {
36                    $s->{$i} = Transports::Model::Source->new(current_user => $system_user);
37                    $s->{$i}->create(
38                            name => 'SRC/' . ($i + 1),
39                    );
40    
41                    Transports::Model::UserOnSource->new(current_user => $system_user)->create(
42                            user_on => $u1,
43                            source => $s->{$i},
44                    );
45    
46                    Transports::Model::UserOnSource->new(current_user => $system_user)->create(
47                            user_on => $u2,
48                            source => $s->{$i},
49                    ) if ($i % 2 == 0);
50            }
51    
52            my $d;
53    
54            foreach my $i ( 0 ... 2 ) {
55                    $d->{$i} = Transports::Model::Destination->new(current_user => $system_user);
56                    $d->{$i}->create(
57                            name => 'DEST/' . ($i + 1),
58                    );
59            }
60    
61            foreach my $i ( 1 ... 7 ) {
62                    my $t = Transports::Model::Transport->new(current_user => $system_user);
63                    $t->create(
64                            source => $s->{ $i % 5 },
65                            destination => $d->{ $i % 2 },
66                            request_nr => $i,
67                            client_dependent => $i % 3 == 0 ? 0 : 1,
68                            created_by => $i % 2 == 0 ? $u1 : $u2,
69                    );
70            }
71    
72  }  }
73    
74    

Legend:
Removed from v.9  
changed lines
  Added in v.28

  ViewVC Help
Powered by ViewVC 1.1.26