暫無描述

thermometer_views.py 995B

    # -*- coding: utf-8 -*- from django_logit import logit from django_response import response from paginator import pagination from TimeConvert import TimeConvert as tc from thermometer.models import ThermometerInfo @logit def thermometer_bind(request): user_id = request.POST.get('user_id', '') macid = request.POST.get('macid', '') thermometer, _ = ThermometerInfo.objects.get_or_create(user_id=user_id, macid=macid) thermometer.bound_at = tc.utc_datetime() thermometer.save() 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, })