def render_table_row(photon_id): chair = Chair.query.filter_by(photon_id=photon_id).first() now = datetime.utcnow() if not(chair): return "Crap" print(chair.occupied,'Yes' if chair.occupied else 'No') return "<td class='occupied %s'>%s</td>\ <td class='name'>%s</td>\ <td class='building'>%s</td>\ <td class='room'>%s</td>\ <td class='table'>%s</td>\ <td class='last_changed'>%s</td>" % ( 'orange-text' if chair.occupied else 'teal-text text-accent-4', 'No' if chair.occupied else 'Yes', chair.name, chair.table.room.building.name, chair.table.room.name, chair.table.name, helpers.time_since(chair.last_changed, now))
def index(): now = datetime.utcnow() chairs = [ { 'name': chair.name, 'occupied': 'No' if chair.occupied else 'Yes', 'color': 'orange-text' if chair.occupied else 'teal-text text-accent-4', 'building': chair.table.room.building.name, 'room': chair.table.room.name, 'photon_id': chair.photon_id, 'table': chair.table.name, 'last_changed': helpers.time_since(chair.last_changed, now) } for chair in Chair.query.all()] print(chairs) return render_template( 'index.html', chairs=chairs)