diff --git a/jasset/models.py b/jasset/models.py index cfa8392e1..01e91f99c 100644 --- a/jasset/models.py +++ b/jasset/models.py @@ -1,6 +1,6 @@ import datetime from django.db import models -from juser.models import User, UserGroup +# from juser.models import User, UserGroup class AssetGroup(models.Model): @@ -90,9 +90,10 @@ class Asset(models.Model): class AssetAlias(models.Model): - user = models.ForeignKey(User) - asset = models.ForeignKey(Asset) - alias = models.CharField(max_length=100, blank=True, null=True) - - def __unicode__(self): - return self.alias + pass +# user = models.ForeignKey(User) +# asset = models.ForeignKey(Asset) +# alias = models.CharField(max_length=100, blank=True, null=True) +# +# def __unicode__(self): +# return self.alias diff --git a/jperm/perm_api.py b/jperm/perm_api.py index 93c4dda0b..1321482fe 100644 --- a/jperm/perm_api.py +++ b/jperm/perm_api.py @@ -125,3 +125,9 @@ def perm_user_api(asset_new, asset_del, asset_group_new, asset_group_del, user=N results = playbook_run(inventory, playbook, default_user, default_port, default_pri_key_path) return results + + +def refresh_group_api(user_group=None, asset_group=None): + """用户组添加删除用户,主机组添加删除主机触发""" + pass + diff --git a/juser/models.py b/juser/models.py index f2d5a6643..900c4bfbf 100644 --- a/juser/models.py +++ b/juser/models.py @@ -2,11 +2,15 @@ from django.db import models +from jasset.models import Asset, AssetGroup + class UserGroup(models.Model): name = models.CharField(max_length=80, unique=True) - assets = models.TextField(max_length=1000, verbose_name="Assets", default='') - asset_groups = models.CharField(max_length=1000, verbose_name="Asset Groups", default='') + # assets = models.TextField(max_length=1000, verbose_name="Assets", default='') + # asset_groups = models.CharField(max_length=1000, verbose_name="Asset Groups", default='') + assets = models.ManyToManyField(Asset) + asset_groups = models.ManyToManyField(AssetGroup) comment = models.CharField(max_length=160, blank=True, null=True) def __unicode__(self): @@ -34,8 +38,8 @@ class User(models.Model): role = models.CharField(max_length=2, choices=USER_ROLE_CHOICES, default='CU') uuid = models.CharField(max_length=100) group = models.ManyToManyField(UserGroup) - assets = models.TextField(max_length=1000, verbose_name="Assets", default='') - asset_groups = models.CharField(max_length=1000, verbose_name="Asset Groups", default='') + assets = models.ManyToManyField(Asset) + asset_groups = models.ManyToManyField(AssetGroup) ssh_key_pwd = models.CharField(max_length=200) is_active = models.BooleanField(default=True) last_login = models.DateTimeField(null=True) diff --git a/manage.py b/manage.py old mode 100644 new mode 100755 diff --git a/templates/juser/user_list.html b/templates/juser/user_list.html index fbe7f7c68..9d6fa45cf 100644 --- a/templates/juser/user_list.html +++ b/templates/juser/user_list.html @@ -61,7 +61,7 @@ {{ user.username }} {{ user.name }} - {{ user.group.all | group_str2 }} + {{ user.group.all | groups2str }} {{ user.id | get_role }} {{ user.is_active | bool2str }} 下载