/[Arh]/lib/Arh/Model/Picture.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

Diff of /lib/Arh/Model/Picture.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 12 by dpavlin, Thu Nov 29 19:32:41 2007 UTC revision 61 by dpavlin, Mon Apr 7 14:33:31 2008 UTC
# Line 8  use Data::Dump qw/dump/; Line 8  use Data::Dump qw/dump/;
8    
9  use Arh::Record schema {  use Arh::Record schema {
10    
11            column filename =>
12                    label is _("Picture filename");
13    #               is immutable,
14    #               is indexed,
15    #               is unique;
16    
17            column content =>
18                    label is _('Picture'),
19                    type is 'bytea',
20    #               render as 'Upload',
21                    render as 'Arh::Web::Form::Field::Upload',
22                    is mandatory;
23    
24          column campaign =>          column campaign =>
25                  label is _("Part of campaign"),                  label is _("Part of campaign"),
26                  refers_to Arh::Model::Campaign,                  refers_to Arh::Model::Campaign,
27                  is required,                  is mandatory,
28                  is indexed,                  is indexed,
29                  since '0.0.4';                  since '0.0.4';
30                    
         column filename =>  
                 label is _("Picture filename"),  
                 is required,  
                 is indexed,  
                 is unique;  
   
31          column type =>          column type =>
32                  label is _("Type of picture"),                  label is _("Type of picture"),
33                  refers_to Arh::Model::PictureType,                  refers_to Arh::Model::PictureType,
34                  is required,                  is mandatory,
35                  is indexed,                  is indexed,
36                  since '0.0.4';                  since '0.0.4';
37    
38            column unit =>
39                    label is _('Unit'),
40                    refers_to Arh::Model::Unit,
41                    is mandatory,
42                    is indexed;
43    
44            column thumbnail =>
45                    label is _('Thumbnail name'),
46                    is indexed;
47    
48            column width =>
49                    label is _('Thumbnail width'),
50                    type is 'int';
51    
52            column height =>
53                    label is _('Thumbnail height'),
54                    type is 'int';
55    
56  };  };
57    
58  # Your model-specific methods go here.  # Your model-specific methods go here.
59    
 sub since { '0.0.3' }  
   
60  sub all_filenames {  sub all_filenames {
61    
62          my @files;          my @files;
63          my $path = Jifty::Util->app_root . '/share/web/static/pics';          my $path = Jifty::Util->app_root . '/share/web/static/pics';
64    
65          warn "## path = $path";  #       warn "## path = $path";
66    
67          find({ wanted => sub {          find({ wanted => sub {
68                  my $f = $File::Find::name;                  my $f = $File::Find::name;
# Line 47  sub all_filenames { Line 70  sub all_filenames {
70                  push @files, $_;                  push @files, $_;
71          }, follow => 0 }, $path);          }, follow => 0 }, $path);
72    
73          warn "## all_filenames = ",dump( @files );  #       warn "## all_filenames = ",dump( @files );
74    
75          return @files;          return @files;
76  }  }
77    
78  #use Jifty::Plugin::ActorMetadata::Mixin::Model::ActorMetadata; # created_by, created_on, updated_on  #use Jifty::Plugin::ActorMetadata::Mixin::Model::ActorMetadata; # created_by, created_on, updated_on
79    
80  sub current_user_can {  use Arh::DefaultACL;
         my ( $self, $action,$item,$name ) = @_;  
         return 1 if $self->current_user->superuser || $self->current_user->administrator;  
         return 1 if $action eq 'read';  
     return 0;  
 }  
81    
82  1;  1;
83    

Legend:
Removed from v.12  
changed lines
  Added in v.61

  ViewVC Help
Powered by ViewVC 1.1.26