--- lib/Arh/View.pm 2007/11/29 16:40:10 9 +++ lib/Arh/View.pm 2007/11/29 19:32:41 12 @@ -8,11 +8,13 @@ use Data::Dump qw/dump/; template '/pictures' => page { - h1 { _("Pictures available in system") }; my $fc = Arh::Model::PictureCollection->new; $fc->unlimit; my $present; form { + if ( $fc->count ) { + h1 { _("Pictures available in system") }; + } table { while ( my $f = $fc->next ) { $present->{ $f->filename }++; @@ -20,26 +22,30 @@ 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' ); - div { - $delete->button( - submit => $delete, - label => _('Delete'), - arguments => { - id => $f->id, - } - ) + if ( $f->current_user_can('write') ) { + div { + $delete->button( + submit => $delete, + label => _('Delete'), + arguments => { + id => $f->id, + } + ) + } } } } } row { - cell { attr { colspan => 4 } outs _('Pending pictures') } + cell { attr { colspan => 2 } h1 { _('Pending pictures') } } }; warn "## present = ",dump( $present ); foreach my $f ( Arh::Model::Picture->all_filenames ) { @@ -47,10 +53,12 @@ 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( @@ -82,6 +90,7 @@ sub unit { my $unit = shift || die "no unit?"; my $a = new_action( class => 'UpdateUnit', record => $unit ); + warn "## current_user = ",dump( current_user ); form { foreach my $f ( qw/name number campaign material dimensions position description chronology location/ ) { if ( $f eq 'material' ) { @@ -91,7 +100,10 @@ render_param( $m => 'name', label => _("Material"), render_mode => 'read' ); } } else { - render_param( $a => $f, render_mode => 'read' ); + my %opt; + $opt{render_mode} = 'read'; # unless + warn "write $f ",$unit->current_user_can('write',$f) ? 'ok' : 'DENIED'; + render_param( $a => $f, %opt ); } } }