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

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

revision 172 by dpavlin, Mon Jun 16 13:32:01 2008 UTC revision 183 by dpavlin, Mon Jun 16 21:33:59 2008 UTC
# Line 6  A3C::View::Strix Line 6  A3C::View::Strix
6    
7  =head1 DESCRIPTION  =head1 DESCRIPTION
8    
9  Display information about Strix sites  Display information about Strix instances
10    
11  =head1 TEMPLATES  =head1 TEMPLATES
12    
# Line 20  use Data::Dump qw/dump/; Line 20  use Data::Dump qw/dump/;
20    
21  =head2 /  =head2 /
22    
23  Display sites search and some stats  Display instaces search and some stats
24    
25  =cut  =cut
26    
27  template 'index.html' => page {  template 'index.html' => page {
28    
29          title is _('Strix sites');          title is _('Strix instances');
30    
31          my $orgs = A3C::Model::StrixSiteCollection->new;          my $orgs = A3C::Model::StrixInstanceCollection->new;
32          $orgs->unlimit;          $orgs->unlimit;
33    
34          div { _('Number of sites in Strix: %1', $orgs->count ) };          div { _('Number of instances in Strix: %1', $orgs->count ) };
35    
36          render_region(          render_region(
37                  name => 'selected-sites',                  name => 'selected-instances',
38                  path => '/strix/selected-sites'                  path => '/strix/selected-instances'
39          );          );
40    
41          render_region(          render_region(
42                  name => 'search-sites',                  name => 'search-instances',
43                  path => '/strix/search-sites',                  path => '/strix/search-instances',
44          );          );
45    
46  };  };
# Line 53  template 'name_diff' => page { Line 53  template 'name_diff' => page {
53    
54          title is _('Strix name differences');          title is _('Strix name differences');
55    
56            render_region(
57                    name => 'selected-instances',
58                    path => '/strix/selected-instances'
59            );
60    
61          my $name_diff = A3C::SQL->new({ query => qq{          my $name_diff = A3C::SQL->new({ query => qq{
62                  select                  select
63                          site,hreduorgurl,                          instance,hreduorgurl,
64                          _site_name,o                          _site_name,o
65                  from strix_sites                  from strix_instances
66                  join hr_edu_orgs on cn = site                  join hr_edu_orgs on cn = instance
67                  where o != _site_name                  where o != _site_name
68          }});          }});
69    
# Line 66  template 'name_diff' => page { Line 71  template 'name_diff' => page {
71    
72                  table {                  table {
73                          row {                          row {
74                                  th { _('Site') }                                  th {}
75                                  th { _('Strix site name') }                                  th { _('Instance') }
76                                    th { _('Strix instance name') }
77                                  th { _('hrEduOrg.o') }                                  th { _('hrEduOrg.o') }
78                          };                          };
79                          while ( my $row = $name_diff->next ) {                          while ( my $row = $name_diff->next ) {
80                                  row {                                  row {
81                                          cell { hyperlink( url => 'http://' . $row->hreduorgurl, label => $row->site ) }                                          cell { show( 'instance-op', 'Create', '+', $row->instance ) }
82                                            cell { $row->instance }
83                                          cell { $row->_site_name }                                          cell { $row->_site_name }
84                                          cell { $row->o }                                          cell { $row->o }
85                                  }                                  }
# Line 80  template 'name_diff' => page { Line 87  template 'name_diff' => page {
87                  }                  }
88                    
89          } else {          } else {
90                  div { _("Can't find any site in strix which has different name than data from LDAP") }                  div { _("Can't find any instance of strix which has different name than data from LDAP") }
91          }          }
92    
93  };  };
94    
95  =head2 sql  =head2 sql
96    
97  Execute SQL query on site  Execute SQL query on instance
98    
99  =cut  =cut
100    
# Line 96  template 'sql' => page { Line 103  template 'sql' => page {
103          title is _('Execute SQL');          title is _('Execute SQL');
104    
105          render_region(          render_region(
106                  name => 'selected-sites',                  name => 'selected-instances',
107                  path => '/strix/selected-sites'                  path => '/strix/selected-instances'
108          );          );
109    
110          render_region(          render_region(
# Line 107  template 'sql' => page { Line 114  template 'sql' => page {
114    
115  };  };
116    
117    sub strix {
118            my $instance = get('instance') || shift || 'new';
119            return Strix->new({ instance => $instance });
120    }
121    
122  =head2 sitemap  =head2 sitemap
123    
124  =cut  =cut
# Line 115  template 'sitemap' => page { Line 127  template 'sitemap' => page {
127    
128          title is _('Sitemap');          title is _('Sitemap');
129    
130          my $strix = Strix->new({ site => 'new' });          render_region(
131          my $sitemap = $strix->site_navigation( 1 );                  name => 'selected-instances',
132                    path => '/strix/selected-instances'
133            );
134    
135            my $site_id = get('site_id') || 1;
136    
137            my $sitemap = strix->site_navigation( $site_id );
138    
139          sub full_url {          sub full_url {
140                  my $p = shift;                  my $p = shift;
# Line 124  template 'sitemap' => page { Line 142  template 'sitemap' => page {
142                          url => 'http://new.cms-qa.skole.hr' . $p->{url},                          url => 'http://new.cms-qa.skole.hr' . $p->{url},
143                          label => $p->{naziv},                          label => $p->{naziv},
144                  );                  );
145                    if ( $p->{type} eq 'category' ) {
146                            outs_raw(' ');
147                            hyperlink(
148                                    url => '/strix/layout?url=' . $p->{url},
149                                    label => '[layout]',
150                            );
151                    }
152          }          }
153    
154          sub children {          sub children {
# Line 132  template 'sitemap' => page { Line 157  template 'sitemap' => page {
157                  ul {                  ul {
158                          foreach my $p ( @{ $c->{children} } ) {                          foreach my $p ( @{ $c->{children} } ) {
159                                  li {                                  li {
160                                            { class is $p->{class} };
161                                          full_url( $p );                                          full_url( $p );
162                                          children( $p );                                          children( $p );
163                                  }                                  }
# Line 150  template 'sitemap' => page { Line 176  template 'sitemap' => page {
176    
177  };  };
178    
179    =head2 layout
180    
181    =cut
182    
183    template 'layout' => page {
184    
185            my $url = get('url') || '/';
186    
187            my $category = strix->category( $url );
188    
189            warn dump( $category );
190    
191            title is _('Layout %1 : %2',
192                    $category->{sitename},
193                    $category->{naziv},
194            );
195    
196            hyperlink(
197                    url => 'http://' . $category->{sitename} . '/' . $category->{url},
198                    label => $category->{naziv},
199            );
200    
201            my $layout = strix->layout( $url );
202    
203            pre {
204                    dump( $layout );
205            }
206    
207    };
208    
209  =head1 REGIONS  =head1 REGIONS
210    
211  =head2 execute-sql  =head2 execute-sql
212    
213  Execute SQL query on site  Execute SQL query on instance
214    
215  =cut  =cut
216    
# Line 166  template 'execute-sql' => sub { Line 222  template 'execute-sql' => sub {
222                  sticky_on_success => 1,                  sticky_on_success => 1,
223                  sticky_on_failure => 1,                  sticky_on_failure => 1,
224                  arguments => {                  arguments => {
225                          strix => get('strix')                          instance => get('instance')
226                  }                  }
227          );          );
228    
229          form {          form {
230                  render_action( $action => [ 'strix', 'sql' ] );                  render_action( $action => [ 'instance', 'sql' ] );
231                  form_submit( label => _('Execute SQL') );                  form_submit( label => _('Execute SQL') );
232          };          };
233    
# Line 190  template 'execute-sql' => sub { Line 246  template 'execute-sql' => sub {
246          }          }
247  };  };
248    
249  =head2 search-sites  =head2 search-instances
250    
251  =cut  =cut
252    
253  template 'search-sites' => sub {  template 'search-instances' => sub {
254    
255          h1 { _('Find site') }          h1 { _('Find instance') }
256    
257          my $action = new_action(          my $action = new_action(
258                  class   => 'SearchStrixSite',                  class   => 'SearchStrixInstance',
259                  moniker => 'search-strix-site',                  moniker => 'search-strix-instance',
260                  sticky_on_success => 1,                  sticky_on_success => 1,
261                  sticky_on_failure => 1,                  sticky_on_failure => 1,
262          );          );
263    
264    
265          form {          form {
266                  render_action( $action => [ 'site_contains', '_site_name_contains' ] );                  render_action( $action => [ 'instance_contains', '_site_name_contains' ] );
267                  form_submit( label => _('Search') );                  form_submit( label => _('Search') );
268          };          };
269    
# Line 218  template 'search-sites' => sub { Line 274  template 'search-sites' => sub {
274                  table {                  table {
275                          while (my $strix = $search->next) {                          while (my $strix = $search->next) {
276                                  row {                                  row {
277                                          cell { tt { $strix->site } }                                          cell { tt { $strix->instance } }
278                                          cell { $strix->_site_name }                                          cell { $strix->_site_name }
279                                          cell { show( 'site-op', 'Create', '+', $strix->site ) }                                          cell { show( 'instance-op', 'Create', '+', $strix->instance ) }
280                                  }                                  }
281                          }                          }
282                  }                  }
# Line 228  template 'search-sites' => sub { Line 284  template 'search-sites' => sub {
284    
285  };  };
286    
287  =head2 selected-sites  =head2 selected-instances
288    
289  Show Selected sites for current user  Show Selected instances for current user
290    
291  =cut  =cut
292    
293  template 'selected-sites' => sub {  template 'selected-instances' => sub {
294          my $self = shift;          my $self = shift;
295    
296          warn "## IN selected-sites ",dump( @_ );          warn "## IN selected-instances ",dump( @_ );
297    
298          if ( my $op = get 'op' ) {          if ( my $op = get 'op' ) {
299                  my $site = get 'site' or die "no site?";                  my $instance = get 'instance' or die "no instance?";
300                  warn "# selected-sites $op on $site";                  warn "# selected-instances $op on $instance";
301    
302                  my $a;                  my $a;
303    
304                  if ( $op eq 'Create' ) {                  if ( $op eq 'Create' ) {
305    
306                          $a = new_action(                          $a = new_action(
307                                  class => $op . 'StrixSiteSelection',                                  class => $op . 'StrixInstanceSelection',
308                                  moniker => $op,                                  moniker => $op,
309                                  arguments => {                                  arguments => {
310                                          strix => $site,                                          instance => $instance,
311                                          by_user => $self->current_user->id,                                          by_user => $self->current_user->id,
312                                  },                                  },
313                          );                          );
314    
315                  } elsif ( $op eq 'Delete' ) {                  } elsif ( $op eq 'Delete' ) {
316    
317                          my $strix = A3C::Model::StrixSiteSelection->new;                          my $strix = A3C::Model::StrixInstanceSelection->new;
318                          $strix->load_by_cols( strix => $site, by_user => $self->current_user->id );                          $strix->load_by_cols( instance => $instance, by_user => $self->current_user->id );
319                          die "can't find site $site" unless $strix->id;                          die "can't find instance $instance" unless $strix->id;
320                          $a = $strix->as_delete_action;                          $a = $strix->as_delete_action;
321    
322                  }                  }
323                  warn "# argument_values = ",dump( $a->argument_values );                  warn "# argument_values = ",dump( $a->argument_values );
324                  $a->run;                  $a->run;
325                  warn "can't $op site $site" unless $a->result->success;                  warn "can't $op instance $instance" unless $a->result->success;
326          }          }
327    
328          my $selected = A3C::Model::StrixSiteSelectionCollection->new;          my $selected = A3C::Model::StrixInstanceSelectionCollection->new;
329          $selected->limit( column => 'by_user', value => Jifty->web->current_user->id );          $selected->limit( column => 'by_user', value => Jifty->web->current_user->id );
330    
331          if ( $selected->count > 0 ) {          if ( $selected->count > 0 ) {
332    
333                  div { _('%1 sites selected', $selected->count ) }                  div { _('%1 instances selected', $selected->count ) };
334                  table {                  table {
335                          while (my $s = $selected->next) {                          while (my $s = $selected->next) {
336                                  row {                                  row {
337                                          cell { tt { $s->strix->site } }                                          cell { tt {
338                                          cell { $s->strix->_site_name }                                                  hyperlink(
339                                          cell { show( 'site-op', 'Delete', '-', $s->strix->site ) }                                                          url => '?instance=' . $s->instance->instance,
340                                                            label => $s->instance->instance
341                                                    )
342                                            } }
343                                            cell { $s->instance->_site_name }
344                                            cell { show( 'instance-op', 'Delete', '-', $s->instance->instance ) }
345                                  }                                  }
346                          }                          }
347                  }                  }
348          } else {          } else {
349                  div { _('No sites selected') }                  div { _('No instances selected') }
350          }          }
351  };  };
352    
353  =head2 site-op  =head2 instance-op
354    
355  Display button to add/remove site from selection  Display button to add/remove instance from selection
356    
357    show( 'site-op', 'Delete', '-', $strix->site );    show( 'instance-op', 'Delete', '-', $strix->instace );
358    
359  =cut  =cut
360    
361  template 'site-op' => sub {  template 'instance-op' => sub {
362          my $self = shift;          my $self = shift;
363    
364          warn "# site-op = ",dump( @_ );          warn "# instance-op = ",dump( @_ );
365    
366          my ( $op, $label, $site ) = @_;          my ( $op, $label, $instance ) = @_;
367    
368          form {          form {
369                  hyperlink(                  hyperlink(
370                          label => $label,                          label => $label,
371                          onclick => {                          onclick => {
372                                  refresh => 'selected-sites',                                  refresh => 'selected-instances',
373                                  path => '/strix/selected-sites',                                  path => '/strix/selected-instances',
374                                  args => {                                  args => {
375                                          site => $site,                                          instance => $instance,
376                                          op => $op,                                          op => $op,
377                                  }                                  }
378                          },                          },

Legend:
Removed from v.172  
changed lines
  Added in v.183

  ViewVC Help
Powered by ViewVC 1.1.26