Browse Source

More functionality, more styles.

master
parent
commit
43de5e73cb
  1. 17
      app.py
  2. 11
      config.toml
  3. 26
      static/style.css
  4. 36
      templates/form.html
  5. 6
      templates/tablo.html

17
app.py

@ -35,7 +35,6 @@ order = [{"id":i,"value":str(i+1)+"."} for i in range(len(config["teams"]))]
order.append({"id":"t", "value":"Třezalka"}) order.append({"id":"t", "value":"Třezalka"})
order.append({"id":"n", "value":"Neběžel"}) order.append({"id":"n", "value":"Neběžel"})
around = 0
def check_form(form,config): def check_form(form,config):
errors = [] errors = []
@ -106,7 +105,7 @@ def hello_world():
def form_page(): def form_page():
if request.method == 'GET': if request.method == 'GET':
return render_template("form.html", return render_template("form.html",
round = config["times"][around], round = config["times"][config['round']],
people = config["orgs"], people = config["orgs"],
order = order, order = order,
teams = config["teams"], teams = config["teams"],
@ -117,7 +116,7 @@ def form_page():
errors = check_form(request.form,config) errors = check_form(request.form,config)
if errors: if errors:
return render_template("form.html", return render_template("form.html",
round = config["times"][around], round = config["times"][config['round']],
people = config["orgs"], people = config["orgs"],
order = order, order = order,
teams = config["teams"], teams = config["teams"],
@ -126,11 +125,19 @@ def form_page():
for team in config["teams"]: for team in config["teams"]:
order1 = request.form['poradi1_'+str(team['id'])] order1 = request.form['poradi1_'+str(team['id'])]
order2 = request.form['poradi2_'+str(team['id'])] order2 = request.form['poradi2_'+str(team['id'])]
per1 = request.form['clovek1_'+str(team['id'])] per1 = request.form.get('clovek1_'+str(team['id']),None)
per2 = request.form.get('clovek2_'+str(team['id']),None) per2 = request.form.get('clovek2_'+str(team['id']),None)
team["points"] += team_points(per1,order1,per2,order2,config) team["points"] += team_points(per1,order1,per2,order2,config)
if team["points"] <= 0:
team["emerg"] += 1
team["points"] = 100
if "zachranka_"+str(team['id']) in request.form and\
team['emerg_remain'] > 0:
team["points"] = 100
team['emerg_remain'] -= 1
config["round"] += 1
return render_template("form.html", return render_template("form.html",
round = config["times"][around], round = config["times"][config['round']],
people = config["orgs"], people = config["orgs"],
order = order, order = order,
teams = config["teams"], teams = config["teams"],

11
config.toml

@ -15,6 +15,7 @@ times = [
"pátek ráno", "pátek ráno",
"pátek v poledne", "pátek v poledne",
"pátek večer", "pátek večer",
"konec"
] ]
order_coeff = [ order_coeff = [
@ -24,6 +25,8 @@ start_pts = 100
base_pts = 20 base_pts = 20
no_pts = -20 no_pts = -20
round = 0
# Přiřazení léků k orgům # Přiřazení léků k orgům
[[orgs]] [[orgs]]
value = "Borek" value = "Borek"
@ -64,19 +67,27 @@ no_pts = -20
name = "Doktoři" name = "Doktoři"
id = 1 id = 1
points = 100 points = 100
emerg = 0
emerg_remain = 1
[[teams]] [[teams]]
name = "Lékaři" name = "Lékaři"
id = 2 id = 2
points = 100 points = 100
emerg = 0
emerg_remain = 1
[[teams]] [[teams]]
name = "Medici" name = "Medici"
id = 3 id = 3
points = 100 points = 100
emerg = 0
emerg_remain = 1
[[teams]] [[teams]]
name = "Hrobaři" name = "Hrobaři"
id = 4 id = 4
points = 100 points = 100
emerg = 0
emerg_remain = 1

26
static/style.css

@ -1,3 +1,7 @@
ul {
list-style-type: none;
}
#content { #content {
width: 100%; width: 100%;
height: 100%; height: 100%;
@ -7,7 +11,7 @@
align-items: flex-end; align-items: flex-end;
} }
.team { .team_bar {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: flex-end; justify-content: flex-end;
@ -17,7 +21,27 @@
.points { .points {
font-size: 32pt; font-size: 32pt;
} }
.emergs {
font-size: 20pt;
}
.teams {
display: flex;
flex-direction: row;
justify-content: space-around;
}
.team {
margin: 5px;
padding: 5px;
border: 1px solid rgba(128,128,128,1);
}
.persons {
display: flex;
flex-direction: row;
justify-content: space-around;
}
.bar { .bar {
float: left; float: left;

36
templates/form.html

@ -1,5 +1,7 @@
<html> <html>
<head> <head>
<link rel="stylesheet" href="/static/style.css">
<title>Úprava zdraví pacientů</title>
</head> </head>
<body> <body>
<h1>Zadávání pořadí - {{round}}</h1> <h1>Zadávání pořadí - {{round}}</h1>
@ -10,29 +12,59 @@
<li>{{e}}</li> <li>{{e}}</li>
{% endfor %} {% endfor %}
</ul> </ul>
<div class="teams">
{% for team in teams %} {% for team in teams %}
<div class="team">
<h2>Tým {{team.name}}</h2> <h2>Tým {{team.name}}</h2>
<div class="persons">
<div class="per1">
<h3>Člověk 1:</h3> <h3>Člověk 1:</h3>
<ul>
{% for c in people %} {% for c in people %}
<li>
<input type="radio" name="clovek1_{{team.id}}" id="clovek1_{{team.id}}_{{c.id}}" value="{{c.id}}"> <input type="radio" name="clovek1_{{team.id}}" id="clovek1_{{team.id}}_{{c.id}}" value="{{c.id}}">
<label for="clovek1_{{team.id}}_{{c.id}}">{{c.value}}</label> <label for="clovek1_{{team.id}}_{{c.id}}">{{c.value}}</label>
</li>
{% endfor %} {% endfor %}
<h3>Pořadí</h3> </ul>
<h4>Pořadí</h4>
<ul>
{% for p in order %} {% for p in order %}
<li>
<input type="radio" name="poradi1_{{team.id}}" id="p1_{{team.id}}_{{p.id}}" value="{{p.id}}"> <input type="radio" name="poradi1_{{team.id}}" id="p1_{{team.id}}_{{p.id}}" value="{{p.id}}">
<label for="p1_{{team.id}}_{{p.id}}">{{p.value}}</label> <label for="p1_{{team.id}}_{{p.id}}">{{p.value}}</label>
</li>
{% endfor %} {% endfor %}
</ul>
</div>
<div class="per2">
<h3>Člověk 2:</h3> <h3>Člověk 2:</h3>
<ul>
{% for c in people %} {% for c in people %}
<li>
<input type="radio" name="clovek2_{{team.id}}" id="clovek2_{{team.id}}_{{c.id}}" value="{{c.id}}"> <input type="radio" name="clovek2_{{team.id}}" id="clovek2_{{team.id}}_{{c.id}}" value="{{c.id}}">
<label for="clovek2_{{team.id}}_{{c.id}}">{{c.value}}</label> <label for="clovek2_{{team.id}}_{{c.id}}">{{c.value}}</label>
</li>
{% endfor %} {% endfor %}
<h3>Pořadí</h3> </ul>
<h4>Pořadí</h4>
<ul>
{% for p in order %} {% for p in order %}
<li>
<input type="radio" name="poradi2_{{team.id}}" id="p2_{{team.id}}_{{p.id}}" value="{{p.id}}"> <input type="radio" name="poradi2_{{team.id}}" id="p2_{{team.id}}_{{p.id}}" value="{{p.id}}">
<label for="p2_{{team.id}}_{{p.id}}">{{p.value}}</label> <label for="p2_{{team.id}}_{{p.id}}">{{p.value}}</label>
</li>
{% endfor %} {% endfor %}
</ul>
</div>
</div>
{% if team.emerg_remain > 0 %}
<input type="checkbox" name="zachranka_{{team.id}}" id="zach_{{team.id}}" value="true">
<label for="zach_{{team.id}}">Záchranka</label>
{% endif %}
</div>
{% endfor %} {% endfor %}
</div>
<input type="submit" value="Odeslat"> <input type="submit" value="Odeslat">
</form> </form>

6
templates/tablo.html

@ -6,12 +6,16 @@
<body> <body>
<div id="content"> <div id="content">
{% for t in teams %} {% for t in teams %}
<div class="team"> <div class="team_bar">
<div class="bar" id="bar_{{t.id}}" style="height:{{t.points}}"> <div class="bar" id="bar_{{t.id}}" style="height:{{t.points}}">
</div> </div>
<div class="points"> <div class="points">
{{t.points}} {{t.points}}
</div> </div>
<div class="emergs">
Záchranky:
{{t.emerg}}
</div>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>

Loading…
Cancel
Save