Sin Descripción

models.py 1.9KB

    # -*- coding: utf-8 -*- from django.db import models from django.utils.translation import ugettext_lazy as _ from django_models_ext import BaseModelMixin, SexModelMixin from shortuuidfield import ShortUUIDField from TimeConvert import TimeConvert as tc class HouseholdThermometerEquipmentBindInfo(BaseModelMixin): bind_id = ShortUUIDField(_('bind_id'), max_length=32, blank=True, null=True, help_text='绑定唯一标识', db_index=True, unique=True) user_id = models.CharField(_('user_id'), max_length=32, blank=True, null=True, help_text='用户唯一标识') macid = models.CharField(_('macid'), max_length=32, blank=True, null=True, help_text='设备号') class Meta: verbose_name = _('家用测温设备绑定信息') verbose_name_plural = _('家用测温设备绑定信息') def __unicode__(self): return self.pk @property def data(self): return { 'bind_id': self.bind_id, 'user_id': self.user_id, 'macid': self.macid, 'created_at': tc.local_string(utc_dt=self.created_at), } class HouseholdThermometerMeasureLogInfo(BaseModelMixin): macid = models.CharField(_('macid'), max_length=32, blank=True, null=True, help_text='设备号') user_id = models.CharField(_('user_id'), max_length=32, blank=True, null=True, help_text='用户唯一标识') temperature = models.FloatField(_('temperature'), default=0, help_text='用户体温') class Meta: verbose_name = _('家用测温记录信息') verbose_name_plural = _('家用测温记录信息') def __unicode__(self): return self.pk @property def data(self): return { 'macid': self.macid, 'user_id': self.user_id, 'temperature': self.temperature, 'created_at': tc.local_string(utc_dt=self.created_at), }