diff options
author | Daniel Friesel <derf@finalrewind.org> | 2023-03-04 09:03:50 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2023-03-04 09:03:50 +0100 |
commit | e1231b88e2dd989dea0ce97d2b28d7e895cbfeaa (patch) | |
tree | 0d08bdf243f85b0efbaab23aebfeb988559672ec | |
parent | 9abdaefaf59a4edc169419fb66bec237a29b9189 (diff) |
status/profile: re-add ability to show latest checkout, if desired1.30.1
got lost in 1.30.0
-rwxr-xr-x | lib/Travelynx.pm | 4 | ||||
-rw-r--r-- | lib/Travelynx/Controller/Account.pm | 4 | ||||
-rwxr-xr-x | lib/Travelynx/Controller/Traveling.pm | 27 | ||||
-rwxr-xr-x | lib/Travelynx/Model/Journeys.pm | 10 | ||||
-rw-r--r-- | lib/Travelynx/Model/Users.pm | 4 | ||||
-rw-r--r-- | templates/_public_status_card.html.ep | 11 | ||||
-rw-r--r-- | templates/privacy.html.ep | 10 |
7 files changed, 64 insertions, 6 deletions
diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index 6d903e6..f182358 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -1609,7 +1609,7 @@ sub startup { my ( $latest, $latest_cancellation ) = $self->journeys->get_latest( uid => $uid, - db => $db + db => $db, ); if ( $latest_cancellation and $latest_cancellation->{cancelled} ) { @@ -1675,6 +1675,8 @@ sub startup { arr_name => $latest->{arr_name}, arr_platform => $latest->{arr_platform}, comment => $latest->{user_data}{comment}, + visibility => $latest->{visibility}, + visibility_str => $latest->{visibility_str}, }; } diff --git a/lib/Travelynx/Controller/Account.pm b/lib/Travelynx/Controller/Account.pm index e8bfcaf..4836117 100644 --- a/lib/Travelynx/Controller/Account.pm +++ b/lib/Travelynx/Controller/Account.pm @@ -463,7 +463,8 @@ sub privacy { $opt{comments_visible} = $self->param('public_comment') ? 1 : 0; - $opt{past_all} = $self->param('history_age') eq 'infinite' ? 1 : 0; + $opt{past_all} = $self->param('history_age') eq 'infinite' ? 1 : 0; + $opt{past_status} = $self->param('past_status') ? 1 : 0; if ( $self->param('history_level') eq 'intern' ) { $opt{past_visible} = 1; @@ -493,6 +494,7 @@ sub privacy { : 'private' ); $self->param( history_age => $user->{past_all} ? 'infinite' : 'month' ); + $self->param( past_status => $user->{past_status} ); $self->render( 'privacy', name => $user->{name} ); } } diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm index 8cf1722..80768ce 100755 --- a/lib/Travelynx/Controller/Traveling.pm +++ b/lib/Travelynx/Controller/Traveling.pm @@ -570,7 +570,7 @@ sub user_status { ); my $visibility; - if ( $status->{checked_in} ) { + if ( $status->{checked_in} or $status->{arr_name} ) { $visibility = $self->compute_effective_visibility( $user->{default_visibility_str}, @@ -589,8 +589,15 @@ sub user_status { ) { $status->{checked_in} = 0; + $status->{arr_name} = undef; } } + if ( not $status->{checked_in} + and $status->{arr_name} + and not $user->{past_status} ) + { + $status->{arr_name} = undef; + } if ( $status->{checked_in} ) { $og_data{url} .= '/' . $status->{sched_departure}->epoch; @@ -640,7 +647,7 @@ sub public_profile { my $status = $self->get_user_status( $user->{id} ); my $visibility; - if ( $status->{checked_in} ) { + if ( $status->{checked_in} or $status->{arr_name} ) { $visibility = $self->compute_effective_visibility( $user->{default_visibility_str}, @@ -659,8 +666,15 @@ sub public_profile { ) { $status->{checked_in} = 0; + $status->{arr_name} = undef; } } + if ( not $status->{checked_in} + and $status->{arr_name} + and not $user->{past_status} ) + { + $status->{arr_name} = undef; + } my %opt = ( uid => $user->{id}, @@ -855,7 +869,7 @@ sub public_status_card { my $status = $self->get_user_status( $user->{id} ); my $visibility; - if ( $status->{checked_in} ) { + if ( $status->{checked_in} or $status->{arr_name} ) { $visibility = $self->compute_effective_visibility( $user->{default_visibility_str}, @@ -874,8 +888,15 @@ sub public_status_card { ) { $status->{checked_in} = 0; + $status->{arr_name} = undef; } } + if ( not $status->{checked_in} + and $status->{arr_name} + and not $user->{past_status} ) + { + $status->{arr_name} = undef; + } $self->render( '_public_status_card', diff --git a/lib/Travelynx/Model/Journeys.pm b/lib/Travelynx/Model/Journeys.pm index 0062642..312910f 100755 --- a/lib/Travelynx/Model/Journeys.pm +++ b/lib/Travelynx/Model/Journeys.pm @@ -720,6 +720,11 @@ sub get_latest { } )->expand->hash; + $latest_successful->{visibility_str} + = $latest_successful->{visibility} + ? $visibility_itoa{ $latest_successful->{visibility} } + : 'default'; + my $latest = $db->select( 'journeys_str', '*', @@ -732,6 +737,11 @@ sub get_latest { } )->expand->hash; + $latest->{visibility_str} + = $latest->{visibility} + ? $visibility_itoa{ $latest->{visibility} } + : 'default'; + return ( $latest_successful, $latest ); } diff --git a/lib/Travelynx/Model/Users.pm b/lib/Travelynx/Model/Users.pm index 397b618..1ffd7ab 100644 --- a/lib/Travelynx/Model/Users.pm +++ b/lib/Travelynx/Model/Users.pm @@ -178,6 +178,7 @@ sub get_privacy_by_name { comments_visible => $user->{public_level} & 0x80 ? 1 : 0, past_visible => ( $user->{public_level} & 0x300 ) >> 8, past_all => $user->{public_level} & 0x400 ? 1 : 0, + past_status => $user->{public_level} & 0x800 ? 1 : 0, }; } return; @@ -194,7 +195,7 @@ sub set_privacy { = ( $opt{default_visibility} & 0x7f ) | ( $opt{comments_visible} ? 0x80 : 0x00 ) | ( ( ( $opt{past_visible} // 0 ) << 8 ) & 0x300 ) - | ( $opt{past_all} ? 0x400 : 0 ); + | ( $opt{past_all} ? 0x400 : 0 ) | ( $opt{past_status} ? 0x800 : 0 ); } $db->update( 'users', { public_level => $public_level }, { id => $uid } ); @@ -376,6 +377,7 @@ sub get { comments_visible => $user->{public_level} & 0x80 ? 1 : 0, past_visible => ( $user->{public_level} & 0x300 ) >> 8, past_all => $user->{public_level} & 0x400 ? 1 : 0, + past_status => $user->{public_level} & 0x800 ? 1 : 0, email => $user->{email}, sb_name => $user->{external_services} ? $sb_templates[ $user->{external_services} & 0x07 ][0] diff --git a/templates/_public_status_card.html.ep b/templates/_public_status_card.html.ep index cb0fb0d..915efdc 100644 --- a/templates/_public_status_card.html.ep +++ b/templates/_public_status_card.html.ep @@ -173,6 +173,17 @@ <i class="material-icons small right sync-failed-marker grey-text" style="display: none;">sync_problem</i> <span class="card-title"><%= $name %> ist gerade nicht eingecheckt</span> <p> + % if ($journey->{arr_name}) { + Zuletzt gesehen + % if ($journey->{real_arrival}->epoch and ($public_level & 0x20 or ($public_level & 0x10 and is_user_authenticated()))) { + %= $journey->{real_arrival}->strftime('am %d.%m.%Y') + in <b><%= $journey->{arr_name} %></b> + %= $journey->{real_arrival}->strftime('(Ankunft um %H:%M Uhr)') + % } + % else { + in <b><%= $journey->{arr_name} %></b> + % } + % } </p> </div> </div> diff --git a/templates/privacy.html.ep b/templates/privacy.html.ep index 2929c73..9222591 100644 --- a/templates/privacy.html.ep +++ b/templates/privacy.html.ep @@ -65,6 +65,16 @@ </div> </div> <div class="row"> + <div class="input-field col s12"> + <div> + <label> + %= check_box past_status => 1 + <span>Wenn nicht eingecheckt: letztes Fahrtziel unter <a href="/status/<%= $name %>">/status/<%= $name %></a> zeigen, sofern die zugehörige Reise für die aufrufende Person sichtbar ist. Caveat: Die derzeitige Implementierung dieses Features gibt preis, ob deine letzte Fahrt öffentlich / lokal sichtbar war (→ Ziel angegeben) oder nicht (→ kein Ziel angegeben).</span> + </label> + </div> + </div> + </div> + <div class="row"> <div class="col s12"> Wenn du (mit passender Sichtbarkeit) eingecheckt bist, werden unter <a href="/status/<%= $name %>">/status/<%= $name %></a> sowie <a |