migrate Subscription list code batches to FormBuilder

This commit is contained in:
Doug Bell 2011-01-25 15:36:38 -06:00
parent affafb0038
commit 7b383ec391
2 changed files with 36 additions and 9 deletions

View file

@ -764,13 +764,13 @@ sub www_listSubscriptionCodeBatches {
my $dcStop = $session->datetime->addToTime($session->form->date('dcStop'), 23, 59); my $dcStop = $session->datetime->addToTime($session->form->date('dcStop'), 23, 59);
my $selection = $session->form->process('selection'); my $selection = $session->form->process('selection');
my $f = WebGUI::HTMLForm->new( $session ); my $f = WebGUI::FormBuilder->new( $session, action => $self->getUrl );
$f->hidden( $f->addField( "hidden",
name => 'func', name => 'func',
value => 'listSubscriptionCodeBatches', value => 'listSubscriptionCodeBatches',
); );
$f->readOnly( $f->addField( "readOnly",
label => label =>
WebGUI::Form::radio( $session, { name => 'selection', value => 'dc', checked => ($selection eq 'dc') } ) WebGUI::Form::radio( $session, { name => 'selection', value => 'dc', checked => ($selection eq 'dc') } )
. $i18n->get('selection created'), . $i18n->get('selection created'),
@ -779,13 +779,13 @@ sub www_listSubscriptionCodeBatches {
. ' ' . $i18n->get( 'and' ) . ' ' . ' ' . $i18n->get( 'and' ) . ' '
. WebGUI::Form::date( $session, { name => 'dcStop', value=> $dcStop } ), . WebGUI::Form::date( $session, { name => 'dcStop', value=> $dcStop } ),
); );
$f->readOnly( $f->addField( "readOnly",
label => label =>
WebGUI::Form::radio( $session, { name => 'selection', value => 'all', checked => ($selection ne 'dc') } ) WebGUI::Form::radio( $session, { name => 'selection', value => 'all', checked => ($selection ne 'dc') } )
. $i18n->get('display all'), . $i18n->get('display all'),
value => '', value => '',
); );
$f->submit( $f->addField( "submit",
value => $i18n->get('select'), value => $i18n->get('select'),
); );
@ -804,7 +804,7 @@ sub www_listSubscriptionCodeBatches {
# Fetch the list of batches at the current paginition index # Fetch the list of batches at the current paginition index
my $batches = $p->getPageData; my $batches = $p->getPageData;
my $output = $f->print; my $output = $f->toHtml;
$output .= $p->getBarTraditional($session->form->process("pn")); $output .= $p->getBarTraditional($session->form->process("pn"));
$output .= '<table border="1" cellpadding="5" cellspacing="0" align="center">'; $output .= '<table border="1" cellpadding="5" cellspacing="0" align="center">';
foreach my $batch ( @{$batches} ) { foreach my $batch ( @{$batches} ) {
@ -826,7 +826,7 @@ sub www_listSubscriptionCodeBatches {
$output = $i18n->get('no subscription code batches') unless $session->db->quickScalar('select count(*) from Subscription_codeBatch'); $output = $i18n->get('no subscription code batches') unless $session->db->quickScalar('select count(*) from Subscription_codeBatch');
return $self->getAdminConsoleWithSubmenu->render( $output, $i18n->get('manage batches') ); return $output;
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------

View file

@ -35,7 +35,7 @@ WebGUI::Test->addToCleanup($user);
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# Tests # Tests
plan tests => 9; # Increment this number for each test you create plan tests => 16; # Increment this number for each test you create
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# put your tests here # put your tests here
@ -126,7 +126,34 @@ cmp_deeply( $codes,
); );
#----------------------------------------------------------------------------
# www_listSubscriptionCodeBatches
my $mech = WebGUI::Test::Mechanize->new( config => WebGUI::Test->file );
$mech->get_ok( '/' );
$mech->session->user({ userId => 3 });
# Add another code for the selection
$session->db->setRow( 'Subscription_codeBatch', 'batchId', {
batchId => 'new',
name => "Fired!",
description => "Sign up to get fired!",
subscriptionId => $sku->getId,
expirationDate => 3600 * 24 * 7,
dateCreated => time+1500,
});
$mech->get_ok( $sku->getUrl( 'func=listSubscriptionCodeBatches' ) );
$mech->text_contains( "Sign up to get your paycheck!" );
$mech->text_contains( "Sign up to get fired!" );
$mech->submit_form_ok( {
fields => {
selection => "dc",
dcStart => time+1000,
dcStop => time+2000,
},
}, 'limit subscription code batches' );
$mech->content_lacks( "Sign up to get your paycheck!" );
$mech->text_contains( "Sign up to get fired!" );