Browse Source

#7 added a /highscores page. Only completed players are shown.

pull/14/head
Rogier Neeleman 8 years ago
parent
commit
cac044aa4b
  1. 36
      nfgame.py
  2. 2
      templates/overview.html

36
nfgame.py

@ -85,7 +85,41 @@ def index(): @@ -85,7 +85,41 @@ def index():
if found_tag == tag:
user[entry['id']][tag] = 'Found'
return render_template('overview.html', entries=entries, tags=app.config['TAGS'], user=user)
return render_template('overview.html', entries=entries, tags=app.config['TAGS'], user=user, type='Current players')
@app.route('/highscores')
def highscores():
tagquery = ""
for tag in app.config['TAGS']:
if tagquery == "":
tagquery = 'where tags like "%' + tag + '%"'
else:
tagquery = tagquery + ' and tags like "%' + tag + '%"'
print(tagquery)
db = get_db()
cur = db.execute('select * from score ' + tagquery + ' order by duration asc')
entries = cur.fetchall()
user = {}
tags = app.config['TAGS']
for entry in entries:
if entry['tags'] == None:
found_tags = []
else:
found_tags = entry['tags'].split(',')
user[entry['id']] = {}
for tag in tags:
user[entry['id']][tag] = 'Not'
for found_tag in found_tags:
if found_tag == tag:
user[entry['id']][tag] = 'Found'
return render_template('overview.html', entries=entries, tags=app.config['TAGS'], user=user, type='Highscores')
@app.route('/newuser/', methods=['GET', 'POST'])
@app.route('/newuser/<string:newhash>/', methods=['GET', 'POST'])

2
templates/overview.html

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
{% extends "layout-overview.html" %}
{% block body %}
<h1 class="uk-heading-primary uk-text-center uk-heading-divider">Scoreboard</h1>
<h1 class="uk-heading-primary uk-text-center uk-heading-divider">{{ type }}</h1>
<center>
<div class="uk-text-large uk-align-center">

Loading…
Cancel
Save