Fix issue with approving organisations.
This commit is contained in:
parent
b009fa5c86
commit
9dd808c547
2 changed files with 24 additions and 10 deletions
|
@ -204,8 +204,8 @@ sub startup {
|
|||
submitted_at => $from_org_transaction->submitted_at,
|
||||
}
|
||||
);
|
||||
$from_org_transaction->delete;
|
||||
}
|
||||
|
||||
$from_org->delete;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package Pear::LocalLoop::Controller::Admin::Organisations;
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
|
||||
use Try::Tiny;
|
||||
|
||||
sub list {
|
||||
my $c = shift;
|
||||
|
||||
|
@ -28,15 +30,27 @@ sub pending_read {
|
|||
sub pending_approve {
|
||||
my $c = shift;
|
||||
my $pending_org = $c->schema->resultset('PendingOrganisation')->find( $c->param('id') );
|
||||
my $valid_org = $c->schema->resultset('Organisation')->create({
|
||||
|
||||
my $valid_org;
|
||||
try {
|
||||
$c->schema->storage->txn_do( sub {
|
||||
$valid_org = $c->schema->resultset('Organisation')->create({
|
||||
name => $pending_org->name,
|
||||
street_name => $pending_org->street_name,
|
||||
town => $pending_org->town,
|
||||
postcode => $pending_org->postcode,
|
||||
});
|
||||
$c->copy_transactions_and_delete( $pending_org, $valid_org );
|
||||
} );
|
||||
} finally {
|
||||
if ( @_ ) {
|
||||
$c->flash( error => 'Something went wrong Validating the Organisation' );
|
||||
$c->redirect_to( '/admin/organisations/pending/' . $pending_org->id );
|
||||
} else {
|
||||
$c->flash( success => 'Validated Organisation' );
|
||||
$c->redirect_to( '/admin/organisations/valid/' . $valid_org->id );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
Reference in a new issue