7 |
|
|
8 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
9 |
|
|
|
template 'pictures' => page { |
|
|
my $fc = Arh::Model::PictureCollection->new; |
|
|
$fc->unlimit; |
|
|
my $present; |
|
|
form { |
|
|
if ( $fc->count ) { |
|
|
h1 { _("Pictures available in system") }; |
|
|
} else { |
|
|
span { outs _("No pubicly available pictures at this time...") } |
|
|
} |
|
|
table { |
|
|
while ( my $f = $fc->next ) { |
|
|
$present->{ $f->filename }++; |
|
|
my $delete = new_action( class => 'DeletePicture' ); |
|
|
my $update = new_action( class => 'UpdatePicture', record => $f ); |
|
|
row { |
|
|
cell { |
|
|
attr { class => 'picture' }; |
|
|
img { attr { src => "/static/pics/" . $f->filename } } |
|
|
div { tt{ $f->filename } } |
|
|
} |
|
|
cell { |
|
|
attr { class => 'picture-description' }; |
|
|
render_param( $update => 'campaign', render_mode => 'read' ); |
|
|
render_param( $update => 'type', render_mode => 'read' ); |
|
|
if ( $f->current_user_can('write') ) { |
|
|
div { |
|
|
$delete->button( |
|
|
submit => $delete, |
|
|
label => _('Delete picture'), |
|
|
arguments => { |
|
|
id => $f->id, |
|
|
} |
|
|
) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
warn "current_user->id: ",current_user->id; |
|
|
if ( current_user->id ) { |
|
|
row { |
|
|
cell { attr { colspan => 2 } h1 { _('Pending pictures') } } |
|
|
}; |
|
|
warn "## present = ",dump( $present ); |
|
|
foreach my $f ( Arh::Model::Picture->all_filenames ) { |
|
|
next if $present->{$f}; |
|
|
my $create = new_action( class => 'CreatePicture' ); |
|
|
row { |
|
|
cell { |
|
|
attr { class => 'picture' }; |
|
|
img { attr { src => "/static/pics/$f" } } |
|
|
div { tt{ $f } } |
|
|
} |
|
|
cell { |
|
|
attr { class => 'picture-description' }; |
|
|
render_param( $create => 'campaign' ); |
|
|
render_param( $create => 'type' ); |
|
|
$create->button( |
|
|
submit => $create, |
|
|
label => _('Add'), |
|
|
arguments => { |
|
|
filename => $f, |
|
|
} |
|
|
); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
10 |
use Jifty::View::Declare::CRUD; |
use Jifty::View::Declare::CRUD; |
11 |
Jifty::View::Declare::CRUD->mount_view('materials'); |
Jifty::View::Declare::CRUD->mount_view('materials'); |
12 |
Jifty::View::Declare::CRUD->mount_view('UnitPictures'); |
Jifty::View::Declare::CRUD->mount_view('UnitPictures'); |
54 |
}; |
}; |
55 |
|
|
56 |
template 'raw_pic' => sub { |
template 'raw_pic' => sub { |
57 |
my $filename = get('image') or die "no image?"; |
my $filename = get('filename') or die "no filename?"; |
58 |
my $image = Arh::Model::Picture->new; |
my $image = Arh::Model::Picture->new; |
59 |
$image->load_by_cols( filename => $filename ); |
$image->load_by_cols( filename => $filename ); |
60 |
if ( $image->id ) { |
if ( $image->id ) { |