/[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 174 by dpavlin, Mon Jun 16 16:48:16 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 55  template 'name_diff' => page { Line 55  template 'name_diff' => page {
55    
56          my $name_diff = A3C::SQL->new({ query => qq{          my $name_diff = A3C::SQL->new({ query => qq{
57                  select                  select
58                          site,hreduorgurl,                          instance,hreduorgurl,
59                          _site_name,o                          _site_name,o
60                  from strix_sites                  from strix_instances
61                  join hr_edu_orgs on cn = site                  join hr_edu_orgs on cn = instance
62                  where o != _site_name                  where o != _site_name
63          }});          }});
64    
# Line 66  template 'name_diff' => page { Line 66  template 'name_diff' => page {
66    
67                  table {                  table {
68                          row {                          row {
69                                  th { _('Site') }                                  th { _('Instance') }
70                                  th { _('Strix site name') }                                  th { _('Strix instance name') }
71                                  th { _('hrEduOrg.o') }                                  th { _('hrEduOrg.o') }
72                          };                          };
73                          while ( my $row = $name_diff->next ) {                          while ( my $row = $name_diff->next ) {
74                                  row {                                  row {
75                                          cell { hyperlink( url => 'http://' . $row->hreduorgurl, label => $row->site ) }                                          cell { hyperlink( url => 'http://' . $row->hreduorgurl, label => $row->instance ) }
76                                          cell { $row->_site_name }                                          cell { $row->_site_name }
77                                          cell { $row->o }                                          cell { $row->o }
78                                  }                                  }
# Line 80  template 'name_diff' => page { Line 80  template 'name_diff' => page {
80                  }                  }
81                    
82          } else {          } else {
83                  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") }
84          }          }
85    
86  };  };
87    
88  =head2 sql  =head2 sql
89    
90  Execute SQL query on site  Execute SQL query on instance
91    
92  =cut  =cut
93    
# Line 96  template 'sql' => page { Line 96  template 'sql' => page {
96          title is _('Execute SQL');          title is _('Execute SQL');
97    
98          render_region(          render_region(
99                  name => 'selected-sites',                  name => 'selected-instances',
100                  path => '/strix/selected-sites'                  path => '/strix/selected-instances'
101          );          );
102    
103          render_region(          render_region(
# Line 107  template 'sql' => page { Line 107  template 'sql' => page {
107    
108  };  };
109    
110    sub strix {
111            my $instance = get('instance') || shift || 'new';
112            return Strix->new({ instance => $instance });
113    }
114    
115  =head2 sitemap  =head2 sitemap
116    
117  =cut  =cut
# Line 115  template 'sitemap' => page { Line 120  template 'sitemap' => page {
120    
121          title is _('Sitemap');          title is _('Sitemap');
122    
123          my $strix = Strix->new({ site => 'new' });          my $site_id = get('site_id') || 1;
124          my $sitemap = $strix->site_navigation( 1 );  
125            my $sitemap = strix->site_navigation( $site_id );
126    
127          sub full_url {          sub full_url {
128                  my $p = shift;                  my $p = shift;
# Line 124  template 'sitemap' => page { Line 130  template 'sitemap' => page {
130                          url => 'http://new.cms-qa.skole.hr' . $p->{url},                          url => 'http://new.cms-qa.skole.hr' . $p->{url},
131                          label => $p->{naziv},                          label => $p->{naziv},
132                  );                  );
133                    if ( $p->{type} eq 'category' ) {
134                            outs_raw(' ');
135                            hyperlink(
136                                    url => '/strix/layout?url=' . $p->{url},
137                                    label => '[layout]',
138                            );
139                    }
140          }          }
141    
142          sub children {          sub children {
# Line 150  template 'sitemap' => page { Line 163  template 'sitemap' => page {
163    
164  };  };
165    
166    =head2 layout
167    
168    =cut
169    
170    template 'layout' => page {
171    
172            my $url = get('url') || '/';
173    
174            my $category = strix->category( $url );
175    
176            warn dump( $category );
177    
178            title is _('Layout %1 : %2',
179                    $category->{sitename},
180                    $category->{naziv},
181            );
182    
183            hyperlink(
184                    url => 'http://' . $category->{sitename} . '/' . $category->{url},
185                    label => $category->{naziv},
186            );
187    
188            my $layout = strix->layout( $url );
189    
190            pre {
191                    dump( $layout );
192            }
193    
194    };
195    
196  =head1 REGIONS  =head1 REGIONS
197    
198  =head2 execute-sql  =head2 execute-sql
199    
200  Execute SQL query on site  Execute SQL query on instance
201    
202  =cut  =cut
203    
# Line 190  template 'execute-sql' => sub { Line 233  template 'execute-sql' => sub {
233          }          }
234  };  };
235    
236  =head2 search-sites  =head2 search-instances
237    
238  =cut  =cut
239    
240  template 'search-sites' => sub {  template 'search-instances' => sub {
241    
242          h1 { _('Find site') }          h1 { _('Find instance') }
243    
244          my $action = new_action(          my $action = new_action(
245                  class   => 'SearchStrixSite',                  class   => 'SearchStrixInstance',
246                  moniker => 'search-strix-site',                  moniker => 'search-strix-instance',
247                  sticky_on_success => 1,                  sticky_on_success => 1,
248                  sticky_on_failure => 1,                  sticky_on_failure => 1,
249          );          );
250    
251    
252          form {          form {
253                  render_action( $action => [ 'site_contains', '_site_name_contains' ] );                  render_action( $action => [ 'instance_contains', '_site_name_contains' ] );
254                  form_submit( label => _('Search') );                  form_submit( label => _('Search') );
255          };          };
256    
# Line 218  template 'search-sites' => sub { Line 261  template 'search-sites' => sub {
261                  table {                  table {
262                          while (my $strix = $search->next) {                          while (my $strix = $search->next) {
263                                  row {                                  row {
264                                          cell { tt { $strix->site } }                                          cell { tt { $strix->instance } }
265                                          cell { $strix->_site_name }                                          cell { $strix->_site_name }
266                                          cell { show( 'site-op', 'Create', '+', $strix->site ) }                                          cell { show( 'instance-op', 'Create', '+', $strix->instance ) }
267                                  }                                  }
268                          }                          }
269                  }                  }
# Line 228  template 'search-sites' => sub { Line 271  template 'search-sites' => sub {
271    
272  };  };
273    
274  =head2 selected-sites  =head2 selected-instances
275    
276  Show Selected sites for current user  Show Selected instances for current user
277    
278  =cut  =cut
279    
280  template 'selected-sites' => sub {  template 'selected-instances' => sub {
281          my $self = shift;          my $self = shift;
282    
283          warn "## IN selected-sites ",dump( @_ );          warn "## IN selected-instances ",dump( @_ );
284    
285          if ( my $op = get 'op' ) {          if ( my $op = get 'op' ) {
286                  my $site = get 'site' or die "no site?";                  my $instance = get 'instance' or die "no instance?";
287                  warn "# selected-sites $op on $site";                  warn "# selected-instances $op on $instance";
288    
289                  my $a;                  my $a;
290    
291                  if ( $op eq 'Create' ) {                  if ( $op eq 'Create' ) {
292    
293                          $a = new_action(                          $a = new_action(
294                                  class => $op . 'StrixSiteSelection',                                  class => $op . 'StrixInstanceSelection',
295                                  moniker => $op,                                  moniker => $op,
296                                  arguments => {                                  arguments => {
297                                          strix => $site,                                          instance => $instance,
298                                          by_user => $self->current_user->id,                                          by_user => $self->current_user->id,
299                                  },                                  },
300                          );                          );
301    
302                  } elsif ( $op eq 'Delete' ) {                  } elsif ( $op eq 'Delete' ) {
303    
304                          my $strix = A3C::Model::StrixSiteSelection->new;                          my $strix = A3C::Model::StrixInstanceSelection->new;
305                          $strix->load_by_cols( strix => $site, by_user => $self->current_user->id );                          $strix->load_by_cols( instance => $instance, by_user => $self->current_user->id );
306                          die "can't find site $site" unless $strix->id;                          die "can't find instance $instance" unless $strix->id;
307                          $a = $strix->as_delete_action;                          $a = $strix->as_delete_action;
308    
309                  }                  }
310                  warn "# argument_values = ",dump( $a->argument_values );                  warn "# argument_values = ",dump( $a->argument_values );
311                  $a->run;                  $a->run;
312                  warn "can't $op site $site" unless $a->result->success;                  warn "can't $op instance $instance" unless $a->result->success;
313          }          }
314    
315          my $selected = A3C::Model::StrixSiteSelectionCollection->new;          my $selected = A3C::Model::StrixInstanceSelectionCollection->new;
316          $selected->limit( column => 'by_user', value => Jifty->web->current_user->id );          $selected->limit( column => 'by_user', value => Jifty->web->current_user->id );
317    
318          if ( $selected->count > 0 ) {          if ( $selected->count > 0 ) {
319    
320                  div { _('%1 sites selected', $selected->count ) }                  div { _('%1 instances selected', $selected->count ) }
321                  table {                  table {
322                          while (my $s = $selected->next) {                          while (my $s = $selected->next) {
323                                  row {                                  row {
324                                          cell { tt { $s->strix->site } }                                          cell { tt { $s->strix->instance } }
325                                          cell { $s->strix->_site_name }                                          cell { $s->strix->_site_name }
326                                          cell { show( 'site-op', 'Delete', '-', $s->strix->site ) }                                          cell { show( 'instance-op', 'Delete', '-', $s->strix->instance ) }
327                                  }                                  }
328                          }                          }
329                  }                  }
330          } else {          } else {
331                  div { _('No sites selected') }                  div { _('No instances selected') }
332          }          }
333  };  };
334    
335  =head2 site-op  =head2 instance-op
336    
337  Display button to add/remove site from selection  Display button to add/remove instance from selection
338    
339    show( 'site-op', 'Delete', '-', $strix->site );    show( 'instance-op', 'Delete', '-', $strix->instace );
340    
341  =cut  =cut
342    
343  template 'site-op' => sub {  template 'instance-op' => sub {
344          my $self = shift;          my $self = shift;
345    
346          warn "# site-op = ",dump( @_ );          warn "# instance-op = ",dump( @_ );
347    
348          my ( $op, $label, $site ) = @_;          my ( $op, $label, $instance ) = @_;
349    
350          form {          form {
351                  hyperlink(                  hyperlink(
352                          label => $label,                          label => $label,
353                          onclick => {                          onclick => {
354                                  refresh => 'selected-sites',                                  refresh => 'selected-instances',
355                                  path => '/strix/selected-sites',                                  path => '/strix/selected-instances',
356                                  args => {                                  args => {
357                                          site => $site,                                          instance => $instance,
358                                          op => $op,                                          op => $op,
359                                  }                                  }
360                          },                          },

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

  ViewVC Help
Powered by ViewVC 1.1.26