/[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 8 by dpavlin, Thu Nov 29 16:08:13 2007 UTC revision 19 by dpavlin, Fri Nov 30 17:36:21 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                    } else {
18                            span { outs _("No pubicly available pictures at this time...") }
19                    }
20                  table {                  table {
21                          while ( my $f = $fc->next ) {                          while ( my $f = $fc->next ) {
22                                  $present->{ $f->filename }++;                                  $present->{ $f->filename }++;
# Line 20  template '/pictures' => page { Line 24  template '/pictures' => page {
24                                  my $update = new_action( class => 'UpdatePicture', record => $f );                                  my $update = new_action( class => 'UpdatePicture', record => $f );
25                                  row {                                  row {
26                                          cell {                                          cell {
27                                                    attr { class => 'picture' };
28                                                  img { attr { src => "static/pics/" . $f->filename } }                                                  img { attr { src => "static/pics/" . $f->filename } }
29                                                  div { tt{ $f->filename } }                                                  div { tt{ $f->filename } }
30                                          }                                          }
31                                          cell {                                          cell {
32                                                    attr { class => 'picture-description' };
33                                                  render_param( $update => 'campaign', render_mode => 'read' );                                                  render_param( $update => 'campaign', render_mode => 'read' );
34                                                  render_param( $update => 'type', render_mode => 'read' );                                                  render_param( $update => 'type', render_mode => 'read' );
35                                                  div {                                                  if ( $f->current_user_can('write') ) {
36                                                          $delete->button(                                                          div {
37                                                                  submit => $delete,                                                                  $delete->button(
38                                                                  label => _('Delete'),                                                                          submit => $delete,
39                                                                  arguments => {                                                                          label => _('Delete'),
40                                                                          id => $f->id,                                                                          arguments => {
41                                                                  }                                                                                  id => $f->id,
42                                                          )                                                                          }
43                                                                    )
44                                                            }
45                                                  }                                                  }
46                                          }                                          }
47                                  }                                  }
48                          }                          }
49                          row {                          warn "current_user->id: ",current_user->id;
50                                  cell { attr { colspan => 4 } outs _('Pending pictures') }                          if ( current_user->id ) {
                         };  
                         warn "## present = ",dump( $present );  
                         foreach my $f ( Arh::Model::Picture->all_filenames ) {  
                                 next if $present->{$f};  
                                 my $create = new_action( class => 'CreatePicture' );  
51                                  row {                                  row {
52                                          cell {                                          cell { attr { colspan => 2 } h1 { _('Pending pictures') } }
53                                                  img { attr { src => "static/pics/$f" } }                                  };
54                                                  div { tt{ $f } }                                  warn "## present = ",dump( $present );
55                                          }                                  foreach my $f ( Arh::Model::Picture->all_filenames ) {
56                                          cell {                                          next if $present->{$f};
57                                                  render_param( $create => 'campaign' );                                          my $create = new_action( class => 'CreatePicture' );
58                                                  render_param( $create => 'type' );                                          row {
59                                                  $create->button(                                                  cell {
60                                                          submit => $create,                                                          attr { class => 'picture' };
61                                                          label => _('Add'),                                                          img { attr { src => "static/pics/$f" } }
62                                                          arguments => {                                                          div { tt{ $f } }
63                                                                  filename => $f,                                                  }
64                                                          }                                                  cell {
65                                                  );                                                          attr { class => 'picture-description' };
66                                                            render_param( $create => 'campaign' );
67                                                            render_param( $create => 'type' );
68                                                            $create->button(
69                                                                    submit => $create,
70                                                                    label => _('Add'),
71                                                                    arguments => {
72                                                                            filename => $f,
73                                                                    }
74                                                            );
75                                                    }
76                                          }                                          }
77                                  }                                  }
78                          }                          }
# Line 68  template '/pictures' => page { Line 81  template '/pictures' => page {
81    
82  };  };
83    
84    use Jifty::View::Declare::CRUD;
85    Jifty::View::Declare::CRUD->mount_view('materials');
86    
87    use Jifty::View::Declare::CRUD;
88    Jifty::View::Declare::CRUD->mount_view('units');
89    
90  template '/units' => page {  template '/units' => page {
91          h1 { _("Units available in system") };          h1 { _("Units available in system") };
92    
93          my $units = Arh::Model::UnitCollection->new;          my $search = Arh::Model::UnitCollection->new;
94          $units->unlimit;          $search->unlimit;
   
         while ( my $u = $units->next ) {  
                 unit( $u );  
         }  
 };  
95    
96  sub unit {          set( search_collection => $search );
97          my $unit = shift || die "no unit?";          render_region(
98          my $a = new_action( class => 'UpdateUnit', record => $unit );                  name => 'units',
99          form {                  path => '/units/list',
100                  foreach my $f ( qw/name number material dimensions position description chronology/ ) {                  defaults => {
101                          if ( $f eq 'material' ) {                          page => 1,
                                 my $material = $unit->material;  
                                 while ( my $um = $material->next ) {  
                                         my $m = new_action( class => 'UpdateMaterial', record => $um->material );  
                                         render_param( $m => 'name', label => _("Material"), render_mode => 'read' );  
                                 }  
                         } else {  
                                 render_param( $a => $f, render_mode => 'read' );  
                         }  
102                  }                  }
103          }          );
104  }  
105    };
106    
107  1;  1;

Legend:
Removed from v.8  
changed lines
  Added in v.19

  ViewVC Help
Powered by ViewVC 1.1.26