Nav apraksta

models.py 1.8KB

    # -*- coding: utf-8 -*- from django.db import models from django.utils.translation import ugettext_lazy as _ from django_models_ext import BaseModelMixin from shortuuidfield import ShortUUIDField from equipment.models import IsolationPointInfo class AdministratorInfo(BaseModelMixin): ACTIVATED = 1 DISABLED = 2 DELETED = 3 USER_STATUS_TUPLE = ( (ACTIVATED, '已激活'), (DISABLED, '已禁用'), (DELETED, '已删除'), ) admin_id = ShortUUIDField(_('admin_id'), max_length=32, blank=True, null=True, help_text='管理员唯一标识', db_index=True, unique=True) phone = models.CharField(_('phone'), max_length=11, blank=True, null=True, help_text='管理员电话', db_index=True) password = models.CharField(_('password'), max_length=255, blank=True, null=True, help_text='管理员密码') encryption = models.CharField(_('encryption'), max_length=255, blank=True, null=True, help_text='管理员密码') name = models.CharField(_('name'), max_length=255, blank=True, null=True, help_text='管理员姓名') point_id = models.CharField(_('point_id'), max_length=32, blank=True, null=True, help_text='隔离点唯一标识', db_index=True) point_name = models.CharField(_('point_name'), max_length=255, blank=True, null=True, help_text='隔离点名称') user_status = models.IntegerField(_('user_status'), choices=USER_STATUS_TUPLE, default=ACTIVATED, help_text='管理员状态', db_index=True) class Meta: verbose_name = _('管理员信息') verbose_name_plural = _('管理员信息') def __unicode__(self): return '{}-{}'.format(self.name, self.phone) @property def data(self): return { 'admin_id': self.admin_id, 'name': self.name, 'point_id': self.point_id, 'point_name': self.point_name, }