From 691e35c22c615f8ea982b071c374fe7bf64011d1 Mon Sep 17 00:00:00 2001 From: pluja Date: Sat, 10 Oct 2020 22:31:33 +0200 Subject: [PATCH] Adds a status page --- app/routes.py | 17 ++++++--------- app/templates/status.html | 46 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 10 deletions(-) create mode 100644 app/templates/status.html diff --git a/app/routes.py b/app/routes.py index f96a6e1..2db22a8 100644 --- a/app/routes.py +++ b/app/routes.py @@ -744,20 +744,17 @@ def register(): return render_template('register.html', title='Register', registrations=REGISTRATIONS, form=form, config=config) -@app.route('/registrations_status/icon') -def registrations_status_icon(): +@app.route('/status') +def status(): count = db.session.query(User).count() if count >= config['maxInstanceUsers'] or config['maxInstanceUsers'] == 0: - return redirect(url_for('static', filename='img/close.png')) + filen = url_for('static', filename='img/close.png') + caniregister = False else: - return redirect(url_for('static', filename='img/open.png')) - - -@app.route('/registrations_status/text') -def registrations_status_text(): - count = db.session.query(User).count() - return "{c}/{t}".format(c=count, t=config['maxInstanceUsers']) + filen = url_for('static', filename='img/open.png') + caniregister = True + return render_template('status.html', title='STATUS', count=count, max=config['maxInstanceUsers'], file=filen, cani=False) @app.route('/error/') def error(errno): diff --git a/app/templates/status.html b/app/templates/status.html new file mode 100644 index 0000000..4281c23 --- /dev/null +++ b/app/templates/status.html @@ -0,0 +1,46 @@ +{% extends "base.html" %} +{% block content %} +
+
+
+
+ {%if cani%} + :) + {%else%} + :( + {%endif%} +
+
+
+

Capacity

+
+ {%if cani%} + + {%else%} + + {%endif%} + {{count}}/{{max}} +
+
+
+
+ + Can I register? +
+ + {%if cani%} +
+ Yes! +
+ {%else%} +
+ It's full! +
+ {%endif%} + +
+
+
+
+
+{%endblock%} \ No newline at end of file