/[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 41 by dpavlin, Sun Mar 30 15:23:35 2008 UTC revision 79 by dpavlin, Fri Apr 11 23:23:42 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    template '/' => page {
13    
14            h1 { _('Statistics') }
15    
16            my $orgs = A3C::Model::OrganizationCollection->new;
17            $orgs->unlimit;
18    
19            dt { _('Number of schools in system') }
20            dd { $orgs->count }
21    
22            my $people = A3C::Model::PersonCollection->new;
23            $people->unlimit;
24    
25            dt { _('Number of persons in system') }
26            dd { $people->count }
27    
28            my $sql = A3C::SQL->new({ query => qq{
29                    select count(uid),l
30                    from organizations
31                    inner join towns on towns.name = l
32                    group by l
33                    order by count desc
34                    limit 25
35            }});
36    
37            dt { _('Top %1 towns by schools', $sql->count) }
38            dd {
39                    ul {
40                            while ( my $row = $sql->next ) {
41                                    li { outs_raw( $row->count, ' ', $row->l ) }
42                            }
43                    }
44            }
45    
 template '/skole' => page {  
         h1 { _('Schools in system') };  
         show 'skole_sve';  
46  };  };
47    
48  private template 'skole_sve' => sub {  
49    template 'ldap' => page {
50            h1 { _('LDAP data about Schools in system') };
51          my $ldap = A3C::LDAP->new;          my $ldap = A3C::LDAP->new;
52          div {          div {
53                  $ldap->search(                  $ldap->search(
# Line 36  private template 'skole_sve' => sub { Line 69  private template 'skole_sve' => sub {
69          }          }
70  };  };
71    
72    template 'people' => page {
73            
74            h1 { _('Find people') }
75    
76            my $action = new_action(
77                    class   => 'SearchPerson',
78                    moniker => 'search-users',
79                    sticky_on_success => 1,
80                    sticky_on_failure => 1,
81            );
82    
83    
84            form {
85                    render_action( $action => [ 'uid_contains', 'cn_contains' ] );
86                    form_submit( label => _('Find someone') );
87            };
88    
89    #       warn dump( $action->result->content );
90    
91            if ( my $search = $action->result->content('search') ) {
92                    div { sprintf(_('Found %d results'), $search->count ) }
93                    ol {
94                            while (my $user = $search->next) {
95                                    li {
96                                            span { $user->cn }
97                                            tt { $user->uid }
98                                    }
99                            }
100                    }
101            }
102    
103    };
104    
105    template 'sync' => page {
106    
107            h1 { _('Sync school from LDAP') }
108    
109            my $action = new_action(
110                    class   => 'SyncOrganization',
111                    moniker => 'sync-organization'
112            );
113    
114            form {
115                    render_action( $action => [ 'cn' ] );
116                    form_submit( label => _('Sync Organization') );
117            };
118    
119            if ( my $users = $action->result->content('synced-users') ) {
120                    ol {
121                            while (my $user = $users->next) {
122                                    li {
123                                            span { $user->cn }
124                                            tt { { class is 'email' } '<' . $user->mail . '>' }
125                                    }
126                            }
127                    }
128            }
129    
130    };

Legend:
Removed from v.41  
changed lines
  Added in v.79

  ViewVC Help
Powered by ViewVC 1.1.26