source: LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller/Sites.pm @ 134

Last change on this file since 134 was 134, checked in by nanardon, 15 years ago
  • add site subsection
  • Property svn:keywords set to Id Rev
File size: 1.4 KB
Line 
1package LATMOS::Accounts::Web::Controller::Sites;
2
3use strict;
4use warnings;
5use base 'Catalyst::Controller';
6
7=head1 NAME
8
9LATMOS::Accounts::Web::Controller::Site - Catalyst Controller
10
11=head1 DESCRIPTION
12
13Catalyst Controller.
14
15=head1 METHODS
16
17=cut
18
19
20=head2 index
21
22=cut
23
24sub index : Private {
25    my ( $self, $c ) = @_;
26
27    my $base = $c->model('Accounts')->db;
28    my %filter = map  {
29        $c->req->params->{attr}[$_] && $c->req->params->{attrval}[$_]
30        ? ($c->req->params->{attr}[$_] => $c->req->params->{attrval}[$_])
31        : ()
32    } (0 .. $#{ $c->req->params->{attr} || []});
33    $c->stash->{siteslist} = %filter
34        ? [ $base->search_objects('site', %filter) ]
35        : [ $base->list_objects('site') ];
36}
37
38sub default : LocalPath {
39    my ( $self, $c, undef, $sitename, $subform ) = @_;
40
41    my $base = $c->model('Accounts')->db;
42
43    $c->stash->{sitename} = $sitename;
44    $c->stash->{site} = $base->get_object('site', $sitename);
45    $c->stash->{subform} = $subform || '';
46
47    for ($subform) {
48        # Exceptions...
49        # /^$/ $c->stash->{template} =
50
51        $c->stash->{form} = $c->model('AttrForms', 'site' . $c->stash->{subform}, $c->stash->{site});
52        $c->stash->{form}->set_attrs;
53    }
54}
55
56=head1 AUTHOR
57
58Thauvin Olivier
59
60=head1 LICENSE
61
62This library is free software, you can redistribute it and/or modify
63it under the same terms as Perl itself.
64
65=cut
66
671;
Note: See TracBrowser for help on using the repository browser.