package BeerDB::Base;
use base qw/Maypole::Model::CDBI/;
use strict;
use warnings;

# Overide list to add display_columns to cgi  
# Perhaps do this in AsForm?

sub list : Exported {
	use Data::Dumper;
	my ($self, $r) = @_;
	$self->SUPER::list($r);
	my %cols =  map { $_ => 1 } $self->columns, $self->display_columns;
	my @cols = keys %cols;
	$r->template_args->{classmetadata}{cgi} = { $self->to_cgi(@cols) }; 
}


# Template switcheroo bug bit me -- was seeing view page but the view action was never 
# being executed after an edit.
sub do_edit : Exported {
	my ($self, $r) = (shift, shift);
	$self->SUPER::do_edit($r, @_);
	if (my $obj = $r->object) {
		my $url = $r->config->uri_base . "/" . $r->table . "/view/" . $obj->id;
		$r->redirect_request(url => $url);
	}
}

sub metadata: Exported {}
	

1;
