1 |
use strict; |
2 |
use warnings; |
3 |
|
4 |
package Arh::Model::Picture; |
5 |
use Jifty::DBI::Schema; |
6 |
use File::Find; |
7 |
use Data::Dump qw/dump/; |
8 |
|
9 |
use Arh::Record schema { |
10 |
|
11 |
column campaign => |
12 |
label is _("Part of campaign"), |
13 |
refers_to Arh::Model::Campaign, |
14 |
is required, |
15 |
is indexed, |
16 |
since '0.0.4'; |
17 |
|
18 |
column filename => |
19 |
label is _("Picture filename"), |
20 |
is required, |
21 |
is indexed, |
22 |
is unique; |
23 |
|
24 |
column type => |
25 |
label is _("Type of picture"), |
26 |
refers_to Arh::Model::PictureType, |
27 |
is required, |
28 |
is indexed, |
29 |
since '0.0.4'; |
30 |
|
31 |
}; |
32 |
|
33 |
# Your model-specific methods go here. |
34 |
|
35 |
sub since { '0.0.3' } |
36 |
|
37 |
sub all_filenames { |
38 |
|
39 |
my @files; |
40 |
my $path = Jifty::Util->app_root . '/share/web/static/pics'; |
41 |
|
42 |
warn "## path = $path"; |
43 |
|
44 |
find({ wanted => sub { |
45 |
my $f = $File::Find::name; |
46 |
return unless -f $f; |
47 |
push @files, $_; |
48 |
}, follow => 0 }, $path); |
49 |
|
50 |
warn "## all_filenames = ",dump( @files ); |
51 |
|
52 |
return @files; |
53 |
} |
54 |
|
55 |
1; |
56 |
|