Merge branch 'development'

This commit is contained in:
Tom Bloor 2017-08-17 15:39:21 +01:00
commit 0a38102200

View file

@ -146,13 +146,21 @@ sub post_upload {
}); });
} }
unless ( defined $organisation ) {
return $c->render( json => {
success => Mojo::JSON->false,
message => 'Error Finding Organisation',
error => 'organisation_error',
});
}
my $transaction_value = $validation->param('transaction_value'); my $transaction_value = $validation->param('transaction_value');
my $upload = $validation->param('file'); my $upload = $validation->param('file');
my $purchase_time = $c->parse_iso_datetime($validation->param('purchase_time') || ''); my $purchase_time = $c->parse_iso_datetime($validation->param('purchase_time') || '');
$purchase_time ||= DateTime->now(); $purchase_time ||= DateTime->now();
my $file = $c->store_file_from_upload( $upload ); my $file = $c->store_file_from_upload( $upload );
$organisation->create_related( my $new_transaction = $organisation->create_related(
'transactions', 'transactions',
{ {
buyer => $user, buyer => $user,
@ -162,13 +170,20 @@ sub post_upload {
} }
); );
unless ( defined $new_transaction ) {
return $c->render( json => {
success => Mojo::JSON->false,
message => 'Error Adding Transaction',
error => 'transaction_error',
});
}
return $c->render( json => { return $c->render( json => {
success => Mojo::JSON->true, success => Mojo::JSON->true,
message => 'Upload Successful', message => 'Upload Successful',
}); });
} }
# TODO Limit search results, possibly paginate them? # TODO Limit search results, possibly paginate them?
# TODO Search by location as well # TODO Search by location as well
sub post_search { sub post_search {