/[Arh]/lib/Arh/View.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/View.pm

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

revision 7 by dpavlin, Thu Nov 29 15:13:10 2007 UTC revision 12 by dpavlin, Thu Nov 29 19:32:41 2007 UTC
# Line 8  use Jifty::View::Declare -base; Line 8  use Jifty::View::Declare -base;
8  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
9    
10  template '/pictures' => page {  template '/pictures' => page {
         h1 { _("Pictures available in system") };  
11          my $fc = Arh::Model::PictureCollection->new;          my $fc = Arh::Model::PictureCollection->new;
12          $fc->unlimit;          $fc->unlimit;
13          my $present;          my $present;
14          form {          form {
15                    if ( $fc->count ) {
16                            h1 { _("Pictures available in system") };
17                    }
18                  table {                  table {
19                          while ( my $f = $fc->next ) {                          while ( my $f = $fc->next ) {
20                                  $present->{ $f->filename }++;                                  $present->{ $f->filename }++;
21                                  my $delete = new_action( class => 'DeletePicture' );                                  my $delete = new_action( class => 'DeletePicture' );
22                                    my $update = new_action( class => 'UpdatePicture', record => $f );
23                                  row {                                  row {
24                                          cell {                                          cell {
25                                                    attr { class => 'picture' };
26                                                  img { attr { src => "static/pics/" . $f->filename } }                                                  img { attr { src => "static/pics/" . $f->filename } }
27                                                  div { tt{ $f->filename } }                                                  div { tt{ $f->filename } }
28                                          }                                          }
29                                          cell {                                          cell {
30                                                  ul {                                                  attr { class => 'picture-description' };
31                                                          li { _("Part of campaign"), ': ',  $f->campaign->name; }                                                  render_param( $update => 'campaign', render_mode => 'read' );
32                                                          li { _("Type of picture"), ': ', $f->type->name }                                                  render_param( $update => 'type', render_mode => 'read' );
33                                                          div { $delete->button(                                                  if ( $f->current_user_can('write') ) {
34                                                            div {
35                                                                    $delete->button(
36                                                                          submit => $delete,                                                                          submit => $delete,
37                                                                          label => _('Delete'),                                                                          label => _('Delete'),
38                                                                          arguments => {                                                                          arguments => {
# Line 39  template '/pictures' => page { Line 45  template '/pictures' => page {
45                                  }                                  }
46                          }                          }
47                          row {                          row {
48                                  cell { attr { colspan => 4 } outs _('Pending pictures') }                                  cell { attr { colspan => 2 } h1 { _('Pending pictures') } }
49                          };                          };
50                          warn "## present = ",dump( $present );                          warn "## present = ",dump( $present );
51                          foreach my $f ( Arh::Model::Picture->all_filenames ) {                          foreach my $f ( Arh::Model::Picture->all_filenames ) {
# Line 47  template '/pictures' => page { Line 53  template '/pictures' => page {
53                                  my $create = new_action( class => 'CreatePicture' );                                  my $create = new_action( class => 'CreatePicture' );
54                                  row {                                  row {
55                                          cell {                                          cell {
56                                                    attr { class => 'picture' };
57                                                  img { attr { src => "static/pics/$f" } }                                                  img { attr { src => "static/pics/$f" } }
58                                                  div { tt{ $f } }                                                  div { tt{ $f } }
59                                          }                                          }
60                                          cell {                                          cell {
61                                                    attr { class => 'picture-description' };
62                                                  render_param( $create => 'campaign' );                                                  render_param( $create => 'campaign' );
63                                                  render_param( $create => 'type' );                                                  render_param( $create => 'type' );
64                                                  $create->button(                                                  $create->button(
# Line 68  template '/pictures' => page { Line 76  template '/pictures' => page {
76    
77  };  };
78    
79    template '/units' => page {
80            h1 { _("Units available in system") };
81    
82            my $units = Arh::Model::UnitCollection->new;
83            $units->unlimit;
84    
85            while ( my $u = $units->next ) {
86                    unit( $u );
87            }
88    };
89    
90    sub unit {
91            my $unit = shift || die "no unit?";
92            my $a = new_action( class => 'UpdateUnit', record => $unit );
93            warn "## current_user = ",dump( current_user );
94            form {
95                    foreach my $f ( qw/name number campaign material dimensions position description chronology location/ ) {
96                            if ( $f eq 'material' ) {
97                                    my $material = $unit->material;
98                                    while ( my $um = $material->next ) {
99                                            my $m = new_action( class => 'UpdateMaterial', record => $um->material );
100                                            render_param( $m => 'name', label => _("Material"), render_mode => 'read' );
101                                    }
102                            } else {
103                                    my %opt;
104                                    $opt{render_mode} = 'read'; # unless
105                                    warn "write $f ",$unit->current_user_can('write',$f) ? 'ok' : 'DENIED';
106                                    render_param( $a => $f, %opt );
107                            }
108                    }
109            }
110    }
111    
112  1;  1;

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

  ViewVC Help
Powered by ViewVC 1.1.26