/[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 22 - (show annotations)
Fri May 26 18:35:08 2006 UTC (18 years ago) by dpavlin
File size: 1901 byte(s)
added current_user_can for create, read and update to everybody
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 =head2 current_user_can ACTION
76
77 Let everybody create, read and update, but not delete.
78
79 =cut
80
81 sub current_user_can {
82 my $self = shift;
83 my $type = shift;
84
85 # We probably want something like this eventually:
86 if ($type =~ /(?:create|read|update)/i) {
87 return 1;
88 } else {
89 return $self->SUPER::current_user_can($type, @_);
90 }
91 }
92
93
94 1;
95

  ViewVC Help
Powered by ViewVC 1.1.26