Added ability to delete transactions successfully
This commit is contained in:
parent
8034844cec
commit
416ac6343a
3 changed files with 48 additions and 24 deletions
|
@ -189,6 +189,7 @@ sub startup {
|
|||
$admin_routes->get('/transactions')->to('admin-transactions#index');
|
||||
$admin_routes->get('/transactions/:id')->to('admin-transactions#read');
|
||||
$admin_routes->get('/transactions/:id/image')->to('admin-transactions#image');
|
||||
$admin_routes->get('/transactions/:id/delete')->to('admin-transactions#delete');
|
||||
|
||||
# my $user_routes = $r->under('/')->to('root#under');
|
||||
|
||||
|
|
|
@ -48,4 +48,19 @@ sub image {
|
|||
}
|
||||
}
|
||||
|
||||
sub delete {
|
||||
my $c = shift;
|
||||
|
||||
my $id = $c->param('id');
|
||||
|
||||
if ( my $transaction = $c->result_set->find($id) ) {
|
||||
$transaction->delete;
|
||||
$c->flash( success => 'Successfully deleted transaction' );
|
||||
$c->redirect_to( '/admin/transactions' );
|
||||
} else {
|
||||
$c->flash( error => 'No transaction found' );
|
||||
$c->redirect_to( '/admin/transactions' );
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -11,28 +11,36 @@
|
|||
<strong>Success!</strong> <%= $success %>
|
||||
</div>
|
||||
% }
|
||||
<form action="<%= url_for %>" method="post">
|
||||
<div class="form-group">
|
||||
<label for="email">Buyer</label>
|
||||
<input id="buyer" type="text" class="form-control" placeholder="Buyer ID" name="buyer" value="<%= $transaction->buyer->name %>" disabled>
|
||||
<div class="card mb-3">
|
||||
<h3 class="card-header">
|
||||
Transaction Details
|
||||
<a href="<%= url_for . '/delete' %>" class="btn btn-danger" style="float: right">Delete Transaction</a>
|
||||
</h3>
|
||||
<div class="card-block">
|
||||
<form action="<%= url_for %>" method="post">
|
||||
<div class="form-group">
|
||||
<label for="email">Buyer</label>
|
||||
<input id="buyer" type="text" class="form-control" placeholder="Buyer ID" name="buyer" value="<%= $transaction->buyer->name %>" disabled>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">Seller</label>
|
||||
<input id="seller" type="text" class="form-control" placeholder="Seller ID" name="seller" value="<%= $transaction->seller->name %>" disabled>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">Value</label>
|
||||
<input id="value" type="text" class="form-control" placeholder="Value" name="value" value="<%= $transaction->value %>" disabled>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">Submitted At</label>
|
||||
<input id="submitted_at" type="text" class="form-control" placeholder="Submitted At" name="submitted_at" value="<%= $transaction->submitted_at %>" disabled>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">Purchase Time</label>
|
||||
<input id="purchase_time" type="text" class="form-control" placeholder="Purchase Time" name="purchase_time" value="<%= $transaction->purchase_time %>" disabled>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<img src="<%= url_for . '/image' %>"/>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">Seller</label>
|
||||
<input id="seller" type="text" class="form-control" placeholder="Seller ID" name="seller" value="<%= $transaction->seller->name %>" disabled>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">Value</label>
|
||||
<input id="value" type="text" class="form-control" placeholder="Value" name="value" value="<%= $transaction->value %>" disabled>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">Submitted At</label>
|
||||
<input id="submitted_at" type="text" class="form-control" placeholder="Submitted At" name="submitted_at" value="<%= $transaction->submitted_at %>" disabled>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">Purchase Time</label>
|
||||
<input id="purchase_time" type="text" class="form-control" placeholder="Purchase Time" name="purchase_time" value="<%= $transaction->purchase_time %>" disabled>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<img src="<%= url_for . '/image' %>"/>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
Reference in a new issue