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

Annotation of /lib/A3C/View.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 208 - (hide annotations)
Thu Jun 19 21:24:26 2008 UTC (15 years, 10 months ago) by dpavlin
File size: 2670 byte(s)
another round of re-factoring

- re-organize LDAP-related pages under /ldap with new view A3C::View::LDAP
- move record multi-value support into A3C::Record
- document multi-value solution which started it all
1 dpavlin 37 package A3C::View;
2    
3     use strict;
4     use warnings;
5    
6     use Jifty::View::Declare -base;
7     use A3C::LDAP;
8 dpavlin 79 use A3C::SQL;
9 dpavlin 37
10     use Data::Dump qw/dump/;
11    
12 dpavlin 165 private template 'menu' => sub {
13     div {
14     attr { id => "navigation" };
15     Jifty->web->navigation->render_as_classical_menu;
16     };
17     };
18    
19    
20 dpavlin 72 template '/' => page {
21 dpavlin 37
22 dpavlin 72 h1 { _('Statistics') }
23    
24 dpavlin 120 my $orgs = A3C::Model::hrEduOrgCollection->new;
25 dpavlin 72 $orgs->unlimit;
26    
27     dt { _('Number of schools in system') }
28     dd { $orgs->count }
29    
30 dpavlin 120 my $people = A3C::Model::hrEduPersonCollection->new;
31 dpavlin 72 $people->unlimit;
32    
33     dt { _('Number of persons in system') }
34     dd { $people->count }
35    
36 dpavlin 83 my $by_towns = A3C::SQL->new({ query => qq{
37 dpavlin 79 select count(uid),l
38 dpavlin 120 from hr_edu_orgs
39 dpavlin 79 inner join towns on towns.name = l
40     group by l
41     order by count desc
42     limit 25
43     }});
44 dpavlin 72
45 dpavlin 83 dt { _('Top %1 towns by schools', $by_towns->count) }
46 dpavlin 72 dd {
47     ul {
48 dpavlin 83 while ( my $row = $by_towns->next ) {
49 dpavlin 79 li { outs_raw( $row->count, ' ', $row->l ) }
50 dpavlin 72 }
51     }
52     }
53    
54 dpavlin 83 my $by_county = A3C::SQL->new({ query => qq{
55     select
56     count(uid) as schools,
57     county,
58     count(distinct municipality) as municipalities
59 dpavlin 120 from hr_edu_orgs
60 dpavlin 83 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 dpavlin 72 };
81    
82    
83 dpavlin 71 template 'people' => page {
84    
85     h1 { _('Find people') }
86 dpavlin 49
87     my $action = new_action(
88 dpavlin 122 class => 'SearchhrEduPerson',
89 dpavlin 71 moniker => 'search-users',
90     sticky_on_success => 1,
91     sticky_on_failure => 1,
92 dpavlin 49 );
93    
94 dpavlin 71
95 dpavlin 49 form {
96     render_action( $action => [ 'uid_contains', 'cn_contains' ] );
97 dpavlin 155 form_submit( label => _('Search') );
98 dpavlin 49 };
99    
100     # warn dump( $action->result->content );
101    
102     if ( my $search = $action->result->content('search') ) {
103 dpavlin 155 div { _('Found %1 results', $search->count ) }
104 dpavlin 149 table {
105 dpavlin 49 while (my $user = $search->next) {
106 dpavlin 149 row {
107     cell { $user->cn }
108     cell { tt { $user->uid } }
109     cell { tt { $user->hrEduPersonUniqueID } }
110     cell { $user->hrEduPersonHomeOrg }
111 dpavlin 49 }
112     }
113     }
114     }
115    
116     };
117    
118 dpavlin 125 # mount other views
119     use A3C::View::Organization;
120    
121     # we can't really use following form because Jifty would upper case first
122     # letter of model and try to find A3C::Model::HrEduOrg which doesn't exit!
123     #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 dpavlin 208 use A3C::View::LDAP;
129     alias A3C::View::LDAP under '/ldap';
130    
131 dpavlin 142 use A3C::View::Strix;
132     alias A3C::View::Strix under '/strix';
133    
134 dpavlin 125 1;

  ViewVC Help
Powered by ViewVC 1.1.26