You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jumpserver/juser/models.py

46 lines
1.2 KiB

9 years ago
# coding: utf-8
from django.db import models
from django.contrib.auth.models import AbstractUser
from jasset.models import Asset, AssetGroup
class UserGroup(models.Model):
name = models.CharField(max_length=80, unique=True)
comment = models.CharField(max_length=160, blank=True, null=True)
9 years ago
asset = models.ManyToManyField(Asset)
asset_group = models.ManyToManyField(AssetGroup)
def __unicode__(self):
return self.name
9 years ago
class User(AbstractUser):
USER_ROLE_CHOICES = (
('SU', 'SuperUser'),
9 years ago
('GA', 'GroupAdmin'),
('CU', 'CommonUser'),
)
name = models.CharField(max_length=80)
uuid = models.CharField(max_length=100)
9 years ago
role = models.CharField(max_length=2, choices=USER_ROLE_CHOICES, default='CU')
group = models.ManyToManyField(UserGroup)
ssh_key_pwd = models.CharField(max_length=200)
def __unicode__(self):
return self.username
class AdminGroup(models.Model):
"""
under the user control group
用户可以管理的用户组或组的管理员是该用户
"""
user = models.ForeignKey(User)
group = models.ForeignKey(UserGroup)
def __unicode__(self):
return '%s: %s' % (self.user.username, self.group.name)