2014-12-22 09:18:51 +00:00
|
|
|
from django.db import models
|
|
|
|
|
2014-12-22 15:14:29 +00:00
|
|
|
|
2015-01-10 05:35:56 +00:00
|
|
|
class UserGroup(models.Model):
|
2015-01-27 07:01:09 +00:00
|
|
|
GROUP_TYPE_CHOICES = (
|
2015-01-28 03:17:29 +00:00
|
|
|
('P', 'PrivateGroup'),
|
|
|
|
('M', 'ManageGroup'),
|
|
|
|
('A', 'AuthorizeGroup'),
|
2015-01-27 07:01:09 +00:00
|
|
|
)
|
|
|
|
|
2014-12-22 15:14:29 +00:00
|
|
|
name = models.CharField(max_length=80, unique=True)
|
2015-01-28 07:08:16 +00:00
|
|
|
type = models.CharField(max_length=1, choices=GROUP_TYPE_CHOICES, default='P')
|
2014-12-22 15:14:29 +00:00
|
|
|
comment = models.CharField(max_length=160, blank=True, null=True)
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
|
|
|
|
class User(models.Model):
|
|
|
|
USER_ROLE_CHOICES = (
|
2014-12-27 15:54:37 +00:00
|
|
|
('SU', 'SuperUser'),
|
|
|
|
('GA', 'GroupAdmin'),
|
|
|
|
('CU', 'CommonUser'),
|
2014-12-22 15:14:29 +00:00
|
|
|
)
|
|
|
|
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')
|
2015-01-10 05:35:56 +00:00
|
|
|
user_group = models.ManyToManyField(UserGroup)
|
2014-12-22 15:14:29 +00:00
|
|
|
ldap_pwd = models.CharField(max_length=100)
|
2015-01-28 03:17:29 +00:00
|
|
|
ssh_key_pwd = models.CharField(max_length=100)
|
2014-12-30 14:48:39 +00:00
|
|
|
ssh_pwd = models.CharField(max_length=100)
|
2014-12-22 15:14:29 +00:00
|
|
|
is_active = models.BooleanField(default=True)
|
|
|
|
last_login = models.IntegerField(default=0)
|
|
|
|
date_joined = models.IntegerField()
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.username
|