6 |
# redirect( '/new'); |
# redirect( '/new'); |
7 |
#}; |
#}; |
8 |
|
|
9 |
|
=head1 Transports operations |
10 |
|
|
11 |
|
=head2 /transports/create |
12 |
|
|
13 |
|
=cut |
14 |
|
|
15 |
|
on 'transports/create/new', run { |
16 |
|
|
17 |
|
my $landscape_id = get('landscape_id'); |
18 |
|
if (! $landscape_id) { |
19 |
|
|
20 |
|
my $landscapes = Transports::Model::UserOnLandscapeCollection->new(); |
21 |
|
$landscapes->limit( |
22 |
|
column => 'user_on', |
23 |
|
value => Jifty->web->current_user->id, |
24 |
|
quote_value => 0, |
25 |
|
); |
26 |
|
$landscapes->order_by({ column => 'landscape' }); |
27 |
|
|
28 |
|
if ($landscapes->count == 0) { |
29 |
|
show '/transports/create/no_landscape'; |
30 |
|
} elsif ($landscapes->count == 1) { |
31 |
|
$landscape_id = $landscapes->first->id; |
32 |
|
} else { |
33 |
|
set landscapes => $landscapes; |
34 |
|
show '/transports/create/landscape'; |
35 |
|
} |
36 |
|
} |
37 |
|
|
38 |
|
my $transport = Jifty->web->new_action( |
39 |
|
class => 'CreateTransport', |
40 |
|
monkier => 'create', |
41 |
|
); |
42 |
|
|
43 |
|
my $l = Transports::Model::Landscape->new(); |
44 |
|
$l->load_by_cols( id => $landscape_id ); |
45 |
|
|
46 |
|
warn "Can't find landscape with id $landscape_id" unless ($l->id); |
47 |
|
|
48 |
|
my $s = Transports::Model::SourceCollection->new(); |
49 |
|
$s->limit( |
50 |
|
column => 'landscape', |
51 |
|
value => $landscape_id, |
52 |
|
); |
53 |
|
$transport->arguments->{'source'}->{'valid_values'}->[0]->{'collection'} = $s; |
54 |
|
|
55 |
|
my $d = Transports::Model::DestinationCollection->new(); |
56 |
|
$d->limit( |
57 |
|
column => 'landscape', |
58 |
|
value => $landscape_id, |
59 |
|
); |
60 |
|
$transport->arguments->{'destination'}->{'valid_values'}->[0]->{'collection'} = $d; |
61 |
|
|
62 |
|
set 'landscape_id' => $landscape_id; |
63 |
|
set 'transport' => $transport; |
64 |
|
|
65 |
|
show '/transports/create/new'; |
66 |
|
} |
67 |
|
|
68 |
=head1 Login and logout operations |
=head1 Login and logout operations |
69 |
|
|
70 |
=head2 login |
=head2 login |
71 |
|
|
72 |
=cut |
=cut |
73 |
|
|
74 |
on qr'^/login', run { |
on '--login', run { |
75 |
|
|
76 |
set 'action' => |
set 'action' => |
77 |
Jifty->web->new_action( class => 'Login', moniker => 'loginbox' ); |
Jifty->web->new_action( class => 'Login', moniker => 'loginbox' ); |
97 |
# able to edit files in place. These should become a plugin of some |
# able to edit files in place. These should become a plugin of some |
98 |
# sort, when we have that infrastructure. |
# sort, when we have that infrastructure. |
99 |
|
|
100 |
before qr'^(.*)$', run { |
before '*' => run { |
101 |
my $url = $1 || '/'; |
my $url = Jifty->web->request->path; |
102 |
|
|
103 |
|
warn "hmmm.... url = $url\n"; |
104 |
|
|
105 |
|
return if ($url eq '/' || $url eq '/login' || $url =~ m#^/__jifty/#); |
106 |
|
|
107 |
Jifty->api->allow(qr/^Jifty::Action::Devel/) |
Jifty->api->allow(qr/^Jifty::Action::Devel/) |
108 |
if Jifty->config->framework('DevelMode'); |
if Jifty->config->framework('DevelMode'); |
109 |
|
|
|
return if ($url eq '/' || $url =~ m#^/login#); |
|
|
|
|
110 |
if (not Jifty->web->current_user->id) { |
if (not Jifty->web->current_user->id) { |
111 |
|
warn "send user accessing $url to login form\n"; |
112 |
Jifty->web->tangent( url => '/login' ); |
Jifty->web->tangent( url => '/login' ); |
113 |
} |
} |
114 |
}; |
}; |