1 |
use strict; |
2 |
use warnings; |
3 |
|
4 |
package Transports::Model::Transport::Schema; |
5 |
use Jifty::DBI::Schema; |
6 |
|
7 |
# Your column definitions go here. See L<Jifty::DBI::Schema> for |
8 |
# documentation about how to write column definitions. |
9 |
|
10 |
column date => |
11 |
type is 'timestamp', |
12 |
label is 'Date', |
13 |
is immutable, |
14 |
render_as 'unrendered', |
15 |
default is 'now()', |
16 |
since '0.0.1'; |
17 |
|
18 |
column source => |
19 |
refers_to Transports::Model::Source, |
20 |
label is 'Source client', |
21 |
# render_as 'Combobox', |
22 |
# sort_order is 'name', |
23 |
# render_as 'select', |
24 |
is mandatory, |
25 |
since '0.0.6'; |
26 |
|
27 |
column destination => |
28 |
refers_to Transports::Model::Destination, |
29 |
label is 'Destionation client', |
30 |
is mandatory, |
31 |
since '0.0.7'; |
32 |
|
33 |
column request_nr => |
34 |
type is 'text', |
35 |
label is 'Change request nr', |
36 |
is mandatory, |
37 |
since '0.0.7'; |
38 |
|
39 |
column client_dependent => |
40 |
type is 'boolean', |
41 |
label 'Client dependent', |
42 |
is mandatory, |
43 |
since '0.0.7', |
44 |
|
45 |
column created_by => |
46 |
refers_to Transports::Model::User, |
47 |
label is 'Request by', |
48 |
since '0.0.7'; |
49 |
|
50 |
|
51 |
package Transports::Model::Transport; |
52 |
use base qw/Transports::Record/; |
53 |
use Transports::Model::Source; |
54 |
use Transports::Model::Destination; |
55 |
use Transports::Model::User; |
56 |
|
57 |
# Your model-specific methods go here. |
58 |
|
59 |
=head2 create |
60 |
|
61 |
Create new transport and fill in C<created_by>. |
62 |
|
63 |
=cut |
64 |
|
65 |
sub x_create { |
66 |
my $self = shift; |
67 |
my %args = (@_); |
68 |
# my $now = DateTime->now(); |
69 |
# $args{'updated'} = $now->ymd . " " . $now->hms; |
70 |
$args{'created_by'} = ( $self->current_user ? $self->current_user->user_object : undef ); |
71 |
my ($id) = $self->SUPER::create(%args); |
72 |
return ($id); |
73 |
} |
74 |
|
75 |
|
76 |
1; |
77 |
|