diff --git a/docs/AddUserAsset.py b/docs/AddUserAsset.py index b1750caf6..8ae015568 100644 --- a/docs/AddUserAsset.py +++ b/docs/AddUserAsset.py @@ -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() diff --git a/jasset/urls.py b/jasset/urls.py index 386538a74..602ed6a69 100644 --- a/jasset/urls.py +++ b/jasset/urls.py @@ -12,13 +12,13 @@ urlpatterns = patterns('', url(r'^idc_add/$', add_idc), url(r'^idc_list/$', list_idc), url(r'^idc_detail/$', detail_idc), - url(r'^idc_del/(\d+)/$', del_idc), + url(r'^idc_del/(\w+)/$', del_idc), url(r'^jgroup_add/$', add_group), url(r'^group_edit/$', edit_group), url(r'^jgroup_list/$', list_group), url(r'^group_detail/$', detail_group), url(r'^group_del_host/(\w+)/$', group_del_host), - url(r'^group_del/(\d+)/$', group_del), + url(r'^group_del/(\w+)/$', group_del), url(r'^host_del/(\w+)/$', host_del), url(r'^host_edit/$', host_edit), url(r'^host_edit/batch/$', batch_host_edit), diff --git a/jasset/views.py b/jasset/views.py index 757c9770c..2b8b4bbda 100644 --- a/jasset/views.py +++ b/jasset/views.py @@ -251,7 +251,15 @@ def list_idc(request): def del_idc(request, offset): - IDC.objects.filter(id=offset).delete() + if offset == 'multi': + len_list = request.POST.get("len_list") + for i in range(int(len_list)): + key = "id_list[" + str(i) + "]" + gid = request.POST.get(key) + IDC.objects.filter(id=gid).delete() + else: + gid = int(offset) + IDC.objects.filter(id=gid).delete() return HttpResponseRedirect('/jasset/idc_list/') @@ -354,8 +362,18 @@ def group_del_host(request, offset): def group_del(request, offset): - BisGroup.objects.filter(id=offset).delete() - return HttpResponseRedirect('/jasset/group_list/') + if offset == 'multi': + len_list = request.POST.get("len_list") + for i in range(int(len_list)): + key = "id_list[" + str(i) + "]" + gid = request.POST.get(key) + BisGroup.objects.filter(id=gid).delete() + else: + gid = int(offset) + BisGroup.objects.filter(id=gid).delete() + return HttpResponseRedirect('/jasset/jgroup_list/') + + def host_search(request): diff --git a/jperm/views.py b/jperm/views.py index e1e182352..873c72c1f 100644 --- a/jperm/views.py +++ b/jperm/views.py @@ -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', '') diff --git a/jumpserver.conf b/jumpserver.conf index 9540fa014..a24c2190a 100644 --- a/jumpserver.conf +++ b/jumpserver.conf @@ -8,7 +8,7 @@ password = mysql234 database = jumpserver [ldap] -ldap_enable = 0 +ldap_enable = 1 host_url = ldap://127.0.0.1:389 base_dn = dc=jumpserver, dc=org root_dn = cn=admin,dc=jumpserver,dc=org diff --git a/jumpserver/views.py b/jumpserver/views.py index 09afd48fa..3a114ad57 100644 --- a/jumpserver/views.py +++ b/jumpserver/views.py @@ -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) diff --git a/templates/filter_ajax_api.html b/templates/filter_ajax_api.html new file mode 100644 index 000000000..0698300a9 --- /dev/null +++ b/templates/filter_ajax_api.html @@ -0,0 +1,9 @@ +{% for object in contact_list %} + {% ifequal attr "asset" %} + + {% else %} + + {% endifequal %} + + +{% endfor %} \ No newline at end of file diff --git a/templates/jasset/group_list.html b/templates/jasset/group_list.html index b427266ca..a9e62dc17 100644 --- a/templates/jasset/group_list.html +++ b/templates/jasset/group_list.html @@ -38,7 +38,13 @@ {% endfor %} - {% include 'paginator.html' %} +
+
+ + +
+ {% include 'paginator.html' %} +
@@ -46,4 +52,28 @@ -{% endblock %} \ No newline at end of file + + +{% endblock %} diff --git a/templates/jasset/host_list.html b/templates/jasset/host_list.html index 4f24879c6..805b03c72 100644 --- a/templates/jasset/host_list.html +++ b/templates/jasset/host_list.html @@ -68,7 +68,7 @@ {{ post.port }} {{ login_types|get_item:post.login_type }} {{ post.idc.name }} - {% for group in post.bis_group.all|filter_private %} {{ group }} {% endfor %} + {{ post.bis_group.all | group_str2}} {{ post.is_active|bool2str }} {{ post.date_added|date:"Y-m-d H:i:s" }} {{ post.comment }} @@ -81,7 +81,13 @@ {% endfor %} - {% include 'paginator.html' %} +
+
+ + +
+ {% include 'paginator.html' %} +
diff --git a/templates/jasset/host_search.html b/templates/jasset/host_search.html index 2c9652926..11fe6ce14 100644 --- a/templates/jasset/host_search.html +++ b/templates/jasset/host_search.html @@ -40,38 +40,7 @@ -
-
- -
-
+ {% include 'paginator.html' %} + {% endblock %} \ No newline at end of file diff --git a/templates/jlog/log_offline.html b/templates/jlog/log_offline.html index abd621ac0..914eb04a5 100644 --- a/templates/jlog/log_offline.html +++ b/templates/jlog/log_offline.html @@ -96,7 +96,11 @@ {% endfor %} - {% include 'paginator.html' %} +
+
+
+ {% include 'paginator.html' %} +
diff --git a/templates/jlog/log_online.html b/templates/jlog/log_online.html index 582d08433..a5833c9c6 100644 --- a/templates/jlog/log_online.html +++ b/templates/jlog/log_online.html @@ -96,7 +96,11 @@ {% endfor %} - {% include 'paginator.html' %} +
+
+
+ {% include 'paginator.html' %} +
diff --git a/templates/jperm/perm_add.html b/templates/jperm/perm_add.html index c0a592d85..464181d92 100644 --- a/templates/jperm/perm_add.html +++ b/templates/jperm/perm_add.html @@ -36,18 +36,40 @@ {% if msg %}
{{ msg }}
{% endif %} + + + + + + + + +
-
- -
- - 取个名字方便辨识 -
-
-
- +
+
@@ -77,7 +99,20 @@
- + +
+ +
+
+
+
+
@@ -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()) + }) +} {% endblock %} \ No newline at end of file diff --git a/templates/juser/group_edit.html b/templates/juser/group_edit.html index 9f9b724c1..e565fc5b2 100644 --- a/templates/juser/group_edit.html +++ b/templates/juser/group_edit.html @@ -37,7 +37,7 @@
- +