From d9d3aac79200ca7d896d753c897e1651517ecf36 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 19 May 2019 10:32:57 +0200 Subject: allow checkin from connections view --- lib/Travelynx/Controller/Traveling.pm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'lib/Travelynx/Controller') diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm index 3d2bb0c..4e4b069 100755 --- a/lib/Travelynx/Controller/Traveling.pm +++ b/lib/Travelynx/Controller/Traveling.pm @@ -145,6 +145,7 @@ sub log_action { my ( $train, $error ) = $self->checkin( $params->{station}, $params->{train} ); + my $destination = $params->{dest}; if ($error) { $self->render( @@ -154,7 +155,7 @@ sub log_action { }, ); } - else { + elsif ( not $destination ) { $self->render( json => { success => 1, @@ -162,6 +163,19 @@ sub log_action { }, ); } + else { + # Silently ignore errors -- if they are permanent, the user will see + # them when selecting the destination manually. + my ( $still_checked_in, undef ) + = $self->checkout( $destination, 0 ); + my $station_link = '/s/' . $destination; + $self->render( + json => { + success => 1, + redirect_to => $still_checked_in ? '/' : $station_link, + }, + ); + } } elsif ( $params->{action} eq 'checkout' ) { my ( $still_checked_in, $error ) -- cgit v1.2.3