/[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 165 by dpavlin, Sun Jun 15 22:03:02 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            div {
14                    attr { id => "navigation" };
15                    Jifty->web->navigation->render_as_classical_menu;
16            };
17    };
18    
19    
20    template '/' => page {
21    
22            h1 { _('Statistics') }
23    
24            my $orgs = A3C::Model::hrEduOrgCollection->new;
25            $orgs->unlimit;
26    
27  template '/skole' => page {          dt { _('Number of schools in system') }
28          h1 { _('Schools in system') };          dd { $orgs->count }
29          show 'skole_sve';  
30            my $people = A3C::Model::hrEduPersonCollection->new;
31            $people->unlimit;
32    
33            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  private template 'skole_sve' => sub {  
83    template 'ldap' => page {
84            h1 { _('LDAP data about Schools in system') };
85          my $ldap = A3C::LDAP->new;          my $ldap = A3C::LDAP->new;
86          div {          div {
87                  $ldap->search(                  $ldap->search(
# Line 36  private template 'skole_sve' => sub { Line 103  private template 'skole_sve' => sub {
103          }          }
104  };  };
105    
106  template '/search-users' => page {  template 'people' => page {
107            
108            h1 { _('Find people') }
109    
110          my $action = new_action(          my $action = new_action(
111                  class   => 'SearchUser',                  class   => 'SearchhrEduPerson',
112                  moniker => 'search-users'                  moniker => 'search-users',
113                    sticky_on_success => 1,
114                    sticky_on_failure => 1,
115          );          );
116    
117    
118          form {          form {
119                  render_action( $action => [ 'uid_contains', 'cn_contains' ] );                  render_action( $action => [ 'uid_contains', 'cn_contains' ] );
120                  form_submit( label => _('Find someone') );                  form_submit( label => _('Search') );
121          };          };
122    
123  #       warn dump( $action->result->content );  #       warn dump( $action->result->content );
124    
125          if ( my $search = $action->result->content('search') ) {          if ( my $search = $action->result->content('search') ) {
126                  div { sprintf(_('Found %d results'), $search->count ) }                  div { _('Found %1 results', $search->count ) }
127                  ol {                  table {
128                          while (my $user = $search->next) {                          while (my $user = $search->next) {
129                                  li {                                  row {
130                                          span { $user->cn }                                          cell { $user->cn }
131                                          tt { $user->uid }                                          cell { tt { $user->uid } }
132                                            cell { tt { $user->hrEduPersonUniqueID } }
133                                            cell { $user->hrEduPersonHomeOrg }
134                                  }                                  }
135                          }                          }
136                  }                  }
# Line 64  template '/search-users' => page { Line 138  template '/search-users' => page {
138    
139  };  };
140    
141  template '/sync' => page {  template 'sync' => page {
142    
143            h1 { _('Sync school from LDAP') }
144    
145          my $action = new_action(          my $action = new_action(
146                  class   => 'SyncOrganization',                  class   => 'SyncOrganization',
# Line 72  template '/sync' => page { Line 148  template '/sync' => page {
148          );          );
149    
150          form {          form {
151                  render_action( $action => [ 'cn' ] );                  render_action( $action => [ 'org_uid' ] );
152                  form_submit( label => _('Sync Organization') );                  form_submit( label => _('Sync Organization') );
153          };          };
154    
# Line 81  template '/sync' => page { Line 157  template '/sync' => page {
157                          while (my $user = $users->next) {                          while (my $user = $users->next) {
158                                  li {                                  li {
159                                          span { $user->cn }                                          span { $user->cn }
160                                          tt { '<' . $user->mail . '>' }                                          tt { { class is 'email' } '<' . $user->mail . '>' }
161                                  }                                  }
162                          }                          }
163                  }                  }
164          }          }
165    
166  };  };
167    
168    # mount other views
169    use A3C::View::Organization;
170    
171    # we can't really use following form because Jifty would upper case first
172    # letter of model and try to find A3C::Model::HrEduOrg which doesn't exit!
173    #Jifty::View::Declare::CRUD->mount_view('hrEduOrg', 'A3C::View::Organization', '/organizations');
174    alias A3C::View::Organization under '/organizations', {
175            object_type => 'hrEduOrg',
176    };
177    
178    use A3C::View::Strix;
179    alias A3C::View::Strix under '/strix';
180    
181    1;

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

  ViewVC Help
Powered by ViewVC 1.1.26