display time since unregistered token was read

This commit is contained in:
Simon Pirkelmann 2021-08-30 21:15:32 +02:00
parent 8a9a667429
commit 8e868f1674
2 changed files with 4 additions and 2 deletions

View File

@ -34,7 +34,7 @@
<h4 class="alert-heading">Unregistrierter Token gelesen:</h4> <h4 class="alert-heading">Unregistrierter Token gelesen:</h4>
<p>Token ID: {{ token['token'] }}</p> <p>Token ID: {{ token['token'] }}</p>
<hr> <hr>
<p class="mb-0">Zeitstempel (UTC): {{ token['timestamp']}}</p> <p class="mb-0">Zeitstempel (UTC): {{ token['timestamp']}} (vor {{ token['timedelta_minutes'] }} Minuten)</p>
</div> </div>
<div class="p-2 bg-light border"> <div class="p-2 bg-light border">

View File

@ -507,8 +507,10 @@ def create_application(config):
recent_token = {} recent_token = {}
if {'token', 'timestamp'}.issubset(set(token.keys())): if {'token', 'timestamp'}.issubset(set(token.keys())):
if token['timestamp'] >= datetime.now() - timedelta(minutes=10): dt = datetime.utcnow() - token['timestamp']
if dt < timedelta(minutes=10):
recent_token = token recent_token = token
recent_token['timedelta_minutes'] = int(dt.total_seconds() / 60.0)
form = TokenForm() form = TokenForm()
if request.method == 'GET': if request.method == 'GET':