# coding=utf-8
from django.conf import settings
from django.db import models
from apps.tenant.models import Tenant

# Create your models here.
class DeviceModel(models.Model):
    name = models.CharField(max_length=50,verbose_name=u'名称')
    device_no = models.CharField(max_length=50, verbose_name=u'编号',null=True)
    device_model = models.CharField(max_length=100,verbose_name=u'设备型号',null=True)
    branch = models.CharField(max_length=100,verbose_name=u'小地点')
    address = models.CharField(max_length=100,verbose_name=u'大地点')
    tenant = models.ForeignKey(Tenant, verbose_name=u'租户', editable=False, on_delete=models.PROTECT, null=True)
    create_user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name=u"创建人", on_delete=models.PROTECT,
                                    editable=False)
    create_time = models.DateTimeField(verbose_name='创建时间', auto_now_add=True)

    class Meta:
        db_table = "device"
        verbose_name = u"设备管理"
        ordering = ('-id',)

    def get_full_name(self):
        return self.branch + ' ' + self.address
