/[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

Contents of /lib/A3C/View.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 72 - (show annotations)
Thu Apr 10 23:16:56 2008 UTC (11 years, 9 months ago) by dpavlin
File size: 2631 byte(s)
index page with non-working group by query
1 package A3C::View;
2
3 use strict;
4 use warnings;
5
6 use Jifty::View::Declare -base;
7 use A3C::LDAP;
8
9 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
55 };
56
57
58 template 'ldap' => page {
59 h1 { _('LDAP data about Schools in system') };
60 my $ldap = A3C::LDAP->new;
61 div {
62 $ldap->search(
63 base => 'dc=skole,dc=hr',
64 filter => '(objectClass=hrEduOrg)',
65 sizelimit => 10,
66 );
67 while ( my $entry = $ldap->current_search->shift_entry ) {
68 #warn $entry->dump;
69 ul {
70 foreach my $attr ( $entry->attributes ) {
71 li {
72 tt { $attr }
73 span { dump( $entry->get_value( $attr ) ) }
74 }
75 }
76 }
77 }
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 };

  ViewVC Help
Powered by ViewVC 1.1.26