/[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 25 - (show annotations)
Fri May 26 19:15:32 2006 UTC (18 years ago) by dpavlin
File size: 1941 byte(s)
refactor methods (much shorter), make default page with a Pony, automaticly fill user which
generated transport, added missing nav and sidebar
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 create {
66 my $self = shift;
67 my %args = (@_);
68
69 my $user = $self->current_user ? $self->current_user->user_object : undef;
70
71 return unless ($user);
72
73 # my $now = DateTime->now();
74 # $args{'updated'} = $now->ymd . " " . $now->hms;
75 $args{'created_by'} = $user;
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