# -*- coding: utf-8 -*- from django_logit import logit from django_response import response from paginator import pagination from thermometer.models import ThermometerInfo @logit def thermometer_bind(request): user_id = request.POST.get('user_id', '') macid = request.POST.get('macid', '') ThermometerInfo.objects.get_or_create(user_id=user_id, macid=macid) return response() @logit def thermometer_list(request): user_id = request.POST.get('user_id', '') page = request.POST.get('page', 1) num = request.POST.get('num', 20) thermometers = ThermometerInfo.objects.filter(user_id=user_id, status=True) thermometers, left = pagination(thermometers, page, num) thermometers = [thermometer.data for thermometer in thermometers] return response(data={ 'thermometers': thermometers, 'left': left, })