diff --git a/jasset/models.py b/jasset/models.py index 71a836239..3d9fbe4fd 100644 --- a/jasset/models.py +++ b/jasset/models.py @@ -1,3 +1,27 @@ from django.db import models +from juser.models import Group, User -# Create your models here. + +class IDC(models.Model): + name = models.CharField(max_length=80, unique=True) + comment = models.CharField(max_length=100, blank=True, null=True) + + def __unicode__(self): + return self.name + + +class Asset(models.Model): + ip = models.IPAddressField(unique=True) + port = models.SmallIntegerField(max_length=40) + idc = models.ForeignKey(IDC) + group = models.ManyToManyField(Group) + ldap_enable = models.BooleanField(default=True) + username_common = models.CharField(max_length=80, blank=True, null=True) + password_common = models.CharField(max_length=160, blank=True, null=True) + username_super = models.CharField(max_length=80, blank=True, null=True) + password_super = models.CharField(max_length=160, blank=True, null=True) + date_added = models.CharField() + comment = models.CharField(max_length=100, blank=True, null=True) + + def __unicode__(self): + return self.ip \ No newline at end of file diff --git a/jumpserver/settings.py b/jumpserver/settings.py index 887ed8d90..bcd5bb39b 100644 --- a/jumpserver/settings.py +++ b/jumpserver/settings.py @@ -103,7 +103,7 @@ STATICFILES_DIRS = ( LANGUAGE_CODE = 'en-us' -TIME_ZONE = 'UTC' +TIME_ZONE = 'Asia/Shanghai' USE_I18N = True diff --git a/juser/models.py b/juser/models.py index 71a836239..a270250cb 100644 --- a/juser/models.py +++ b/juser/models.py @@ -1,3 +1,31 @@ from django.db import models -# Create your models here. + +class Group(models): + name = models.CharField(max_length=80, unique=True) + comment = models.CharField(max_length=160, blank=True, null=True) + + def __unicode__(self): + return self.name + + +class User(models.Model): + USER_ROLE_CHOICES = ( + ('SU', 'Super_User'), + ('GA', 'Group_Admin'), + ('CU', 'Common_User'), + ) + username = models.CharField(max_length=80, unique=True) + password = models.CharField(max_length=100) + name = models.CharField(max_length=80) + email = models.EmailField(max_length=75, null=True, blank=True) + role = models.CharField(max_length=2, choices=USER_ROLE_CHOICES, default='CU') + group = models.ManyToManyField(Group) + ldap_pwd = models.CharField(max_length=100) + ssh_key_pwd = models.CharField(max_length=100) + is_active = models.BooleanField(default=True) + last_login = models.IntegerField(default=0) + date_joined = models.IntegerField() + + def __unicode__(self): + return self.username