/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.26