1 |
use strict; |
2 |
use warnings; |
3 |
|
4 |
package Transports::Model::Landscape::Schema; |
5 |
use Jifty::DBI::Schema; |
6 |
|
7 |
use Transports::Model::SourceCollection; |
8 |
use Transports::Model::DestinationCollection; |
9 |
|
10 |
# Your column definitions go here. See L<Jifty::DBI::Schema> for |
11 |
# documentation about how to write column definitions. |
12 |
|
13 |
column name => |
14 |
type is 'text', |
15 |
label is 'Landscape', |
16 |
is mandatory, |
17 |
is distinct; |
18 |
|
19 |
column sources => |
20 |
refers_to Transports::Model::SourceCollection by 'landscape', |
21 |
since '0.0.14'; |
22 |
|
23 |
column destinations => |
24 |
refers_to Transports::Model::DestinationCollection by 'landscape', |
25 |
since '0.0.14'; |
26 |
|
27 |
package Transports::Model::Landscape; |
28 |
use base qw/Transports::Record/; |
29 |
|
30 |
# Your model-specific methods go here. |
31 |
|
32 |
=head2 current_user_can |
33 |
|
34 |
everybody can read landscapes while only admins can update it |
35 |
|
36 |
=cut |
37 |
|
38 |
sub current_user_can { |
39 |
my $self = shift; |
40 |
my $right = shift; |
41 |
my %args = (@_); |
42 |
|
43 |
return 1 if ($right eq 'read' or $self->current_user->admin ); |
44 |
|
45 |
return $self->SUPER::current_user_can( $right, %args ); |
46 |
} |
47 |
|
48 |
1; |
49 |
|