Browse files

Removed indexed attribute access with a namedtuple.

  • Loading branch information...
1 parent 3d75322 commit 1fda45bb7b69d8c75c01b46f770314613fd925bd @exhuma committed Apr 1, 2013
Showing with 9 additions and 6 deletions.
  1. +4 −1 lost_tracker/main.py
  2. +5 −5 lost_tracker/templates/station.html
View
5 lost_tracker/main.py
@@ -1,4 +1,5 @@
import os
+from collections import namedtuple
from sqlalchemy import create_engine
from lost_tracker.core import (get_matrix, get_state_sum, get_grps, add_grp,
@@ -74,10 +75,12 @@ def station(name):
return abort(404)
groups = get_grps()
+ group_state_row = namedtuple('group_state_row',
+ 'group, state')
return render_template(
'station.html',
station=station,
- group_states=[(grp, get_state(grp.id, station.id))
+ group_states=[group_state_row(grp, get_state(grp.id, station.id))
for grp in groups])
View
10 lost_tracker/templates/station.html
@@ -10,14 +10,14 @@
<h2><a href="{{url_for('index')}}">Zeréck op d'Haaptsäit</a></h2>
{% for row in group_states %}
-<div class="group state_{{row[1]}} {{row[0].cancelled and 'cancelled' or ''}}">
+<div class="group state_{{row.state}} {{row.group.cancelled and 'cancelled' or ''}}">
<div class="icon">
- {% set icon_file = 'icons/%s.png' % row[1] %}
- <img id="icon_{{station.id}}_{{row[0].id}}" src="{{url_for('static', filename=icon_file)}}" />
+ {% set icon_file = 'icons/%s.png' % row.state %}
+ <img id="icon_{{station.id}}_{{row.group.id}}" src="{{url_for('static', filename=icon_file)}}" />
</div>
<div class="details">
- <div class="name" onclick="advanceState({{row[0].id}});">
- {{row[0].name}}
+ <div class="name" onclick="advanceState({{row.group.id}});">
+ {{row.group.name}}
</div>
<div>
<input type="number" name="score" />

0 comments on commit 1fda45b

Please sign in to comment.