Subversion Repositories oidfminutesapp

[/] [trunk/] [lib/] [OIDFMinutes/] [Controller/] [Root.pm] - Rev 4

Compare with Previous | Blame | View Log

package OIDFMinutes::Controller::Root;

use strict;
use warnings;
use base 'Catalyst::Controller';

#
# Sets the actions in this controller to be registered with no prefix
# so they function identically to actions created in MyApp.pm
#
__PACKAGE__->config->{namespace} = '';

=head1 NAME

OIDFMinutes::Controller::Root - Root Controller for OIDFMinutes

=head1 DESCRIPTION

[enter your description here]

=head1 METHODS

=cut

=head2 default

=cut

sub default : Private {
    my ($self, $c) = @_;

    $c->response->status(404);
    $c->stash->{template} = "404.tt";
}

sub index : Private {
    my ($self, $c) = @_;

    $c->stash->{teams} = [$c->model('DB::Team')->all];

    $c->stash->{template} = 'home.tt';
}

sub begin : Private {
    my ($self, $c) = @_;

    if (defined($c->session->{remote_ident})) {
        $c->stash->{remote_ident} = $c->session->{remote_ident};
        $c->stash->{remote_user} = OIDFMinutes::Model::DB::fetch_user_by_ident($c->session->{remote_ident}, $c);
    }
}

sub login : Global {
    my ($self, $c) = @_;

    if ($c->authenticate_openid) {
        $c->session->{remote_ident} = $c->req->{openid_identity}->url;
        $c->res->redirect($c->req->base);
    }
    else {
        if ($c->res->redirect) {
            # Do something magic to make the redirect work.
            # Don't know what this does, but btrott says to do it.
            $c->req->action(undef);
        }
        else {
            $c->stash->{template} = 'login.tt';
        }
    }

}

sub logout : Global {
    my ($self, $c) = @_;

    if ($c->req->method ne 'POST') {
        $c->stash->{template} = 'logout.tt';
    }
    else {
        delete $c->session->{remote_ident};
        $c->res->redirect($c->req->base);
    }
}

sub team : Path("minutes") : Args(1) {
    my ($self, $c, $team_urlname) = @_;

    my $team = OIDFMinutes::Model::DB::fetch_team_by_urlname($team_urlname, $c);

    $c->response->body("Team thing <plaintext>".Data::Dumper::Dumper($team));
}

sub minutes : Local : Args(2) {
    my ($self, $c, $team_urlname, $date) = @_;

    my $minutes = OIDFMinutes::Model::DB::fetch_minutes_by_team_urlname_and_meeting_date($team_urlname. $date, $c);

    $c->response->body("Minutes thing <plaintext>".Data::Dumper::Dumper($minutes));
}

=head2 end

Attempt to render a view, if needed.

=cut

sub end : ActionClass('RenderView') {}

=head1 AUTHOR

Martin Atkins,,,

=head1 LICENSE

This library is free software, you can redistribute it and/or modify
it under the same terms as Perl itself.

=cut

1;

Compare with Previous | Blame