Change proof storage to have a settable folder

This commit is contained in:
Tom Bloor 2017-04-21 19:54:28 +01:00
parent 8c424c02d3
commit 4c5f27976c
8 changed files with 56 additions and 183 deletions

View file

@ -92,7 +92,6 @@ sub post_admin_merge {
my $target_org = $valid_org_rs->find( $validation->param('target_organisation_id') );
$c->copy_transactions_and_delete( $pending_org, $target_org );
#FIXME This requires mutual exclusion.
return $c->render(
json => {
@ -113,7 +112,7 @@ sub copy_transactions_and_delete {
'transactions', {
buyeruserid_fk => $from_org_transaction->buyeruserid_fk,
valuemicrocurrency => $from_org_transaction->valuemicrocurrency,
proofimage => $from_org_transaction->proofimage,
proof_image => $from_org_transaction->proof_image,
timedatesubmitted => $from_org_transaction->timedatesubmitted,
}
);

View file

@ -113,12 +113,9 @@ sub post_upload {
return $c->api_validation_error if $validation->has_error;
my $transaction_value = $validation->param('transaction_value');
my $upload = $validation->param('file');
my $file = $validation->param('file');
my $ext = '.jpg';
my $uuid = Data::UUID->new->create_str;
my $filename = $uuid . $ext;
my $file = $c->store_file_from_upload( $upload );
if ( $type == 1 ) {
# Validated organisation
@ -126,44 +123,24 @@ sub post_upload {
buyeruserid_fk => $user->id,
sellerorganisationid_fk => $validation->param('organisation_id'),
valuemicrocurrency => $transaction_value,
proofimage => $filename,
proof_image => $file,
timedatesubmitted => DateTime->now,
});
$file->move_to('images/' . $filename);
} elsif ( $type == 2 ) {
# Unvalidated Organisation
$c->schema->resultset('PendingTransaction')->create({
buyeruserid_fk => $user->id,
pendingsellerorganisationid_fk => $validation->param('organisation_id'),
valuemicrocurrency => $transaction_value,
proofimage => $filename,
proof_image => $file,
timedatesubmitted => DateTime->now,
});
$file->move_to('images/' . $filename);
} elsif ( $type == 3 ) {
my $organisation_name = $validation->param('organisation_name');
my $street_name = $validation->param('street_name');
my $town = $validation->param('town');
my $postcode = $validation->param('postcode');
my $fullAddress = "";
if ( defined $street_name && ! ($street_name =~ m/^\s*$/) ){
$fullAddress = $street_name;
}
if ( defined $town && ! ($town =~ m/^\s*$/) ){
if ($fullAddress eq ""){
$fullAddress = $town;
}
else{
$fullAddress = $fullAddress . ", " . $town;
}
}
my $pending_org = $c->schema->resultset('PendingOrganisation')->create({
submitted_by => $user,
submitted_at => DateTime->now,
@ -177,11 +154,9 @@ sub post_upload {
buyeruserid_fk => $user->id,
pendingsellerorganisationid_fk => $pending_org->id,
valuemicrocurrency => $transaction_value,
proofimage => $filename,
proof_image => $file,
timedatesubmitted => DateTime->now,
});
$file->move_to('images/' . $filename);
}
return $self->render( json => {
success => Mojo::JSON->true,