/[transports]/trunk/lib/Transports/Dispatcher.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/Dispatcher.pm

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

revision 87 by dpavlin, Fri Jun 16 18:20:02 2006 UTC revision 88 by dpavlin, Mon Jun 19 15:15:54 2006 UTC
# Line 8  use Jifty::Dispatcher -base; Line 8  use Jifty::Dispatcher -base;
8    
9  =head1 Transports operations  =head1 Transports operations
10    
11  =head2 /transports/create/new  =head2 /transports/create/
12    
13    Select transport (if only one exists, it will be picked automatically) and
14    create new stransport
15    
16  =cut  =cut
17    
18  on '/transports/create/new' => run {  under '/transports/create/' => [
19    
20            on '' => redirect('/transports/create/landscape'),
21            on 'landscape' => run {
22    
23          my $landscape_id = get('landscape_id');                          my $landscapes = Transports::Model::UserOnLandscapeCollection->new();
24          if (! $landscape_id) {                          $landscapes->limit(
25                                            column          => 'user_on',
26                  my $landscapes = Transports::Model::UserOnLandscapeCollection->new();                                  value           => Jifty->web->current_user->id,
27                  $landscapes->limit(                                  quote_value     => 0,
28                          column          => 'user_on',                          );
29                          value           => Jifty->web->current_user->id,                          $landscapes->order_by( column => 'landscape' );
30                          quote_value     => 0,  
31                            if ($landscapes->count == 0) {
32                                    show '/transports/create/no_landscape';
33                            } elsif ($landscapes->count == 1) {
34                                    $landscape_id = $landscapes->first->id;
35                                    set 'landscape_id' => $landscape_id;
36                                    dispatch('/transports/create/new');
37                            } else {
38                                    set landscapes => $landscapes;
39                                    show '/transports/create/landscape';
40                            };
41    
42            },
43            on 'new' => run {
44    
45                    my $landscape_id = get('landscape_id');
46                    Jifty->web->tangent('/transports/create/landscape') unless ($landscape_id);
47    
48                    my $transport = get('transport') || Jifty->web->new_action(
49                            class => 'CreateTransport',
50                            monkier => 'create',
51                  );                  );
                 $landscapes->order_by( column => 'landscape' );  
52    
53                  if ($landscapes->count == 0) {                  my $l = Transports::Model::Landscape->new();
54                          show '/transports/create/no_landscape';                  $l->load_by_cols( id => $landscape_id );
55                  } elsif ($landscapes->count == 1) {  
56                          $landscape_id = $landscapes->first->id;                  if (! $l->id) {
57                  } else {                          warn "Can't find landscape with id $landscape_id\n";
58                          set landscapes => $landscapes;                          redirect('/transports/create/landscape');
                         show '/transports/create/landscape';  
59                  }                  }
         }  
60    
61          my $transport = Jifty->web->new_action(                  my $s = Transports::Model::SourceCollection->new();
62                  class => 'CreateTransport',                  $s->limit(
63                  monkier => 'create',                          column => 'landscape',
64          );                          value => $landscape_id,
65                    );
66          my $l = Transports::Model::Landscape->new();  #               $transport->arguments->{'source'}->{'valid_values'}->[0]->{'collection'} = $s;
         $l->load_by_cols( id => $landscape_id );  
   
         warn "Can't find landscape with id $landscape_id" unless ($l->id);  
   
         my $s = Transports::Model::SourceCollection->new();  
         $s->limit(  
                 column => 'landscape',  
                 value => $landscape_id,  
         );  
         $transport->arguments->{'source'}->{'valid_values'}->[0]->{'collection'} = $s;  
   
         my $d = Transports::Model::DestinationCollection->new();  
         $d->limit(  
                 column => 'landscape',  
                 value => $landscape_id,  
         );  
         $transport->arguments->{'destination'}->{'valid_values'}->[0]->{'collection'} = $d;  
67    
68          set 'landscape_id' => $landscape_id;                  my $d = Transports::Model::DestinationCollection->new();
69          set 'transport' => $transport;                  $d->limit(
70                            column => 'landscape',
71                            value => $landscape_id,
72                    );
73    #               $transport->arguments->{'destination'}->{'valid_values'}->[0]->{'collection'} = $d;
74    
75          show '/transports/create/new';                  set 'transport' => $transport;
76  };  
77                    show '/transports/create/new';
78            },
79    ];
80    
81    =head1 User operations
82    
83    =cut
84    
85    under '/users' => [
86            on '' => run {
87                    dispatch '/users/form' if ( get 'user_id' );
88            },
89    ];
90    
91  =head1 Login and logout operations  =head1 Login and logout operations
92    
# Line 116  on qr'^/__jifty/edit/(.*?)/(.*)$', run { Line 139  on qr'^/__jifty/edit/(.*?)/(.*)$', run {
139      show '/__jifty/edit_file';      show '/__jifty/edit_file';
140  };  };
141    
 use Data::Dumper;  
 foreach my $s ( qw/SETUP RUN CLEANUP/ ) {  
         Jifty->log->debug("$s rules:\n", join("\n",  
                 map { my ($on,$what) = @$_ ; "\t$on $what" } @{ 'RULES_' . $s } )  
         );  
 }  
   
142  1;  1;

Legend:
Removed from v.87  
changed lines
  Added in v.88

  ViewVC Help
Powered by ViewVC 1.1.26