Affichage de l'historique plus souvent

This commit is contained in:
guimoz 2017-01-30 10:30:26 +01:00
parent 115c81f283
commit 10bbc40117

View file

@ -357,12 +357,8 @@ def home():
player = get_player_from_ip(get_ip()) player = get_player_from_ip(get_ip())
if DEBUG: if DEBUG:
print(STATE) print(STATE)
if "down" in STATE:
return render_template('down.html', user=player,stats=statistiques())
elif "up" in STATE:
if DEBUG: if DEBUG:
print(player, 'arrived') print(player, 'arrived')
bans = sorted(get_bans(player['id']), \ bans = sorted(get_bans(player['id']), \
key=lambda ban: ban['time'], \ key=lambda ban: ban['time'], \
reverse=True) reverse=True)
@ -387,8 +383,11 @@ def home():
else: else:
entry = ('ban', u'%s : Tu as échoué en voulant trancher %s %s.' \ entry = ('ban', u'%s : Tu as échoué en voulant trancher %s %s.' \
% (date, target['firstname'], target['name'])) % (date, target['firstname'], target['name']))
bans_hist.append(entry) bans_hist.append(entry)
if "down" in STATE:
return render_template('down.html', user=player, stats=statistiques(), bans_hist=bans_hist)
elif "up" in STATE:
return render_template('home.html', bans_hist=bans_hist, stats=statistiques()) return render_template('home.html', bans_hist=bans_hist, stats=statistiques())
else: else:
return render_template('precampagne.html', user=player,stats=statistiques()) return render_template('precampagne.html', user=player,stats=statistiques())
@ -399,7 +398,33 @@ def play():
ip = get_ip() ip = get_ip()
player = get_player_from_ip(ip) player = get_player_from_ip(ip)
if "down" in STATE: if "down" in STATE:
bans = sorted(get_bans(player['id']), \
key=lambda ban: ban['time'], \
reverse=True)
bans_hist = []
for ban in bans:
date = strftime('%Hh%M (%A)', localtime(ban['time']))
source = get_player(ban['player_id'])
target = get_player(ban['target_id'])
if target['id'] == player['id']:
if ban['success']:
entry = ('ban', u'%s : %s %s a réussi à t\'avoir.' \
% (date, source['firstname'], source['name']))
else:
entry = ('warn', u'%s : %s %s a essayé de te trancher, en vain.' \
% (date, source['firstname'], source['name']))
else:
if ban['success']:
entry = ('ok', u'%s : Tu as tranché %s %s avec succès.' \
% (date, target['firstname'], target['name']))
else:
entry = ('ban', u'%s : Tu as échoué en voulant trancher %s %s.' \
% (date, target['firstname'], target['name']))
bans_hist.append(entry)
return render_template('down.html', user=player,stats=statistiques()) return render_template('down.html', user=player,stats=statistiques())
elif "up" in STATE: elif "up" in STATE:
# Traitement de la requête de bannissement # Traitement de la requête de bannissement
if request.method == 'POST': if request.method == 'POST':