Ajout de la precampagne

This commit is contained in:
guimoz 2017-01-29 19:54:55 +01:00
parent b421d7b83f
commit 0acf16f411
4 changed files with 94 additions and 66 deletions

View file

@ -28,20 +28,10 @@ MYSQL_DB = 'rezo_admin'
BAN_DURATION = 30. * 60.
IMMUNITY_FILE = '/var/roulette/immunity'
ASSHOLES_FILE = '/var/www/roulette/assholes'
ASSHOLES_FILE = '/var/roulette/assholes'
STATE_FILE = '/var/roulette/state'
IMMUNITY = [
'Lazare Olivry',
'Brieuc Lacroix',
'Elliot Butty',
'Jean-Christophe Carli',
'Juliette Tibayrenc',
'Elise Laurent',
'Goulven Kermarec',
'Siqi Liu',
]
ASSHOLES = []
STATE = 'precampagne'
app = Flask(__name__)
app.config.from_object(__name__)
@ -313,6 +303,9 @@ def banned():
@app.route('/banned_ip')
def banned_ip():
#Actualisation de l'etat de la roulette
with open(STATE_FILE, 'r') as f:
STATE = f.read()
# Liste des ip pour récupération par babel et plop
if not DEBUG:
if get_ip() not in ['10.7.0.254']:
@ -334,10 +327,9 @@ def banned_ip():
@playable_required
def home():
player = get_player_from_ip(get_ip())
#if ip not in ['10.69.8.5', '10.69.8.202']:
# abort(403)
if STATE == "down":
return render_template('down.html', user=player)
elif STATE == "launched":
if DEBUG:
print(player, 'arrived')
@ -369,13 +361,17 @@ def home():
bans_hist.append(entry)
return render_template('home.html', bans_hist=bans_hist)
else STATE:
return render_template('precampagne.html', user=player)
@app.route('/jouer', methods=['GET', 'POST'])
@playable_required
def play():
ip = get_ip()
player = get_player_from_ip(ip)
if STATE == "down":
return render_template('down.html', user=player)
elif STATE == "launched":
# Traitement de la requête de bannissement
if request.method == 'POST':
target_id = request.form['target_id']
@ -402,6 +398,8 @@ def play():
players = filter(lambda p: p['id'] != player['id'], players)
return render_template('play.html', players=players)
else STATE:
return render_template('precampagne.html', user=player)
if __name__ == '__main__':
app.run()

View file

@ -1,4 +1,4 @@
import sys
sys.path.insert(0, '/var/www/roulette')
sys.path.insert(0, '/var/roulette')
from roulette import app as application

22
templates/down.html Normal file
View file

@ -0,0 +1,22 @@
{% extends "layout.html" %}
{% block content %}
<h2>Toi aussi, joue au rézoman !</h2>
<p>
La rezo-roulette metzquetaire vous offre un répit temporaire. Profite bien {{ user['firstname']+' '+user['name'] }} ;-)
</p>
<h2>Historique personnel</h2>
{% if bans_hist != [] %}
<ul id="history">
{% for entry in bans_hist %}
<li class="{{ entry[0] }}" class="events">
<span class="normal"> {{ entry[1] }}</span>
</li>
{% endfor %}
</ul>
{% else %}
<p>
Rien pour l'instant
</p>
{% endif %}
{% endblock %}

View file

@ -0,0 +1,8 @@
{% extends "layout.html" %}
{% block content %}
<h2>Pas de précampagne!</h2>
<p>
Reviens bientôt {{ user['firstname']+' '+user['name'] }} pour jouer à la rezo-roulette
</p>
{% endif %}
{% endblock %}