diff --git a/README.md b/README.md index 3ed6db5..e50abf1 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/freeriders/routes.py b/freeriders/routes.py index 3ec91b8..e21eca6 100644 --- a/freeriders/routes.py +++ b/freeriders/routes.py @@ -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: diff --git a/freeriders/templates/sms.html b/freeriders/templates/sms.html index 0e80b0b..ae07217 100644 --- a/freeriders/templates/sms.html +++ b/freeriders/templates/sms.html @@ -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 @@
x
- \ No newline at end of file +