From 8677b0d18daebc3b1c8000a55a1c0a682ae55e56 Mon Sep 17 00:00:00 2001 From: ibuler Date: Sat, 27 Dec 2014 23:54:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- connect.py | 2 +- jpermission/models.py | 15 +++++++-------- juser/models.py | 6 +++--- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/connect.py b/connect.py index 181784263..eecc38f4d 100755 --- a/connect.py +++ b/connect.py @@ -173,7 +173,7 @@ def get_user_host(username): try: user = User.objects.get(username=username) except ObjectDoesNotExist: - return {'Error': 'username %s is not exist.' % username}, ['Error'] + return {'Error': ['0', "Username \033[1;31m%s\033[0m doesn't exist on Jumpserver." % username]}, ['Error'] else: perm_all = user.permission_set.all() for perm in perm_all: diff --git a/jpermission/models.py b/jpermission/models.py index 9b187c6a6..2d81a3461 100644 --- a/jpermission/models.py +++ b/jpermission/models.py @@ -4,17 +4,16 @@ from jasset.models import Asset class Permission(models.Model): - PERM_USER_TYPE_CHOICE = ( - ('S', 'Super'), - ('C', 'Common'), + USER_ROLE_CHOICES = ( + ('SU', 'SuperUser'), + ('CU', 'CommonUser'), ) user = models.ForeignKey(User) asset = models.ForeignKey(Asset) - is_ldap = models.BooleanField(default=True) - perm_user_type = models.CharField(choices=PERM_USER_TYPE_CHOICE, - max_length=1, - blank=True, - null=True) + role = models.CharField(choices=USER_ROLE_CHOICES, + max_length=1, + blank=True, + null=True) def __unicode__(self): return '%s_%s' % (self.user.username, self.asset.ip) \ No newline at end of file diff --git a/juser/models.py b/juser/models.py index c818185a5..26cc6c5d4 100644 --- a/juser/models.py +++ b/juser/models.py @@ -11,9 +11,9 @@ class Group(models.Model): class User(models.Model): USER_ROLE_CHOICES = ( - ('SU', 'Super_User'), - ('GA', 'Group_Admin'), - ('CU', 'Common_User'), + ('SU', 'SuperUser'), + ('GA', 'GroupAdmin'), + ('CU', 'CommonUser'), ) username = models.CharField(max_length=80, unique=True) password = models.CharField(max_length=100)