Exemple #1
0
def _thermo_sensor_post(request, sensor_name):
    form = forms.ThermoPostForm(request.POST)
    if not form.is_valid():
        raise kbapi.BadRequestError, _form_errors(form)
    cd = form.cleaned_data
    sensor, created = models.ThermoSensor.objects.get_or_create(raw_name=sensor_name)
    # TODO(mikey): use form fields to compute `when`
    return request.backend.log_sensor_reading(sensor.raw_name, cd['temp_c'])
Exemple #2
0
def _thermo_sensor_post(request, sensor_name):
    form = forms.ThermoPostForm(request.POST)
    if not form.is_valid():
        raise krest.BadRequestError, _form_errors(form)
    cd = form.cleaned_data
    b = backend.KegbotBackend(site=request.kbsite)
    sensor, created = models.ThermoSensor.objects.get_or_create(
        site=request.kbsite, raw_name=sensor_name)
    # TODO(mikey): use form fields to compute `when`
    return FromProto(b.LogSensorReading(sensor.raw_name, cd['temp_c']))