Correction de bugs

This commit is contained in:
guimoz 2017-01-30 09:19:01 +01:00
parent 8bd93b22d5
commit 815d7abe21

View file

@ -352,11 +352,31 @@ def banned_ip():
@app.route('/')
@playable_required
def home():
#Calcul des statistiques
con = connect_sqlite()
cur = con.cursor()
cur.execute("""select firstname,name,ban_end from players""")
rows = cur.fetchall()
con.close()
tranchés = 0
n_tranchés = 0
with open(IMMUNITY_FILE, 'r') as f:
immunity = f.read()
for row in rows:
if row[0]+' '+row[1] not in immunity:
if row[2] > time():
tranchés += 1
else:
n_tranchés += 1
stats = (tranchés,n_tranchés)
player = get_player_from_ip(get_ip())
if DEBUG:
print(STATE)
if "down" in STATE:
return render_template('down.html', user=player)
return render_template('down.html', user=player,stats=stats)
elif "up" in STATE:
if DEBUG:
print(player, 'arrived')
@ -387,36 +407,35 @@ def home():
% (date, target['firstname'], target['name']))
bans_hist.append(entry)
#Calcul des statistiques
con = connect_sqlite()
cur = con.cursor()
cur.execute("""select firstname,name,ban_end from players""")
rows = cur.fetchall()
con.close()
tranchés = 0
n_tranchés = 0
with open(IMMUNITY_FILE, 'r') as f:
immunity = f.read()
for row in rows:
if row[0]+' '+row[1] not in immunity:
if row[2] > time():
tranchés += 1
else:
n_tranchés += 1
stats = (tranchés,n_tranchés)
return render_template('home.html', bans_hist=bans_hist, stats=stats)
else:
return render_template('precampagne.html', user=player)
return render_template('precampagne.html', user=player,stats=stats)
@app.route('/jouer', methods=['GET', 'POST'])
@playable_required
def play():
ip = get_ip()
player = get_player_from_ip(ip)
#Calcul des statistiques
con = connect_sqlite()
cur = con.cursor()
cur.execute("""select firstname,name,ban_end from players""")
rows = cur.fetchall()
con.close()
tranchés = 0
n_tranchés = 0
with open(IMMUNITY_FILE, 'r') as f:
immunity = f.read()
for row in rows:
if row[0]+' '+row[1] not in immunity:
if row[2] > time():
tranchés += 1
else:
n_tranchés += 1
stats = (tranchés,n_tranchés)
if "down" in STATE:
return render_template('down.html', user=player)
elif "up" in STATE:
@ -445,30 +464,9 @@ def play():
# sans le joueur actuel
players = filter(lambda p: p['id'] != player['id'], players)
#Calcul des statistiques
con = connect_sqlite()
cur = con.cursor()
cur.execute("""select firstname,name,ban_end from players""")
rows = cur.fetchall()
con.close()
tranchés = 0
n_tranchés = 0
with open(IMMUNITY_FILE, 'r') as f:
immunity = f.read()
for row in rows:
if row[0]+' '+row[1] not in immunity:
if row[2] > time():
tranchés += 1
else:
n_tranchés += 1
stats = (tranchés,n_tranchés)
return render_template('play.html', players=players, stats=stats)
else:
return render_template('precampagne.html', user=player)
return render_template('precampagne.html', user=player,stats=stats)
if __name__ == '__main__':
app.run()