Browse Source

More functionality, more styles.

master
parent
commit
43de5e73cb
  1. 17
      app.py
  2. 11
      config.toml
  3. 26
      static/style.css
  4. 74
      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":"n", "value":"Neběžel"})
around = 0
def check_form(form,config):
errors = []
@ -106,7 +105,7 @@ def hello_world():
def form_page():
if request.method == 'GET':
return render_template("form.html",
round = config["times"][around],
round = config["times"][config['round']],
people = config["orgs"],
order = order,
teams = config["teams"],
@ -117,7 +116,7 @@ def form_page():
errors = check_form(request.form,config)
if errors:
return render_template("form.html",
round = config["times"][around],
round = config["times"][config['round']],
people = config["orgs"],
order = order,
teams = config["teams"],
@ -126,11 +125,19 @@ def form_page():
for team in config["teams"]:
order1 = request.form['poradi1_'+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)
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",
round = config["times"][around],
round = config["times"][config['round']],
people = config["orgs"],
order = order,
teams = config["teams"],

11
config.toml

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

26
static/style.css

@ -1,3 +1,7 @@
ul {
list-style-type: none;
}
#content {
width: 100%;
height: 100%;
@ -7,7 +11,7 @@
align-items: flex-end;
}
.team {
.team_bar {
display: flex;
flex-direction: column;
justify-content: flex-end;
@ -17,7 +21,27 @@
.points {
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 {
float: left;

74
templates/form.html

@ -1,5 +1,7 @@
<html>
<head>
<link rel="stylesheet" href="/static/style.css">
<title>Úprava zdraví pacientů</title>
</head>
<body>
<h1>Zadávání pořadí - {{round}}</h1>
@ -10,29 +12,59 @@
<li>{{e}}</li>
{% endfor %}
</ul>
<div class="teams">
{% for team in teams %}
<h2>Tým {{team.name}}</h2>
<h3>Člověk 1:</h3>
{% for c in people %}
<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>
{% endfor %}
<h3>Pořadí</h3>
{% for p in order %}
<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>
{% endfor %}
<h3>Člověk 2:</h3>
{% for c in people %}
<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>
{% endfor %}
<h3>Pořadí</h3>
{% for p in order %}
<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>
{% endfor %}
<div class="team">
<h2>Tým {{team.name}}</h2>
<div class="persons">
<div class="per1">
<h3>Člověk 1:</h3>
<ul>
{% for c in people %}
<li>
<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>
</li>
{% endfor %}
</ul>
<h4>Pořadí</h4>
<ul>
{% for p in order %}
<li>
<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>
</li>
{% endfor %}
</ul>
</div>
<div class="per2">
<h3>Člověk 2:</h3>
<ul>
{% for c in people %}
<li>
<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>
</li>
{% endfor %}
</ul>
<h4>Pořadí</h4>
<ul>
{% for p in order %}
<li>
<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>
</li>
{% 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 %}
</div>
<input type="submit" value="Odeslat">
</form>

6
templates/tablo.html

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

Loading…
Cancel
Save