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

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

revision 55 by dpavlin, Tue Apr 1 19:39:00 2008 UTC revision 208 by dpavlin, Thu Jun 19 21:24:26 2008 UTC
# Line 5  use warnings; Line 5  use warnings;
5    
6  use Jifty::View::Declare -base;  use Jifty::View::Declare -base;
7  use A3C::LDAP;  use A3C::LDAP;
8    use A3C::SQL;
9    
10  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
11    
12    private template 'menu' => sub {
13  template '/skole' => page {          div {
14          h1 { _('Schools in system') };                  attr { id => "navigation" };
15          show 'skole_sve';                  Jifty->web->navigation->render_as_classical_menu;
16            };
17  };  };
18    
19  private template 'skole_sve' => sub {  
20          my $ldap = A3C::LDAP->new;  template '/' => page {
21          div {  
22                  $ldap->search(          h1 { _('Statistics') }
23                          base    => 'dc=skole,dc=hr',  
24                          filter  => '(objectClass=hrEduOrg)',          my $orgs = A3C::Model::hrEduOrgCollection->new;
25                          sizelimit => 10,          $orgs->unlimit;
26                  );  
27                  while ( my $entry = $ldap->current_search->shift_entry ) {          dt { _('Number of schools in system') }
28                          #warn $entry->dump;          dd { $orgs->count }
29                          ul {  
30                                  foreach my $attr ( $entry->attributes ) {          my $people = A3C::Model::hrEduPersonCollection->new;
31                                          li {          $people->unlimit;
32                                                  tt { $attr }  
33                                                  span { dump( $entry->get_value( $attr ) ) }          dt { _('Number of persons in system') }
34                                          }          dd { $people->count }
35    
36            my $by_towns = A3C::SQL->new({ query => qq{
37                    select count(uid),l
38                    from hr_edu_orgs
39                    inner join towns on towns.name = l
40                    group by l
41                    order by count desc
42                    limit 25
43            }});
44    
45            dt { _('Top %1 towns by schools', $by_towns->count) }
46            dd {
47                    ul {
48                            while ( my $row = $by_towns->next ) {
49                                    li { outs_raw( $row->count, ' ', $row->l ) }
50                            }
51                    }
52            }
53    
54            my $by_county = A3C::SQL->new({ query => qq{
55                    select
56                            count(uid) as schools,
57                            county,
58                            count(distinct municipality) as municipalities
59                    from hr_edu_orgs
60                    inner join towns on towns.name = l
61                    group by county
62                    order by schools desc
63            }});
64    
65            dt { _('Schools by counties') }
66            dd {
67                    table {
68                            th { _('Schools') }
69                            th { _('County') }
70                            th { _('Municipalities') };
71                            while ( my $row = $by_county->next ) {
72                                    row {
73                                            cell { $row->schools }
74                                            cell { $row->county }
75                                            cell { $row->municipalities }
76                                  }                                  }
77                          }                          }
78                  }                  }
79          }          }
80  };  };
81    
82  template '/search-users' => page {  
83    template 'people' => page {
84            
85            h1 { _('Find people') }
86    
87          my $action = new_action(          my $action = new_action(
88                  class   => 'SearchUser',                  class   => 'SearchhrEduPerson',
89                  moniker => 'search-users'                  moniker => 'search-users',
90                    sticky_on_success => 1,
91                    sticky_on_failure => 1,
92          );          );
93    
94    
95          form {          form {
96                  render_action( $action => [ 'uid_contains', 'cn_contains' ] );                  render_action( $action => [ 'uid_contains', 'cn_contains' ] );
97                  form_submit( label => _('Find someone') );                  form_submit( label => _('Search') );
98          };          };
99    
100  #       warn dump( $action->result->content );  #       warn dump( $action->result->content );
101    
102          if ( my $search = $action->result->content('search') ) {          if ( my $search = $action->result->content('search') ) {
103                  div { sprintf(_('Found %d results'), $search->count ) }                  div { _('Found %1 results', $search->count ) }
104                  ol {                  table {
105                          while (my $user = $search->next) {                          while (my $user = $search->next) {
106                                  li {                                  row {
107                                          span { $user->cn }                                          cell { $user->cn }
108                                          tt { $user->uid }                                          cell { tt { $user->uid } }
109                                            cell { tt { $user->hrEduPersonUniqueID } }
110                                            cell { $user->hrEduPersonHomeOrg }
111                                  }                                  }
112                          }                          }
113                  }                  }
# Line 64  template '/search-users' => page { Line 115  template '/search-users' => page {
115    
116  };  };
117    
118  template '/sync' => page {  # mount other views
119    use A3C::View::Organization;
120    
121          my $action = new_action(  # we can't really use following form because Jifty would upper case first
122                  class   => 'SyncOrganization',  # letter of model and try to find A3C::Model::HrEduOrg which doesn't exit!
123                  moniker => 'sync-organization'  #Jifty::View::Declare::CRUD->mount_view('hrEduOrg', 'A3C::View::Organization', '/organizations');
124          );  alias A3C::View::Organization under '/organizations', {
125            object_type => 'hrEduOrg',
126    };
127    
128          form {  use A3C::View::LDAP;
129                  render_action( $action => [ 'cn' ] );  alias A3C::View::LDAP under '/ldap';
                 form_submit( label => _('Sync Organization') );  
         };  
130    
131          if ( my $users = $action->result->content('synced-users') ) {  use A3C::View::Strix;
132                  ol {  alias A3C::View::Strix under '/strix';
                         while (my $user = $users->next) {  
                                 li {  
                                         span { $user->cn }  
                                         tt { '<' . $user->mail . '>' }  
                                 }  
                         }  
                 }  
         }  
133    
134  };  1;

Legend:
Removed from v.55  
changed lines
  Added in v.208

  ViewVC Help
Powered by ViewVC 1.1.26