/[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 72 by dpavlin, Thu Apr 10 23:16:56 2008 UTC
# Line 8  use A3C::LDAP; Line 8  use A3C::LDAP;
8    
9  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
10    
11    template '/' => page {
12    
13            h1 { _('Statistics') }
14    
15            my $orgs = A3C::Model::OrganizationCollection->new;
16            $orgs->unlimit;
17    
18            dt { _('Number of schools in system') }
19            dd { $orgs->count }
20    
21            my $people = A3C::Model::PersonCollection->new;
22            $people->unlimit;
23    
24            dt { _('Number of persons in system') }
25            dd { $people->count }
26    
27    =for later
28    
29            dt { _('Breakdown by towns') }
30            dd {
31                    $orgs->redo_search;
32                    # select count(l),l from organizations group by l order by count desc limit 25
33                    $orgs->group_by( column => 'l' );
34                    $orgs->order_by( column => 'l', order => 'desc' );
35    
36                    warn "## SQL: ", $orgs->build_select_query;
37                    my $count = $orgs->column( column => 'l', function => 'count(l)' );
38                    warn "## count: $count\n";
39    #               $orgs->column( column => 'l' );
40                    warn "## SQL: ", $orgs->build_select_query;
41    
42                    ul {
43                            for ( 1 .. 1 ) {
44                                    my $o = $orgs->next;
45                                    warn "## ",dump( $o );
46                                    li { outs ( $o->l, '|', $o->__value('l'), $o->__value( $count ) ) }
47                            }
48                    }
49    
50    
51            }
52    
53    =cut
54    
 template '/skole' => page {  
         h1 { _('Schools in system') };  
         show 'skole_sve';  
55  };  };
56    
57  private template 'skole_sve' => sub {  
58    template 'ldap' => page {
59            h1 { _('LDAP data about Schools in system') };
60          my $ldap = A3C::LDAP->new;          my $ldap = A3C::LDAP->new;
61          div {          div {
62                  $ldap->search(                  $ldap->search(
# Line 36  private template 'skole_sve' => sub { Line 78  private template 'skole_sve' => sub {
78          }          }
79  };  };
80    
81    template 'people' => page {
82            
83            h1 { _('Find people') }
84    
85            my $action = new_action(
86                    class   => 'SearchPerson',
87                    moniker => 'search-users',
88                    sticky_on_success => 1,
89                    sticky_on_failure => 1,
90            );
91    
92    
93            form {
94                    render_action( $action => [ 'uid_contains', 'cn_contains' ] );
95                    form_submit( label => _('Find someone') );
96            };
97    
98    #       warn dump( $action->result->content );
99    
100            if ( my $search = $action->result->content('search') ) {
101                    div { sprintf(_('Found %d results'), $search->count ) }
102                    ol {
103                            while (my $user = $search->next) {
104                                    li {
105                                            span { $user->cn }
106                                            tt { $user->uid }
107                                    }
108                            }
109                    }
110            }
111    
112    };
113    
114    template 'sync' => page {
115    
116            h1 { _('Sync school from LDAP') }
117    
118            my $action = new_action(
119                    class   => 'SyncOrganization',
120                    moniker => 'sync-organization'
121            );
122    
123            form {
124                    render_action( $action => [ 'cn' ] );
125                    form_submit( label => _('Sync Organization') );
126            };
127    
128            if ( my $users = $action->result->content('synced-users') ) {
129                    ol {
130                            while (my $user = $users->next) {
131                                    li {
132                                            span { $user->cn }
133                                            tt { { class is 'email' } '<' . $user->mail . '>' }
134                                    }
135                            }
136                    }
137            }
138    
139    };

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

  ViewVC Help
Powered by ViewVC 1.1.26