add dynamic values to sms.html

This commit is contained in:
fram3d 2023-10-03 22:03:13 +02:00
parent 05bc3112d6
commit a872c70e93
Signed by: fram3d
GPG Key ID: 938920E709EEA32A
3 changed files with 9 additions and 4 deletions

View File

@ -7,3 +7,4 @@ Web app for tracking current ticket numbers
- keep all ticket numbers and timestamps in SQL table "tickets"
- display last ticket number
- don't allow tickets that are out of probable ticket number range
- if last submited ticket is timestamped more then 90 minutes ago, try to predict the next number

View File

@ -1,6 +1,7 @@
from flask import render_template, request, redirect
from freeriders import app, db
from freeriders.models import Ticket
from datetime import datetime
import time
@app.route('/sms', methods=['GET'])
@ -8,7 +9,10 @@ def sms():
if request.method == 'GET':
try:
lastticket = Ticket.query.order_by(Ticket.timestamp.desc()).first()
return render_template('sms.html', ticket = lastticket)
date = datetime.now()
datenow = f'{"{:02d}".format(date.day)}.{"{:02d}".format(date.month)}.{date.year}'
timenow = f'{"{:02d}".format(date.hour)}:{"{:02d}".format(date.minute)}:{date.second}'
return render_template('sms.html', ticket = lastticket, date = datenow, time = timenow)
except:
return 'Error retriving last ticket'
else:

View File

@ -20,8 +20,8 @@
U Beogradu, za broj telefona ste kupili
VREMENSKU KARTU OD 90 MINUTA U ZONI A po
ceni od 50 din + osnovna cena poruke,
koja vazi do 03.10.2023, 09:42:54.
Karta broj: 0000343232.
koja vazi do {{ date }}, {{ time }}.
Karta broj: {{ ticket }}.
Placanjem operateru izmirujete dugovanja
za ovu kartu prema JKP Naplata prevozne
usluge Beograd. Sacuvajte ovu poruku.
@ -59,4 +59,4 @@
<div>x</div>
</footer>
</body>
</html>
</html>