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

Contents of /trunk/lib/Transports/Model/Transport.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 27 - (show annotations)
Fri May 26 21:21:25 2006 UTC (17 years, 11 months ago) by dpavlin
File size: 1947 byte(s)
added admin column to users, better bootstrap data
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 render_as 'unrendered',
14 since '0.0.1';
15
16 column source =>
17 refers_to Transports::Model::Source,
18 label is 'Source client',
19 # render_as 'Combobox',
20 # sort_order is 'name',
21 # render_as 'select',
22 is mandatory,
23 since '0.0.6';
24
25 column destination =>
26 refers_to Transports::Model::Destination,
27 label is 'Destionation client',
28 is mandatory,
29 since '0.0.7';
30
31 column request_nr =>
32 type is 'text',
33 label is 'Change request nr',
34 is mandatory,
35 since '0.0.7';
36
37 column client_dependent =>
38 type is 'boolean',
39 label 'Client dependent',
40 is mandatory,
41 since '0.0.7',
42
43 column created_by =>
44 refers_to Transports::Model::User,
45 label is 'Request by',
46 since '0.0.7';
47
48
49 package Transports::Model::Transport;
50 use base qw/Transports::Record/;
51 use Transports::Model::Source;
52 use Transports::Model::Destination;
53 use Transports::Model::User;
54 use DateTime;
55
56 # Your model-specific methods go here.
57
58 =head2 create
59
60 Create new transport and fill-in C<date> and C<created_by>.
61
62 =cut
63
64 sub create {
65 my $self = shift;
66 my %args = (@_);
67
68 my $now = DateTime->now();
69 $args{'date'} = $now->ymd . " " . $now->hms;
70
71 if (! $args{created_by}) {
72 warn 'need $self->current_user' unless ($self->current_user);
73 $args{created_by} = $self->current_user->user_object;
74 }
75
76 my ($id) = $self->SUPER::create(%args);
77 return ($id);
78 }
79
80 =head2 current_user_can ACTION
81
82 Let everybody create, read and update, but not delete.
83
84 =cut
85
86 sub current_user_can {
87 my $self = shift;
88 my $type = shift;
89
90 # We probably want something like this eventually:
91 if ($type =~ /(?:create|read|update)/i) {
92 return 1;
93 } else {
94 return $self->SUPER::current_user_can($type, @_);
95 }
96 }
97
98
99 1;
100

  ViewVC Help
Powered by ViewVC 1.1.26