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,
|
submitted_at => $from_org_transaction->submitted_at,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
$from_org_transaction->delete;
|
||||||
}
|
}
|
||||||
|
|
||||||
$from_org->delete;
|
$from_org->delete;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package Pear::LocalLoop::Controller::Admin::Organisations;
|
package Pear::LocalLoop::Controller::Admin::Organisations;
|
||||||
use Mojo::Base 'Mojolicious::Controller';
|
use Mojo::Base 'Mojolicious::Controller';
|
||||||
|
|
||||||
|
use Try::Tiny;
|
||||||
|
|
||||||
sub list {
|
sub list {
|
||||||
my $c = shift;
|
my $c = shift;
|
||||||
|
|
||||||
|
@ -28,15 +30,27 @@ sub pending_read {
|
||||||
sub pending_approve {
|
sub pending_approve {
|
||||||
my $c = shift;
|
my $c = shift;
|
||||||
my $pending_org = $c->schema->resultset('PendingOrganisation')->find( $c->param('id') );
|
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,
|
name => $pending_org->name,
|
||||||
street_name => $pending_org->street_name,
|
street_name => $pending_org->street_name,
|
||||||
town => $pending_org->town,
|
town => $pending_org->town,
|
||||||
postcode => $pending_org->postcode,
|
postcode => $pending_org->postcode,
|
||||||
});
|
});
|
||||||
$c->copy_transactions_and_delete( $pending_org, $valid_org );
|
$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->flash( success => 'Validated Organisation' );
|
||||||
$c->redirect_to( '/admin/organisations/valid/' . $valid_org->id );
|
$c->redirect_to( '/admin/organisations/valid/' . $valid_org->id );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
Reference in a new issue