mirror of https://github.com/jumpserver/jumpserver
修改很多内容,但不打算用
parent
d72d55c965
commit
5c54128f8d
|
@ -108,14 +108,13 @@ def test_add_log():
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# test_add_dept()
|
||||
# test_add_group()
|
||||
# test_add_user()
|
||||
# test_add_idc()
|
||||
# test_add_asset_group()
|
||||
test_add_asset()
|
||||
test_add_dept()
|
||||
test_add_group()
|
||||
test_add_user()
|
||||
test_add_idc()
|
||||
test_add_asset_group()
|
||||
test_add_asset()
|
||||
test_add_log()
|
||||
# test_add_log()
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,16 +1,31 @@
|
|||
from django.db import models
|
||||
from juser.models import UserGroup
|
||||
from jasset.models import BisGroup
|
||||
from juser.models import User, UserGroup, DEPT
|
||||
from jasset.models import Asset, BisGroup
|
||||
|
||||
|
||||
class Perm(models.Model):
|
||||
name = models.CharField(max_length=100)
|
||||
user_group = models.ManyToManyField(UserGroup)
|
||||
asset_group = models.ManyToManyField(BisGroup)
|
||||
comment = models.CharField(max_length=100)
|
||||
user = models.ForeignKey(User)
|
||||
asset = models.ForeignKey(Asset)
|
||||
|
||||
def __unicode__(self):
|
||||
return '%s_%s' % (self.user_group.name, self.asset_group.name)
|
||||
return '%s_%s' % (self.user.name, self.asset.ip)
|
||||
|
||||
|
||||
class DeptPerm(models.Model):
|
||||
dept = models.ForeignKey(DEPT)
|
||||
asset = models.ForeignKey(Asset)
|
||||
|
||||
def __unicode__(self):
|
||||
return '%s_%s' % (self.dept.name, self.asset.ip)
|
||||
|
||||
|
||||
class ShowPerm(models.Model):
|
||||
uid = models.CharField(max_length=500, blank=True, null=True)
|
||||
gid = models.CharField(max_length=500, blank=True, null=True)
|
||||
did = models.CharField(max_length=500, blank=True, null=True)
|
||||
aid = models.CharField(max_length=500, blank=True, null=True)
|
||||
bid = models.CharField(max_length=500, blank=True, null=True)
|
||||
comment = models.CharField(max_length=200, blank=True, null=True)
|
||||
|
||||
|
||||
class CmdGroup(models.Model):
|
||||
|
|
|
@ -42,6 +42,8 @@ def perm_add(request):
|
|||
if request.method == 'GET':
|
||||
user_groups = UserGroup.objects.filter(id__gt=2)
|
||||
asset_groups = BisGroup.objects.all()
|
||||
users = User.objects.all()
|
||||
assets = Asset.objects.all()
|
||||
|
||||
else:
|
||||
name = request.POST.get('name', '')
|
||||
|
|
|
@ -18,7 +18,7 @@ from django.template import RequestContext
|
|||
from django.core.paginator import Paginator, EmptyPage, InvalidPage
|
||||
from django.template import RequestContext
|
||||
|
||||
from juser.models import User
|
||||
from juser.models import User, UserGroup
|
||||
from jlog.models import Log
|
||||
from jasset.models import Asset, BisGroup, IDC
|
||||
|
||||
|
@ -301,6 +301,21 @@ class PyCrypt(object):
|
|||
return plain_text.rstrip('\0')
|
||||
|
||||
|
||||
def filter_ajax_api(request):
|
||||
attr = request.GET.get('attr', 'user')
|
||||
value = request.GET.get('value', '')
|
||||
if attr == 'user':
|
||||
contact_list = User.objects.filter(name__icontains=value)
|
||||
elif attr == "user_group":
|
||||
contact_list = UserGroup.objects.filter(name__icontains=value)
|
||||
elif attr == "asset":
|
||||
contact_list = Asset.objects.filter(ip__icontains=value)
|
||||
elif attr == "asset":
|
||||
contact_list = BisGroup.objects.filter(name__icontains=value)
|
||||
|
||||
return render_to_response('filter_ajax_api.html', locals())
|
||||
|
||||
|
||||
# def perm_user_asset(user_id=None, username=None):
|
||||
# if user_id:
|
||||
# user = User.objects.get(id=user_id)
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
{% for object in contact_list %}
|
||||
{% ifequal attr "asset" %}
|
||||
<option value="{{ contact_list.id }}">{{ contact_list.ip }}</option>
|
||||
{% else %}
|
||||
<option value="{{ contact_list.id }}">{{ contact_list.name }}</option>
|
||||
{% endifequal %}
|
||||
|
||||
|
||||
{% endfor %}
|
|
@ -36,23 +36,45 @@
|
|||
{% if msg %}
|
||||
<div class="alert alert-success text-center">{{ msg }}</div>
|
||||
{% endif %}
|
||||
<select multiple="multiple" id="user_all" style="display: none;">
|
||||
{% for user in users %}
|
||||
<option value="{{ user.id }}">{{ user.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
||||
<select multiple="multiple" id="user_group_all" style="display: none;">
|
||||
{% for user_group in user_groups %}
|
||||
<option value="{{ user_group.id }}">{{ user_group.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
||||
<select multiple="multiple" id="asset_all" style="display: none;">
|
||||
{% for asset in assets %}
|
||||
<option value="{{ asset.id }}">{{ asset.ip }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
||||
<select multiple="multiple" id="asset_group_all" style="display: none;" >
|
||||
{% for asset_group in asset_groups %}
|
||||
<option value="{{ asset_group.id }}">{{ asset_group.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
||||
</select>
|
||||
<div class="row">
|
||||
<div class="form-group">
|
||||
<label for="name" class="col-sm-2 control-label">鎺堟潈鍚<span class="red-fonts">*</span></label>
|
||||
<div class="col-sm-8">
|
||||
<input id="name" name="name" placeholder="鎺堟潈鍚嶇О" type="text" class="form-control">
|
||||
<span class="help-block m-b-none">鍙栦釜鍚嶅瓧鏂逛究杈ㄨ瘑</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="" class="col-sm-2 control-label">鐢ㄦ埛缁<span class="red-fonts">*</span></label>
|
||||
<label for="" class="col-sm-2 control-label" >
|
||||
<select id="user_type" name="user_type" onchange="userChoice(this.value)">
|
||||
<option value="1">鐢ㄦ埛缁</option>
|
||||
<option value="0">鐢ㄦ埛</option>
|
||||
</select>
|
||||
</label>
|
||||
<div class="col-sm-4">
|
||||
<div>
|
||||
<select id="user_groups" name="user_groups" class="form-control" size="5" multiple>
|
||||
<select id="user_groups" name="user_groups" class="form-control" size="10" multiple>
|
||||
{% for user_group in user_groups %}
|
||||
<option value="{{ user_group.id }}">{{ user_group.name }} --- {{ user_group.type|group_type_to_str }}</option>
|
||||
<option value="{{ user_group.id }}">{{ user_group.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
@ -68,7 +90,7 @@
|
|||
|
||||
<div class="col-sm-3">
|
||||
<div>
|
||||
<select id="user_groups_select" name="user_groups_select" class="form-control m-b" size="5" multiple>
|
||||
<select id="user_groups_select" name="user_groups_select" class="form-control m-b" size="10" multiple>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -77,10 +99,23 @@
|
|||
<div class="hr-line-dashed"></div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="" class="col-sm-2 control-label">涓绘満缁<span class="red-fonts">*</span></label>
|
||||
<label for="" class="col-sm-2 control-label">
|
||||
|
||||
</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="comment" name="comment" placeholder="杩囨护" type="text" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="" class="col-sm-2 control-label">
|
||||
<select id="asset_type" name="user_type" onchange="assetChoice(this.value)" >
|
||||
<option value="1">涓绘満缁</option>
|
||||
<option value="0">涓绘満</option>
|
||||
</select>
|
||||
</label>
|
||||
<div class="col-sm-4">
|
||||
<div>
|
||||
<select id="asset_groups" name="asset_groups" class="form-control m-b" size="5" multiple>
|
||||
<select id="asset_groups" name="asset_groups" class="form-control m-b" size="10" multiple>
|
||||
{% for asset_group in asset_groups %}
|
||||
<option value="{{ asset_group.id }}">{{ asset_group.name }}</option>
|
||||
{% endfor %}
|
||||
|
@ -97,7 +132,7 @@
|
|||
|
||||
<div class="col-sm-3">
|
||||
<div>
|
||||
<select id="asset_groups_select" name="asset_groups_select" class="form-control m-b" size="5" multiple>
|
||||
<select id="asset_groups_select" name="asset_groups_select" class="form-control m-b" size="10" multiple>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -168,6 +203,38 @@ $(document).ready(function(){
|
|||
})
|
||||
})
|
||||
})
|
||||
|
||||
function userChoice(value){
|
||||
if (value == "1"){
|
||||
$("#user_groups").children().each(function(){$(this).remove()});
|
||||
$("#user_groups_select").children().each(function(){$(this).remove()});
|
||||
$("#user_group_all").children().each(function(){
|
||||
$("#user_groups").append($(this).clone())
|
||||
})
|
||||
}
|
||||
else
|
||||
$("#user_groups").children().each(function(){$(this).remove()});
|
||||
$("#user_groups_select").children().each(function(){$(this).remove()});
|
||||
$("#user_all").children().each(function(){
|
||||
$("#user_groups").append($(this).clone())
|
||||
})
|
||||
}
|
||||
|
||||
function assetChoice(value){
|
||||
if (value == "1"){
|
||||
$("#asset_groups").children().each(function(){$(this).remove()});
|
||||
$("#asset_groups_select").children().each(function(){$(this).remove()});
|
||||
$("#asset_group_all").children().each(function(){
|
||||
$("#asset_groups").append($(this).clone())
|
||||
})
|
||||
}
|
||||
else
|
||||
$("#asset_groups").children().each(function(){$(this).remove()});
|
||||
$("#asset_groups_select").children().each(function(){$(this).remove()});
|
||||
$("#asset_all").children().each(function(){
|
||||
$("#asset_groups").append($(this).clone())
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
Loading鈥
Reference in New Issue