2014-12-22 09:18:51 +00:00
|
|
|
from django.db import models
|
|
|
|
|
2014-12-22 15:14:29 +00:00
|
|
|
|
2015-03-02 10:27:48 +00:00
|
|
|
class DEPT(models.Model):
|
|
|
|
name = models.CharField(max_length=80, unique=True)
|
|
|
|
comment = models.CharField(max_length=160, blank=True, null=True)
|
2015-01-27 07:01:09 +00:00
|
|
|
|
2015-03-02 10:27:48 +00:00
|
|
|
def __unicode__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
|
|
|
|
class UserGroup(models.Model):
|
2014-12-22 15:14:29 +00:00
|
|
|
name = models.CharField(max_length=80, unique=True)
|
2015-03-02 10:27:48 +00:00
|
|
|
dept = models.ForeignKey(DEPT)
|
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'),
|
2015-03-02 10:27:48 +00:00
|
|
|
('DA', 'DeptAdmin'),
|
2014-12-27 15:54:37 +00:00
|
|
|
('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)
|
2015-03-02 10:27:48 +00:00
|
|
|
email = models.EmailField(max_length=75)
|
2014-12-22 15:14:29 +00:00
|
|
|
role = models.CharField(max_length=2, choices=USER_ROLE_CHOICES, default='CU')
|
2015-03-02 10:27:48 +00:00
|
|
|
dept = models.ForeignKey(DEPT)
|
|
|
|
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-22 15:14:29 +00:00
|
|
|
is_active = models.BooleanField(default=True)
|
2015-03-02 10:27:48 +00:00
|
|
|
last_login = models.DateTimeField(null=True)
|
|
|
|
date_joined = models.DateTimeField(null=True)
|
2014-12-22 15:14:29 +00:00
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.username
|