Browse Source

修改bug

pull/6/head
ibuler 10 years ago
parent
commit
8677b0d18d
  1. 2
      connect.py
  2. 15
      jpermission/models.py
  3. 6
      juser/models.py

2
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:

15
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)

6
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)

Loading…
Cancel
Save