Fixed bug where generate mailing would generate two mailings before even saving the form.
This commit is contained in:
parent
ed0398a2c0
commit
87139a7498
2 changed files with 113 additions and 45 deletions
|
|
@ -421,7 +421,7 @@ sub www_edit {
|
|||
|
||||
return $session->privilege->insufficient unless $self->admin->canManage;
|
||||
|
||||
my $f = WebGUI::HTMLForm->new( $session );
|
||||
my $f = $self->getEditForm;
|
||||
$f->hidden(
|
||||
name => 'newsletter',
|
||||
value => 'mailing',
|
||||
|
|
@ -435,6 +435,16 @@ sub www_edit {
|
|||
value => $self->getId,
|
||||
);
|
||||
|
||||
return $self->renderInConsole( $f->print, $i18n->get('configure mailing') );
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
sub getEditForm {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $i18n = WebGUI::International->new( $session, 'MailingManager' );
|
||||
my $f = WebGUI::HTMLForm->new( $session );
|
||||
|
||||
my %fields = %{ $self->getAsset->getMailingProperties( $self ) };
|
||||
my $configuration = $self->get('configuration') || {};
|
||||
while ( my( $name, $properties ) = each %fields ) {
|
||||
|
|
@ -463,7 +473,7 @@ sub www_edit {
|
|||
extras => qq{onclick="window.location='$cancelUrl'" class="backwardButton"},
|
||||
);
|
||||
|
||||
return $self->renderInConsole( $f->print, $i18n->get('configure mailing') );
|
||||
return $f;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ sub www_createMailing {
|
|||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $form = $session->form;
|
||||
my $i18n = WebGUI::International->new( $session, 'MailingManager' );
|
||||
|
||||
return $session->privilege->insufficient unless $self->canManage;
|
||||
|
||||
|
|
@ -123,7 +124,64 @@ sub www_createMailing {
|
|||
state => 'idle',
|
||||
} );
|
||||
|
||||
return $mailing->www_edit;
|
||||
my $f = $mailing->getEditForm;
|
||||
$f->hidden(
|
||||
name => 'newsletter',
|
||||
value => 'manage',
|
||||
);
|
||||
$f->hidden(
|
||||
name => 'func',
|
||||
value => 'createMailingSave',
|
||||
);
|
||||
$f->hidden(
|
||||
name => 'assetId',
|
||||
value => $assetId,
|
||||
);
|
||||
$f->hidden(
|
||||
name => 'issueId',
|
||||
value => $issueId,
|
||||
);
|
||||
|
||||
my $output = $mailing->renderInConsole( $f->print, $i18n->get('configure mailing') );
|
||||
$mailing->delete;
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
sub www_createMailingSave {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $form = $session->form;
|
||||
my $i18n = WebGUI::International->new( $session, 'MailingManager' );
|
||||
|
||||
return $session->privilege->insufficient unless $self->canManage;
|
||||
|
||||
my $assetId = $form->guid( 'assetId' );
|
||||
my $issueId = $form->guid( 'issueId' );
|
||||
|
||||
# Sanity check: does assetId exist?
|
||||
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId )
|
||||
|| return "Error: Asset [$assetId] could not be instanciated";
|
||||
|
||||
# Sanity check: is asset mailable?
|
||||
unless ( $asset->isa( 'WebGUI::AssetAspect::Mailable' ) ) {
|
||||
return "Error: Asset [$assetId] is not Mailable";
|
||||
}
|
||||
|
||||
# Sanity check: does issue exist?
|
||||
my $issue = WebGUI::Asset->newByDynamicClass( $session, $issueId )
|
||||
|| return "Error: issue [$issueId] for asset [$assetId] could not be instanciated.";
|
||||
|
||||
# All ok, create mailing.
|
||||
require WebGUI::Mailing;
|
||||
my $mailing = WebGUI::Mailing->create( $session, {
|
||||
assetId => $assetId,
|
||||
issueId => $issueId,
|
||||
state => 'idle',
|
||||
} );
|
||||
|
||||
return $mailing->www_editSave;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue