Added listing sensors' states.

pull/1/head
Stanislaw Klekot 2014-06-19 19:08:54 +02:00
rodzic 81e4205dd1
commit b0efd3c263
2 zmienionych plików z 18 dodań i 1 usunięć

Wyświetl plik

@ -46,7 +46,22 @@ def sensor_state(sensor_id, state, context = None):
return sensor_update_state(sensor_id, state, context)
def list_sensors():
return [] # TODO
return Sensor.objects.all().order_by('sensor_id')
def list_list_sensors():
sensors = {}
order = []
for s in ListSensor.objects.all().order_by('sensor_id'):
entry = {
'name': s.subname,
'since': s.since,
}
if s.name not in sensors:
sensors[s.name] = { 'name': s.name, 'entries': [entry] }
order.append(s.name)
else:
sensors[s.name]['entries'].append(entry)
return [sensors[s] for s in order]
def delete_sensor(sensor_id, context = None):
sensors = Sensor.objects.filter(sensor_id = sensor_id)

Wyświetl plik

@ -43,6 +43,8 @@ def list(request, nick = None):
'form_target': form_target,
'form': form,
'present': presence.list_people(),
'sensors': presence.list_sensors(),
'list_sensors': presence.list_list_sensors(),
})
return HttpResponse(template.render(context))