diff options
author | Daniel Friesel <derf@finalrewind.org> | 2019-04-04 18:26:53 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2019-04-04 18:26:53 +0200 |
commit | e2598df25ba089bbdef12777048ba68b7b119926 (patch) | |
tree | 6e0d8293729f527c26acce193e50b435fe18feca /lib/Travelynx/Controller/Traveling.pm | |
parent | b0ad209a234ffb447ac56b89be6e43a3ecec4ae7 (diff) |
Allow journey deletion
See issue #3
Diffstat (limited to 'lib/Travelynx/Controller/Traveling.pm')
-rwxr-xr-x | lib/Travelynx/Controller/Traveling.pm | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm index bf61741..a83adb0 100755 --- a/lib/Travelynx/Controller/Traveling.pm +++ b/lib/Travelynx/Controller/Traveling.pm @@ -175,6 +175,26 @@ sub log_action { ); } } + elsif ( $params->{action} eq 'delete' ) { + my ( $from, $to ) = split( qr{,}, $params->{ids} ); + my $error = $self->delete_journey( $from, $to, $params->{checkin}, + $params->{checkout} ); + if ($error) { + $self->render( + json => { + success => 0, + error => $error, + }, + ); + } + else { + $self->render( + json => { + success => 1, + }, + ); + } + } else { $self->render( json => { @@ -312,7 +332,7 @@ sub journey_details { my ($self) = @_; my ( $uid, $checkout_id ) = split( qr{-}, $self->stash('id') ); - if ( not ($uid == $self->current_user->{id} and $checkout_id)) { + if ( not( $uid == $self->current_user->{id} and $checkout_id ) ) { $self->render( 'journey', error => 'notfound', @@ -322,11 +342,14 @@ sub journey_details { } my @journeys = $self->get_user_travels( - uid => $uid, - checkout_id => $checkout_id, - verbose => 1, + uid => $uid, + checkout_id => $checkout_id, + verbose => 1, ); - if ( @journeys == 0 or not $journeys[0]{completed} or $journeys[0]{ids}[1] != $checkout_id) { + if ( @journeys == 0 + or not $journeys[0]{completed} + or $journeys[0]{ids}[1] != $checkout_id ) + { $self->render( 'journey', error => 'notfound', |