optionally show journey comment in public user status

Closes #19
This commit is contained in:
Daniel Friesel 2019-12-06 21:42:26 +01:00
parent 094c536eb4
commit fb126c6928
7 changed files with 41 additions and 10 deletions

View file

@ -65,7 +65,7 @@ sub register {
my $password2 = $self->req->param('password2'); my $password2 = $self->req->param('password2');
my $ip = $self->req->headers->header('X-Forwarded-For'); my $ip = $self->req->headers->header('X-Forwarded-For');
my $ua = $self->req->headers->user_agent; my $ua = $self->req->headers->user_agent;
my $date = DateTime->now( time_zone => 'Europe/Berlin' ) my $date = DateTime->now( time_zone => 'Europe/Berlin' )
->strftime('%d.%m.%Y %H:%M:%S %z'); ->strftime('%d.%m.%Y %H:%M:%S %z');
# In case Mojolicious is not running behind a reverse proxy # In case Mojolicious is not running behind a reverse proxy
@ -221,13 +221,20 @@ sub privacy {
else { else {
$public_level &= ~0x02; $public_level &= ~0x02;
} }
if ( $self->param('public_comment') ) {
$public_level |= 0x04;
}
else {
$public_level &= ~0x04;
}
$self->set_privacy( $user->{id}, $public_level ); $self->set_privacy( $user->{id}, $public_level );
$self->flash( success => 'privacy' ); $self->flash( success => 'privacy' );
$self->redirect_to('account'); $self->redirect_to('account');
} }
else { else {
$self->param( public_status => $public_level & 0x02 ? 1 : 0 ); $self->param( public_status => $public_level & 0x02 ? 1 : 0 );
$self->param( public_comment => $public_level & 0x04 ? 1 : 0 );
$self->render( 'privacy', name => $user->{name} ); $self->render( 'privacy', name => $user->{name} );
} }
} }
@ -640,7 +647,7 @@ sub json_export {
$self->render( $self->render(
json => { json => {
account => $db->select( 'users', '*', { id => $uid } )->hash, account => $db->select( 'users', '*', { id => $uid } )->hash,
in_transit => [ in_transit => [
$db->select( 'in_transit_str', '*', { user_id => $uid } ) $db->select( 'in_transit_str', '*', { user_id => $uid } )
->hashes->each ->hashes->each

View file

@ -75,9 +75,10 @@ sub user_status {
$self->render( $self->render(
'user_status', 'user_status',
name => $name, name => $name,
journey => $status, public_level => $user->{public_level},
twitter => \%tw_data, journey => $status,
twitter => \%tw_data,
); );
} }
else { else {
@ -97,8 +98,9 @@ sub public_status_card {
my $status = $self->get_user_status( $user->{id} ); my $status = $self->get_user_status( $user->{id} );
$self->render( $self->render(
'_public_status_card', '_public_status_card',
name => $name, name => $name,
journey => $status public_level => $user->{public_level},
journey => $status
); );
} }
else { else {

View file

@ -4,7 +4,7 @@
<i class="material-icons small right sync-failed-marker grey-text" style="display: none;">sync_problem</i> <i class="material-icons small right sync-failed-marker grey-text" style="display: none;">sync_problem</i>
<span class="card-title">Eingecheckt in <%= $journey->{train_type} %> <%= $journey->{train_no} %></span> <span class="card-title">Eingecheckt in <%= $journey->{train_type} %> <%= $journey->{train_no} %></span>
% if ($journey->{comment}) { % if ($journey->{comment}) {
<p><%= $journey->{comment} %>.</p> <p><%= $journey->{comment} %></p>
% } % }
<p> <p>
<div class="center-align countdown" <div class="center-align countdown"

View file

@ -3,6 +3,9 @@
<div class="card-content"> <div class="card-content">
<i class="material-icons small right sync-failed-marker grey-text" style="display: none;">sync_problem</i> <i class="material-icons small right sync-failed-marker grey-text" style="display: none;">sync_problem</i>
<span class="card-title"><%= $name %> ist unterwegs</span> <span class="card-title"><%= $name %> ist unterwegs</span>
% if ($public_level & 0x04 and $journey->{comment}) {
<p>„<%= $journey->{comment} %>“</p>
% }
<p> <p>
% if ($journey->{train_line}) { % if ($journey->{train_line}) {
<div class="center-align"><b><%= $journey->{train_type} %> <%= $journey->{train_line} %></b> <%= $journey->{train_no} %></div> <div class="center-align"><b><%= $journey->{train_type} %> <%= $journey->{train_line} %></b> <%= $journey->{train_no} %></div>

View file

@ -69,6 +69,9 @@
% if ($acc->{is_public} & 0x02) { % if ($acc->{is_public} & 0x02) {
Aktueller Status Aktueller Status
% } % }
% if (($acc->{is_public} & 0x06) == 0x06) {
mit Kommentar
% }
</td> </td>
</tr> </tr>
<tr> <tr>

View file

@ -27,6 +27,22 @@
Wann die letzte Reise beendet wurde, wird bewusst nicht angegeben. Wann die letzte Reise beendet wurde, wird bewusst nicht angegeben.
</div> </div>
</div> </div>
<div class="row">
<div class="input-field col s12">
<label>
%= check_box public_comment => 1
<span>Checkin-Kommentar</span>
</label>
</div>
</div>
<div class="row">
<div class="col s12">
Wenn aktiv, wird in deinem aktuellen Status auch der optionale
Freitext-Kommentar der Zugfahrt gezeigt. Wenn du gerade nicht
eingecheckt bist oder dein aktueller Status nicht öffentlich ist,
hat dieses Feld keine Auswirkungen.
</div>
</div>
<div class="row"> <div class="row">
<div class="col s3 m3 l3"> <div class="col s3 m3 l3">
</div> </div>

View file

@ -1,5 +1,5 @@
<div class="row"> <div class="row">
<div class="col s12 publicstatuscol" data-user="<%= $name %>"> <div class="col s12 publicstatuscol" data-user="<%= $name %>">
%= include '_public_status_card', name => $name, journey => $journey %= include '_public_status_card', name => $name, public_level => $public_level, journey => $journey
</div> </div>
</div> </div>