/[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 69 - (show annotations)
Sun Jun 11 14:23:37 2006 UTC (17 years, 11 months ago) by dpavlin
File size: 2457 byte(s)
refactored transports handling
1 use strict;
2 use warnings;
3
4 package Transports::Model::Transport::Schema;
5 use Jifty::DBI::Schema;
6
7 use Transports::Model::Source;
8 use Transports::Model::Destination;
9 use Transports::Model::User;
10 use Transports::Model::TransportClass;
11 use Transports::Model::ReturnCode;
12
13 # Your column definitions go here. See L<Jifty::DBI::Schema> for
14 # documentation about how to write column definitions.
15
16 column date =>
17 type is 'timestamp',
18 label is 'Date',
19 render_as 'unrendered',
20 since '0.0.1';
21
22 column class =>
23 refers_to Transports::Model::TransportClass,
24 label is 'Transport class',
25 is mandatory,
26 since '0.0.11';
27
28 column source =>
29 refers_to Transports::Model::Source,
30 label is 'Source client',
31 # render_as 'Combobox',
32 # sort_order is 'name',
33 # render_as 'select',
34 is mandatory,
35 since '0.0.6';
36
37 column destination =>
38 refers_to Transports::Model::Destination,
39 label is 'Destionation client',
40 is mandatory,
41 since '0.0.7';
42
43 column request_nr =>
44 type is 'text',
45 label is 'Change request nr',
46 is mandatory,
47 since '0.0.7';
48
49 column client_dependent =>
50 type is 'boolean',
51 label 'Client dependent',
52 is mandatory,
53 since '0.0.7',
54
55 column description =>
56 type is 'text',
57 label 'Description',
58 render_as 'textarea',
59 since '0.0.11';
60
61 column created_by =>
62 refers_to Transports::Model::User,
63 label is 'Request by',
64 since '0.0.7';
65
66 column return_code =>
67 refers_to Transports::Model::ReturnCode,
68 label is 'Return code',
69 since '0.0.12';
70
71 column comment =>
72 type is 'text',
73 label is 'Import comment',
74 render_as 'textarea',
75 since '0.0.12';
76
77 package Transports::Model::Transport;
78 use base qw/Transports::Record/;
79 use DateTime;
80
81 # Your model-specific methods go here.
82
83 =head2 create
84
85 Create new transport and fill-in C<date> and C<created_by>.
86
87 =cut
88
89 sub create {
90 my $self = shift;
91 my %args = (@_);
92
93 my $now = DateTime->now();
94 $args{'date'} = $now->ymd . " " . $now->hms;
95
96 if (! $args{created_by}) {
97 warn 'need $self->current_user' unless ($self->current_user);
98 $args{created_by} = $self->current_user->user_object;
99 }
100
101 my ($id) = $self->SUPER::create(%args);
102 return ($id);
103 }
104
105 =head2 current_user_can ACTION
106
107 Let everybody create, read and update, but not delete.
108
109 =cut
110
111 sub current_user_can {
112 my $self = shift;
113 my $type = shift;
114
115 # We probably want something like this eventually:
116 if ($type =~ /(?:create|read|update)/i) {
117 return 1;
118 } else {
119 return $self->SUPER::current_user_can($type, @_);
120 }
121 }
122
123
124 1;
125

  ViewVC Help
Powered by ViewVC 1.1.26