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 |
|
|
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; |