jumpserver/jasset/models.py

46 lines
1.5 KiB
Python
Raw Normal View History

import datetime
2014-12-22 09:18:51 +00:00
from django.db import models
2015-03-14 09:54:17 +00:00
from juser.models import UserGroup, DEPT
2014-12-22 09:18:51 +00:00
2014-12-22 15:14:29 +00:00
class IDC(models.Model):
name = models.CharField(max_length=40, unique=True)
comment = models.CharField(max_length=80, blank=True, null=True)
2014-12-22 15:14:29 +00:00
def __unicode__(self):
return self.name
2015-01-10 05:30:01 +00:00
2015-01-10 05:35:56 +00:00
class BisGroup(models.Model):
GROUP_TYPE = (
('P', 'PRIVATE'),
('A', 'ASSET'),
)
name = models.CharField(max_length=80, unique=True)
2015-03-14 09:54:27 +00:00
dept = models.ForeignKey(DEPT)
comment = models.CharField(max_length=160, blank=True, null=True)
type = models.CharField(max_length=1, choices=GROUP_TYPE, default='P')
def __unicode__(self):
return self.name
2014-12-22 15:14:29 +00:00
class Asset(models.Model):
LOGIN_TYPE_CHOICES = (
('L', 'LDAP'),
('M', 'MAP'),
)
2014-12-22 15:14:29 +00:00
ip = models.IPAddressField(unique=True)
port = models.SmallIntegerField(max_length=5)
2014-12-22 15:14:29 +00:00
idc = models.ForeignKey(IDC)
2015-01-10 05:35:56 +00:00
bis_group = models.ManyToManyField(BisGroup)
2015-03-14 09:54:17 +00:00
dept = models.ManyToManyField(DEPT)
login_type = models.CharField(max_length=1, choices=LOGIN_TYPE_CHOICES, default='L')
username = models.CharField(max_length=20, blank=True, null=True)
password = models.CharField(max_length=80, blank=True, null=True)
2015-01-10 05:30:01 +00:00
date_added = models.DateTimeField(auto_now=True, default=datetime.datetime.now(), null=True)
is_active = models.BooleanField(default=True)
2014-12-22 15:14:29 +00:00
comment = models.CharField(max_length=100, blank=True, null=True)
def __unicode__(self):
return self.ip