修改使用新表结构

pull/26/head
ibuler@qq.com 2015-10-06 23:47:53 +08:00
parent 43fe985143
commit e99b33c51e
5 changed files with 23 additions and 12 deletions

View File

@ -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

View File

@ -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

View File

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

0
manage.py Normal file → Executable file
View File

View File

@ -61,7 +61,7 @@
</td>
<td class="text-center"> {{ user.username }} </td>
<td class="text-center"> {{ user.name }} </td>
<td class="text-center" title="{% for user_group in user.group.all %} {{ user_group.name }} {% endfor %}"> {{ user.group.all | group_str2 }} </td>
<td class="text-center" title="{% for user_group in user.group.all %} {{ user_group.name }} {% endfor %}"> {{ user.group.all | groups2str }} </td>
<td class="text-center"> {{ user.id | get_role }}</td>
<td class="text-center">{{ user.is_active | bool2str }}</td>
<td class="text-center"><a href="/juser/down_key/?id={{ user.id }}">下载</a></td>