From acf508f07475c4b9a092a0edfe5f3dc0fedff8bb Mon Sep 17 00:00:00 2001 From: halcyon <864072399@qq.com> Date: Sun, 11 Jan 2015 19:27:21 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E8=B5=84=E4=BA=A7=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=9F=BA=E6=9C=AC=E5=AE=8C=E6=88=90.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jasset/urls.py | 10 +-- jasset/views.py | 104 +++++++++++++++++------------ jumpserver.conf | 8 +-- templates/jasset/jadd.html | 33 +++++++--- templates/jasset/jadd_group.html | 106 ++++++++++++++++++++++++++++++ templates/jasset/jadd_idc.html | 106 ++++++++++++++++++++++++++++++ templates/jasset/jlist.html | 2 +- templates/jasset/jlist_group.html | 59 +++++++++++++++++ templates/jasset/jlist_idc.html | 59 +++++++++++++++++ templates/nav.html | 10 +-- templates/script.html | 16 ++--- 11 files changed, 441 insertions(+), 72 deletions(-) create mode 100644 templates/jasset/jadd_group.html create mode 100644 templates/jasset/jadd_idc.html create mode 100644 templates/jasset/jlist_group.html create mode 100644 templates/jasset/jlist_idc.html diff --git a/jasset/urls.py b/jasset/urls.py index bf108e16b..463d696bc 100644 --- a/jasset/urls.py +++ b/jasset/urls.py @@ -4,8 +4,10 @@ from jasset.views import * urlpatterns = patterns('', url(r'^$', index), - url(r'jadd', jadd), - url(r'jlist', jlist), - url(r'jadd_idc', jadd_idc), - url(r'jlist_idc', jlist_idc), + url(r'host_add', jadd_host), + url(r'host_list', jlist_host), + url(r'idc_add', jadd_idc), + url(r'idc_list', jlist_idc), + url(r'group_add', jadd_group), + url(r'group_list', jlist_group), ) \ No newline at end of file diff --git a/jasset/views.py b/jasset/views.py index 52a95d32e..cfcb1818b 100644 --- a/jasset/views.py +++ b/jasset/views.py @@ -5,9 +5,9 @@ from django.http import HttpResponse from django.template import RequestContext from django.shortcuts import render_to_response from django.http import HttpResponseRedirect -from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger +from django.core.paginator import Paginator, EmptyPage -from models import IDC, Asset, Group +from models import IDC, Asset, BisGroup from connect import PyCrypt, KEY @@ -15,14 +15,12 @@ def index(request): return render_to_response('jasset/jasset.html', ) -def jadd(request): - global j_passwd +def jadd_host(request): + header_title, path1, path2 = '添加主机 | Add Host', '资产管理', '添加主机' groups = [] cryptor = PyCrypt(KEY) eidc = IDC.objects.all() - egroup = Group.objects.all() - is_actived = {'active': 1, 'no_active': 0} - login_typed = {'LDAP': 'L', 'SSH_KEY': 'S', 'PASSWORD': 'P', 'MAP': 'M'} + egroup = BisGroup.objects.all() if request.method == 'POST': j_ip = request.POST.get('j_ip') @@ -32,27 +30,26 @@ def jadd(request): j_group = request.POST.getlist('j_group') j_active = request.POST.get('j_active') j_comment = request.POST.get('j_comment') + + j_idc = IDC.objects.get(name=j_idc) + for group in j_group: + c = BisGroup.objects.get(name=group) + groups.append(c) + + if Asset.objects.filter(ip=str(j_ip)): + emg = u'该IP已存在!' + return render_to_response('jasset/jadd.html', locals(), context_instance=RequestContext(request)) + if j_type == 'MAP': j_user = request.POST.get('j_user') j_password = cryptor.encrypt(request.POST.get('j_password')) j_root = request.POST.get('j_root') j_passwd = cryptor.encrypt(request.POST.get('j_passwd')) - - j_idc = IDC.objects.get(name=j_idc) - for group in j_group: - c = Group.objects.get(name=group) - groups.append(c) - - if Asset.objects.filter(ip=str(j_ip)): - emg = u'该IP已存在!' - return render_to_response('jasset/jadd.html', {'emg': emg, 'j_ip': j_ip}) - - elif j_type == 'MAP': a = Asset(ip=j_ip, port=j_port, - login_type=login_typed[j_type], + login_type=j_type, idc=j_idc, - is_active=int(is_actived[j_active]), + is_active=int(j_active), comment=j_comment, username_common=j_user, password_common=j_password, @@ -61,24 +58,19 @@ def jadd(request): else: a = Asset(ip=j_ip, port=j_port, - login_type=login_typed[j_type], + login_type=j_type, idc=j_idc, - is_active=int(is_actived[j_active]), + is_active=int(j_active), comment=j_comment) a.save() - a.group = groups + a.bis_group = groups a.save() - return render_to_response('jasset/jadd.html', - {'header_title': u'添加主机 | Add Host', - 'path1': '资产管理', - 'path2': '添加主机', - 'eidc': eidc, - 'egroup': egroup, } - ) + return render_to_response('jasset/jadd.html', locals(), context_instance=RequestContext(request)) -def jlist(request): +def jlist_host(request): + header_title, path1, path2 = '查看主机 | List Host', '资产管理', '查看主机' posts = contact_list = Asset.objects.all().order_by('ip') print posts paginator = Paginator(contact_list, 5) @@ -92,19 +84,49 @@ def jlist(request): except (EmptyPage, InvalidPage): contacts = paginator.page(paginator.num_pages) - return render_to_response('jasset/jlist.html', - {"contacts": contacts, - 'p': paginator, - 'posts': posts, - 'header_title': u'查看主机 | List Host', - 'path1': '资产管理', - 'path2': '查看主机', }, - context_instance=RequestContext(request)) + return render_to_response('jasset/jlist.html', locals(), context_instance=RequestContext(request)) def jadd_idc(request): - pass + header_title, path1, path2 = '添加IDC | Add IDC', '资产管理', '添加IDC' + if request.method == 'POST': + j_idc = request.POST.get('j_idc') + j_comment = request.POST.get('j_comment') + print j_idc,j_comment + + if IDC.objects.filter(name=j_idc): + emg = u'该IDC已存在!' + return render_to_response('jasset/jadd_idc.html', + {'emg': emg, 'j_idc': j_idc, 'j_comment': j_comment,}, + context_instance=RequestContext(request)) + else: + IDC.objects.create(name=j_idc, comment=j_comment) + + return render_to_response('jasset/jadd_idc.html', locals(), context_instance=RequestContext(request)) def jlist_idc(request): - pass \ No newline at end of file + header_title, path1, path2 = '查看IDC | List Host', '资产管理', '查看IDC' + posts = IDC.objects.all().order_by('id') + return render_to_response('jasset/jlist_idc.html', locals(), context_instance=RequestContext(request)) + + +def jadd_group(request): + header_title, path1, path2 = '添加业务组 | Add Group', '资产管理', '添加业务组' + if request.method == 'POST': + j_group = request.POST.get('j_group') + j_comment = request.POST.get('j_comment') + + if BisGroup.objects.filter(name=j_group): + emg = u'该业务组已存在!' + return render_to_response('jasset/jadd_group.html', locals(), context_instance=RequestContext(request)) + else: + BisGroup.objects.create(name=j_group, comment=j_comment) + + return render_to_response('jasset/jadd_group.html', locals(), context_instance=RequestContext(request)) + + +def jlist_group(request): + header_title, path1, path2 = '添加业务组 | Add Group', '资产管理', '查看业务组' + posts = BisGroup.objects.all().order_by('id') + return render_to_response('jasset/jlist_group.html', locals(), context_instance=RequestContext(request)) \ No newline at end of file diff --git a/jumpserver.conf b/jumpserver.conf index f54c84c15..1523fb3ba 100644 --- a/jumpserver.conf +++ b/jumpserver.conf @@ -8,10 +8,10 @@ password = mysql234 database = jumpserver [ldap] -host_url = ldap://127.0.0.1:389 -base_dn = dc=jumpserver,dc=org -root_dn = cn=admin,dc=jumpserver,dc=org -root_pw = secret234 +host_url = ldap://192.168.8.60:389 +base_dn = dc=fengxing,dc=org +root_dn = cn=admin,dc=fengxing,dc=org +root_pw = 123456 [web] key = 88aaaf7ffe3c6c04 diff --git a/templates/jasset/jadd.html b/templates/jasset/jadd.html index 6d3985beb..bae139d69 100644 --- a/templates/jasset/jadd.html +++ b/templates/jasset/jadd.html @@ -5,7 +5,13 @@
-
+
+ 请选择添加内容: + 添加主机 + 添加IDC + 添加业务组 +
+
填写主机基本信息
@@ -37,16 +43,16 @@
-
+
-
-
-
-
+
+
+
+
+ + + + + + + + {% endblock %} \ No newline at end of file diff --git a/templates/jasset/jadd_group.html b/templates/jasset/jadd_group.html new file mode 100644 index 000000000..179794ebb --- /dev/null +++ b/templates/jasset/jadd_group.html @@ -0,0 +1,106 @@ +{% extends 'base.html' %} +{% block content %} +{% include 'nav_cat_bar.html' %} +
+
+
+
+ + +
+ {% if emg %} +
{{ emg }}
+ {% endif %} +
+
+
+
+ +
+
+
+
+ +
+
+
+ + +
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + +{% endblock %} \ No newline at end of file diff --git a/templates/jasset/jadd_idc.html b/templates/jasset/jadd_idc.html new file mode 100644 index 000000000..5a2b66f72 --- /dev/null +++ b/templates/jasset/jadd_idc.html @@ -0,0 +1,106 @@ +{% extends 'base.html' %} +{% block content %} +{% include 'nav_cat_bar.html' %} +
+
+
+
+
+
填写IDC基本信息
+ +
+ +
+ {% if emg %} +
{{ emg }}
+ {% endif %} +
+
+
+
+ +
+
+
+
+ +
+
+
+ + +
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + +{% endblock %} \ No newline at end of file diff --git a/templates/jasset/jlist.html b/templates/jasset/jlist.html index 67ff7b909..5d1c3ed75 100644 --- a/templates/jasset/jlist.html +++ b/templates/jasset/jlist.html @@ -52,7 +52,7 @@ {{ post.login_type}} {{ post.idc.name }} - {% for group in post.group.all %} + {% for group in post.bis_group.all %} {{ group }} {% endfor %} diff --git a/templates/jasset/jlist_group.html b/templates/jasset/jlist_group.html new file mode 100644 index 000000000..182dd2b23 --- /dev/null +++ b/templates/jasset/jlist_group.html @@ -0,0 +1,59 @@ +{% extends 'base.html' %} +{% block content %} +{% include 'nav_cat_bar.html' %} + +
+
+
+
+
+
IDC详细信息列表
+ +
+ +
+ + + + + + + + + + + + {% for post in posts %} + + + + + + {% endfor %} + +
ID 机房名 备注
{{ post.id }} {{ post.name }} {{ post.comment }}
+
+
+
+
+
+ +{% endblock %} \ No newline at end of file diff --git a/templates/jasset/jlist_idc.html b/templates/jasset/jlist_idc.html new file mode 100644 index 000000000..182dd2b23 --- /dev/null +++ b/templates/jasset/jlist_idc.html @@ -0,0 +1,59 @@ +{% extends 'base.html' %} +{% block content %} +{% include 'nav_cat_bar.html' %} + +
+
+
+
+
+
IDC详细信息列表
+ +
+ +
+ + + + + + + + + + + + {% for post in posts %} + + + + + + {% endfor %} + +
ID 机房名 备注
{{ post.id }} {{ post.name }} {{ post.comment }}
+
+
+
+
+
+ +{% endblock %} \ No newline at end of file diff --git a/templates/nav.html b/templates/nav.html index 32d3b3165..0b830731d 100644 --- a/templates/nav.html +++ b/templates/nav.html @@ -23,10 +23,12 @@
  • 资产管理
  • diff --git a/templates/script.html b/templates/script.html index 490d4eb88..da70b090e 100644 --- a/templates/script.html +++ b/templates/script.html @@ -17,12 +17,12 @@ - + From 6b95c7ed6f3cf2a33b80ac4c7160f6e3c3a85646 Mon Sep 17 00:00:00 2001 From: halcyon <864072399@qq.com> Date: Wed, 14 Jan 2015 16:39:57 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E8=B5=84=E4=BA=A7=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jasset/urls.py | 13 +- jasset/views.py | 11 +- static/css/colorbox.css | 50 ++ static/css/images/controls.png | Bin 0 -> 503 bytes static/css/images/loading.gif | Bin 0 -> 6244 bytes static/js/jquery.colorbox.js | 1090 ++++++++++++++++++++++++++++++++ templates/base.html | 3 +- templates/css_js.html | 33 + templates/jasset/jadd.html | 14 +- templates/jasset/jlist.html | 10 +- templates/jasset/jlist_ip.html | 60 ++ templates/link_css.html | 1 + templates/script.html | 3 + 13 files changed, 1270 insertions(+), 18 deletions(-) create mode 100755 static/css/colorbox.css create mode 100755 static/css/images/controls.png create mode 100755 static/css/images/loading.gif create mode 100755 static/js/jquery.colorbox.js create mode 100644 templates/css_js.html create mode 100644 templates/jasset/jlist_ip.html diff --git a/jasset/urls.py b/jasset/urls.py index 463d696bc..e60b47f71 100644 --- a/jasset/urls.py +++ b/jasset/urls.py @@ -4,10 +4,11 @@ from jasset.views import * urlpatterns = patterns('', url(r'^$', index), - url(r'host_add', jadd_host), - url(r'host_list', jlist_host), - url(r'idc_add', jadd_idc), - url(r'idc_list', jlist_idc), - url(r'group_add', jadd_group), - url(r'group_list', jlist_group), + url(r'host_add/$', jadd_host), + url(r'host_list/$', jlist_host), + url(r"(\d+.\d+.\d+.\d+)/$",jlist_ip), + url(r'idc_add/$', jadd_idc), + url(r'idc_list/$', jlist_idc), + url(r'group_add/$', jadd_group), + url(r'group_list/$', jlist_group), ) \ No newline at end of file diff --git a/jasset/views.py b/jasset/views.py index cfcb1818b..7419519a8 100644 --- a/jasset/views.py +++ b/jasset/views.py @@ -1,10 +1,6 @@ # coding:utf-8 -import datetime -from django.shortcuts import render -from django.http import HttpResponse from django.template import RequestContext from django.shortcuts import render_to_response -from django.http import HttpResponseRedirect from django.core.paginator import Paginator, EmptyPage from models import IDC, Asset, BisGroup @@ -73,7 +69,7 @@ def jlist_host(request): header_title, path1, path2 = '查看主机 | List Host', '资产管理', '查看主机' posts = contact_list = Asset.objects.all().order_by('ip') print posts - paginator = Paginator(contact_list, 5) + p = paginator = Paginator(contact_list, 5) try: page = int(request.GET.get('page', '1')) except ValueError: @@ -86,6 +82,11 @@ def jlist_host(request): return render_to_response('jasset/jlist.html', locals(), context_instance=RequestContext(request)) +def jlist_ip(request, offset): + header_title, path1, path2 = '主机详细信息 | Host Detail.', '资产管理', '主机详情' + print offset + post = contact_list = Asset.objects.get(ip = str(offset)) + return render_to_response('jasset/jlist_ip.html', locals(), context_instance=RequestContext(request)) def jadd_idc(request): header_title, path1, path2 = '添加IDC | Add IDC', '资产管理', '添加IDC' diff --git a/static/css/colorbox.css b/static/css/colorbox.css new file mode 100755 index 000000000..0a6710404 --- /dev/null +++ b/static/css/colorbox.css @@ -0,0 +1,50 @@ +/* + Colorbox Core Style: + The following CSS is consistent between example themes and should not be altered. +*/ +#colorbox, #cboxOverlay, #cboxWrapper{position:absolute; top:0; left:0; z-index:9999; overflow:hidden;} +#cboxWrapper {max-width:none;} +#cboxOverlay{position:fixed; width:100%; height:100%;} +#cboxMiddleLeft, #cboxBottomLeft{clear:left;} +#cboxContent{position:relative;} +#cboxLoadedContent{overflow:auto; -webkit-overflow-scrolling: touch;} +#cboxTitle{margin:0;} +#cboxLoadingOverlay, #cboxLoadingGraphic{position:absolute; top:0; left:0; width:100%; height:100%;} +#cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow{cursor:pointer;} +.cboxPhoto{float:left; margin:auto; border:0; display:block; max-width:none; -ms-interpolation-mode:bicubic;} +.cboxIframe{width:100%; height:100%; display:block; border:0; padding:0; margin:0;} +#colorbox, #cboxContent, #cboxLoadedContent{box-sizing:content-box; -moz-box-sizing:content-box; -webkit-box-sizing:content-box;} + +/* + User Style: + Change the following styles to modify the appearance of Colorbox. They are + ordered & tabbed in a way that represents the nesting of the generated HTML. +*/ +#cboxOverlay{background:#fff; opacity: 0.9; filter: alpha(opacity = 90);} +#colorbox{outline:0;} + #cboxContent{margin-top:32px; overflow:visible; background:#000;} + .cboxIframe{background:#fff;} + #cboxError{padding:50px; border:1px solid #ccc;} + #cboxLoadedContent{background:#000; padding:1px;} + #cboxLoadingGraphic{background:url(images/loading.gif) no-repeat center center;} + #cboxLoadingOverlay{background:#000;} + #cboxTitle{position:absolute; top:-22px; left:0; color:#000;} + #cboxCurrent{position:absolute; top:-22px; right:205px; text-indent:-9999px;} + + /* these elements are buttons, and may need to have additional styles reset to avoid unwanted base styles */ + #cboxPrevious, #cboxNext, #cboxSlideshow, #cboxClose {border:0; padding:0; margin:0; overflow:visible; text-indent:-9999px; width:20px; height:20px; position:absolute; top:-20px; background:url(images/controls.png) no-repeat 0 0;} + + /* avoid outlines on :active (mouseclick), but preserve outlines on :focus (tabbed navigating) */ + #cboxPrevious:active, #cboxNext:active, #cboxSlideshow:active, #cboxClose:active {outline:0;} + + #cboxPrevious{background-position:0px 0px; right:44px;} + #cboxPrevious:hover{background-position:0px -25px;} + #cboxNext{background-position:-25px 0px; right:22px;} + #cboxNext:hover{background-position:-25px -25px;} + #cboxClose{background-position:-50px 0px; right:0;} + #cboxClose:hover{background-position:-50px -25px;} + .cboxSlideshow_on #cboxPrevious, .cboxSlideshow_off #cboxPrevious{right:66px;} + .cboxSlideshow_on #cboxSlideshow{background-position:-75px -25px; right:44px;} + .cboxSlideshow_on #cboxSlideshow:hover{background-position:-100px -25px;} + .cboxSlideshow_off #cboxSlideshow{background-position:-100px 0px; right:44px;} + .cboxSlideshow_off #cboxSlideshow:hover{background-position:-75px -25px;} diff --git a/static/css/images/controls.png b/static/css/images/controls.png new file mode 100755 index 0000000000000000000000000000000000000000..36f5269929f735d3d3d14424f03fd7f3010045c7 GIT binary patch literal 503 zcmVQvGG};B5A2d>; z`je}=1^Jhm`qW>d=5@(X;wfqp5zC7xY5KLHsKHI)ugz!V^z|WQ5G@grgb<^mpB`H} zW~d_aZoY|?qhnAH9ubM?Q+{M8B1Eja$*vFiawj$>< zcl;^3jy`qk{QLUWuSQZQ=j@%)I5_6g@dSx z);f7w8#O&GAZlPy__Uae1XCY6Ako4ARxAK3dN9z^Aww0Bck@k7Ia&vGG5}z${g5Ad z{MiD4x|{48%9o(%@R3Gz2PL<@OID4C8ZWh$*srh9)Zg$ybRA6W*4^*xOTRAkPN%^q zZ-Ek=bK*L>?9gA*5*_QWl5aNqSGE@Kn002ovPDHLkV1k`%>Zt$# literal 0 HcmV?d00001 diff --git a/static/css/images/loading.gif b/static/css/images/loading.gif new file mode 100755 index 0000000000000000000000000000000000000000..a32df5c0881b563e18f3660758009a4aec47a5a0 GIT binary patch literal 6244 zcmZu#d010-y8dMkfrNxW2!|wugzaR5ummJ52>}uU1cX4?466u;EaFmUdgsA&63D`m zfXJdEB6X`;(Q4Ie9j$wB+fmyhZS9P;w%5_=OzX5Www-x;57@=dbMx=XAMgAA-tYU~ z@6+eyrmUzJ0wMT^7R=AjCnY6mG#VO>78e&6930H$avK{PGcq!CI$cFYMOj%{dwaW5 zsiaUSJv}`Ng<|8zjZ;%oVzKzmH{YC@nF$XMKX~vUlgXT%oW$X9R;#tHt}Ze%l0YD& zrltl31>LxDBRV>o#bODCLZ{O?K0bcv(4pV`?souy{{DVHKR+s!N+OZ!>+4^7>7{qx zd8ebJqot)~&6+jS)6+Y5?qo0+1qB6r_Ut))_;5~6j$W^CYilbmE*=^hTD^L8O-+r- zWJ*g*GZ+k2RaLLO_S(voD|tMg#bSBut+xaMfzfD;iHSLR@?>dg>E6A2j~zR9>(;H! zn>X*@zh5SkX|-CH%LPG@-EL1#PJZ{@cYpJn-y|d?c)eaWn|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@-L!_%}TZ&Cc@U&qM5+7V!2*Pl@?n2QK-13dG96~b)* literal 0 HcmV?d00001 diff --git a/static/js/jquery.colorbox.js b/static/js/jquery.colorbox.js new file mode 100755 index 000000000..c0348849e --- /dev/null +++ b/static/js/jquery.colorbox.js @@ -0,0 +1,1090 @@ +/*! + Colorbox 1.5.14 + license: MIT + http://www.jacklmoore.com/colorbox +*/ +(function ($, document, window) { + var + // Default settings object. + // See http://jacklmoore.com/colorbox for details. + defaults = { + // data sources + html: false, + photo: false, + iframe: false, + inline: false, + + // behavior and appearance + transition: "elastic", + speed: 300, + fadeOut: 300, + width: false, + initialWidth: "600", + innerWidth: false, + maxWidth: false, + height: false, + initialHeight: "450", + innerHeight: false, + maxHeight: false, + scalePhotos: true, + scrolling: true, + opacity: 0.9, + preloading: true, + className: false, + overlayClose: true, + escKey: true, + arrowKey: true, + top: false, + bottom: false, + left: false, + right: false, + fixed: false, + data: undefined, + closeButton: true, + fastIframe: true, + open: false, + reposition: true, + loop: true, + slideshow: false, + slideshowAuto: true, + slideshowSpeed: 2500, + slideshowStart: "start slideshow", + slideshowStop: "stop slideshow", + photoRegex: /\.(gif|png|jp(e|g|eg)|bmp|ico|webp|jxr|svg)((#|\?).*)?$/i, + + // alternate image paths for high-res displays + retinaImage: false, + retinaUrl: false, + retinaSuffix: '@2x.$1', + + // internationalization + current: "image {current} of {total}", + previous: "previous", + next: "next", + close: "close", + xhrError: "This content failed to load.", + imgError: "This image failed to load.", + + // accessbility + returnFocus: true, + trapFocus: true, + + // callbacks + onOpen: false, + onLoad: false, + onComplete: false, + onCleanup: false, + onClosed: false, + + rel: function() { + return this.rel; + }, + href: function() { + // using this.href would give the absolute url, when the href may have been inteded as a selector (e.g. '#container') + return $(this).attr('href'); + }, + title: function() { + return this.title; + } + }, + + // Abstracting the HTML and event identifiers for easy rebranding + colorbox = 'colorbox', + prefix = 'cbox', + boxElement = prefix + 'Element', + + // Events + event_open = prefix + '_open', + event_load = prefix + '_load', + event_complete = prefix + '_complete', + event_cleanup = prefix + '_cleanup', + event_closed = prefix + '_closed', + event_purge = prefix + '_purge', + + // Cached jQuery Object Variables + $overlay, + $box, + $wrap, + $content, + $topBorder, + $leftBorder, + $rightBorder, + $bottomBorder, + $related, + $window, + $loaded, + $loadingBay, + $loadingOverlay, + $title, + $current, + $slideshow, + $next, + $prev, + $close, + $groupControls, + $events = $(''), // $({}) would be prefered, but there is an issue with jQuery 1.4.2 + + // Variables for cached values or use across multiple functions + settings, + interfaceHeight, + interfaceWidth, + loadedHeight, + loadedWidth, + index, + photo, + open, + active, + closing, + loadingTimer, + publicMethod, + div = "div", + requests = 0, + previousCSS = {}, + init; + + // **************** + // HELPER FUNCTIONS + // **************** + + // Convenience function for creating new jQuery objects + function $tag(tag, id, css) { + var element = document.createElement(tag); + + if (id) { + element.id = prefix + id; + } + + if (css) { + element.style.cssText = css; + } + + return $(element); + } + + // Get the window height using innerHeight when available to avoid an issue with iOS + // http://bugs.jquery.com/ticket/6724 + function winheight() { + return window.innerHeight ? window.innerHeight : $(window).height(); + } + + function Settings(element, options) { + if (options !== Object(options)) { + options = {}; + } + + this.cache = {}; + this.el = element; + + this.value = function(key) { + var dataAttr; + + if (this.cache[key] === undefined) { + dataAttr = $(this.el).attr('data-cbox-'+key); + + if (dataAttr !== undefined) { + this.cache[key] = dataAttr; + } else if (options[key] !== undefined) { + this.cache[key] = options[key]; + } else if (defaults[key] !== undefined) { + this.cache[key] = defaults[key]; + } + } + + return this.cache[key]; + }; + + this.get = function(key) { + var value = this.value(key); + return $.isFunction(value) ? value.call(this.el, this) : value; + }; + } + + // Determine the next and previous members in a group. + function getIndex(increment) { + var + max = $related.length, + newIndex = (index + increment) % max; + + return (newIndex < 0) ? max + newIndex : newIndex; + } + + // Convert '%' and 'px' values to integers + function setSize(size, dimension) { + return Math.round((/%/.test(size) ? ((dimension === 'x' ? $window.width() : winheight()) / 100) : 1) * parseInt(size, 10)); + } + + // Checks an href to see if it is a photo. + // There is a force photo option (photo: true) for hrefs that cannot be matched by the regex. + function isImage(settings, url) { + return settings.get('photo') || settings.get('photoRegex').test(url); + } + + function retinaUrl(settings, url) { + return settings.get('retinaUrl') && window.devicePixelRatio > 1 ? url.replace(settings.get('photoRegex'), settings.get('retinaSuffix')) : url; + } + + function trapFocus(e) { + if ('contains' in $box[0] && !$box[0].contains(e.target) && e.target !== $overlay[0]) { + e.stopPropagation(); + $box.focus(); + } + } + + function setClass(str) { + if (setClass.str !== str) { + $box.add($overlay).removeClass(setClass.str).addClass(str); + setClass.str = str; + } + } + + function getRelated(rel) { + index = 0; + + if (rel && rel !== false && rel !== 'nofollow') { + $related = $('.' + boxElement).filter(function () { + var options = $.data(this, colorbox); + var settings = new Settings(this, options); + return (settings.get('rel') === rel); + }); + index = $related.index(settings.el); + + // Check direct calls to Colorbox. + if (index === -1) { + $related = $related.add(settings.el); + index = $related.length - 1; + } + } else { + $related = $(settings.el); + } + } + + function trigger(event) { + // for external use + $(document).trigger(event); + // for internal use + $events.triggerHandler(event); + } + + var slideshow = (function(){ + var active, + className = prefix + "Slideshow_", + click = "click." + prefix, + timeOut; + + function clear () { + clearTimeout(timeOut); + } + + function set() { + if (settings.get('loop') || $related[index + 1]) { + clear(); + timeOut = setTimeout(publicMethod.next, settings.get('slideshowSpeed')); + } + } + + function start() { + $slideshow + .html(settings.get('slideshowStop')) + .unbind(click) + .one(click, stop); + + $events + .bind(event_complete, set) + .bind(event_load, clear); + + $box.removeClass(className + "off").addClass(className + "on"); + } + + function stop() { + clear(); + + $events + .unbind(event_complete, set) + .unbind(event_load, clear); + + $slideshow + .html(settings.get('slideshowStart')) + .unbind(click) + .one(click, function () { + publicMethod.next(); + start(); + }); + + $box.removeClass(className + "on").addClass(className + "off"); + } + + function reset() { + active = false; + $slideshow.hide(); + clear(); + $events + .unbind(event_complete, set) + .unbind(event_load, clear); + $box.removeClass(className + "off " + className + "on"); + } + + return function(){ + if (active) { + if (!settings.get('slideshow')) { + $events.unbind(event_cleanup, reset); + reset(); + } + } else { + if (settings.get('slideshow') && $related[1]) { + active = true; + $events.one(event_cleanup, reset); + if (settings.get('slideshowAuto')) { + start(); + } else { + stop(); + } + $slideshow.show(); + } + } + }; + + }()); + + + function launch(element) { + var options; + + if (!closing) { + + options = $(element).data(colorbox); + + settings = new Settings(element, options); + + getRelated(settings.get('rel')); + + if (!open) { + open = active = true; // Prevents the page-change action from queuing up if the visitor holds down the left or right keys. + + setClass(settings.get('className')); + + // Show colorbox so the sizes can be calculated in older versions of jQuery + $box.css({visibility:'hidden', display:'block', opacity:''}); + + $loaded = $tag(div, 'LoadedContent', 'width:0; height:0; overflow:hidden; visibility:hidden'); + $content.css({width:'', height:''}).append($loaded); + + // Cache values needed for size calculations + interfaceHeight = $topBorder.height() + $bottomBorder.height() + $content.outerHeight(true) - $content.height(); + interfaceWidth = $leftBorder.width() + $rightBorder.width() + $content.outerWidth(true) - $content.width(); + loadedHeight = $loaded.outerHeight(true); + loadedWidth = $loaded.outerWidth(true); + + // Opens inital empty Colorbox prior to content being loaded. + var initialWidth = setSize(settings.get('initialWidth'), 'x'); + var initialHeight = setSize(settings.get('initialHeight'), 'y'); + var maxWidth = settings.get('maxWidth'); + var maxHeight = settings.get('maxHeight'); + + settings.w = (maxWidth !== false ? Math.min(initialWidth, setSize(maxWidth, 'x')) : initialWidth) - loadedWidth - interfaceWidth; + settings.h = (maxHeight !== false ? Math.min(initialHeight, setSize(maxHeight, 'y')) : initialHeight) - loadedHeight - interfaceHeight; + + $loaded.css({width:'', height:settings.h}); + publicMethod.position(); + + trigger(event_open); + settings.get('onOpen'); + + $groupControls.add($title).hide(); + + $box.focus(); + + if (settings.get('trapFocus')) { + // Confine focus to the modal + // Uses event capturing that is not supported in IE8- + if (document.addEventListener) { + + document.addEventListener('focus', trapFocus, true); + + $events.one(event_closed, function () { + document.removeEventListener('focus', trapFocus, true); + }); + } + } + + // Return focus on closing + if (settings.get('returnFocus')) { + $events.one(event_closed, function () { + $(settings.el).focus(); + }); + } + } + + var opacity = parseFloat(settings.get('opacity')); + $overlay.css({ + opacity: opacity === opacity ? opacity : '', + cursor: settings.get('overlayClose') ? 'pointer' : '', + visibility: 'visible' + }).show(); + + if (settings.get('closeButton')) { + $close.html(settings.get('close')).appendTo($content); + } else { + $close.appendTo('
    '); // replace with .detach() when dropping jQuery < 1.4 + } + + load(); + } + } + + // Colorbox's markup needs to be added to the DOM prior to being called + // so that the browser will go ahead and load the CSS background images. + function appendHTML() { + if (!$box) { + init = false; + $window = $(window); + $box = $tag(div).attr({ + id: colorbox, + 'class': $.support.opacity === false ? prefix + 'IE' : '', // class for optional IE8 & lower targeted CSS. + role: 'dialog', + tabindex: '-1' + }).hide(); + $overlay = $tag(div, "Overlay").hide(); + $loadingOverlay = $([$tag(div, "LoadingOverlay")[0],$tag(div, "LoadingGraphic")[0]]); + $wrap = $tag(div, "Wrapper"); + $content = $tag(div, "Content").append( + $title = $tag(div, "Title"), + $current = $tag(div, "Current"), + $prev = $('
    - {% include 'script.html' %} + diff --git a/templates/css_js.html b/templates/css_js.html new file mode 100644 index 000000000..9004ffc1e --- /dev/null +++ b/templates/css_js.html @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/templates/jasset/jadd.html b/templates/jasset/jadd.html index bae139d69..fe5ecd0de 100644 --- a/templates/jasset/jadd.html +++ b/templates/jasset/jadd.html @@ -7,9 +7,9 @@ +
    + addidc +
    -
    +
    {% if emg %}
    {{ emg }}
    {% endif %} @@ -146,6 +149,9 @@ var showFlag={}; if(showFlag.j_type=="MAP"){ document.getElementById("a1").style.display=""; } + else if(showFlag.addidc=="addidc"){ + document.getElementById("addidc").style.display=""; + } else{ document.getElementById("a1").style.display="none"; }}; diff --git a/templates/jasset/jlist.html b/templates/jasset/jlist.html index 5d1c3ed75..7798b3a2a 100644 --- a/templates/jasset/jlist.html +++ b/templates/jasset/jlist.html @@ -47,9 +47,9 @@ {% for post in contacts.object_list %} - {{ post.ip }} + {{ post.ip }} {{ post.port }} - {{ post.login_type}} + {{ post.get_login_type}} {{ post.idc.name }} {% for group in post.bis_group.all %} @@ -85,4 +85,10 @@
    + + {% endblock %} \ No newline at end of file diff --git a/templates/jasset/jlist_ip.html b/templates/jasset/jlist_ip.html new file mode 100644 index 000000000..11f975edb --- /dev/null +++ b/templates/jasset/jlist_ip.html @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + +
    +
    +

    {{ offset }}主机详情

    + + + + + + + + + + + + + + + + + + + + + + + +
    IP地址 端口号 登录方式 所属IDC 所属业务组 添加时间 备注
    {{ post.ip }} {{ post.port }} {{ post.get_login_type}} {{ post.idc.name }} + {% for group in post.bis_group.all %} + {{ group }} + {% endfor %} + {{ post.date_added }} {{ post.comment }}
    + 是否激活: {{ post.is_active }} +
    +
    + + \ No newline at end of file diff --git a/templates/link_css.html b/templates/link_css.html index 26fd0e087..2d795dece 100644 --- a/templates/link_css.html +++ b/templates/link_css.html @@ -3,3 +3,4 @@ + \ No newline at end of file diff --git a/templates/script.html b/templates/script.html index da70b090e..7d22a71b4 100644 --- a/templates/script.html +++ b/templates/script.html @@ -26,3 +26,6 @@ + + + From 7863a6853c5cc26f49d8a48ddca79cabfec966af Mon Sep 17 00:00:00 2001 From: halcyon <864072399@qq.com> Date: Mon, 19 Jan 2015 10:09:16 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=B5=84=E4=BA=A7=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=9F=BA=E6=9C=AC=E5=AE=8C=E6=88=90=EF=BC=8C?= =?UTF-8?q?=E5=B0=9A=E6=9C=89=E9=83=A8=E5=88=86=E5=B0=8Fbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jasset/urls.py | 19 +- jasset/views.py | 137 ++++++++--- jumpserver/templatetags/mytags.py | 4 + juser/views.py | 1 - .../{jadd_group.html => group_add.html} | 68 ++---- .../{jlist_idc.html => group_list.html} | 20 +- templates/jasset/{jadd.html => host_add.html} | 120 +++++----- templates/jasset/host_edit.html | 215 ++++++++++++++++++ .../jasset/{jlist.html => host_list.html} | 41 ++-- .../jasset/{jadd_idc.html => idc_add.html} | 67 ++---- .../{jlist_group.html => idc_list.html} | 20 +- templates/jasset/test.html | 30 +++ 12 files changed, 512 insertions(+), 230 deletions(-) rename templates/jasset/{jadd_group.html => group_add.html} (60%) rename templates/jasset/{jlist_idc.html => group_list.html} (62%) rename templates/jasset/{jadd.html => host_add.html} (70%) create mode 100644 templates/jasset/host_edit.html rename templates/jasset/{jlist.html => host_list.html} (60%) rename templates/jasset/{jadd_idc.html => idc_add.html} (64%) rename templates/jasset/{jlist_group.html => idc_list.html} (62%) create mode 100644 templates/jasset/test.html diff --git a/jasset/urls.py b/jasset/urls.py index e60b47f71..280ed090c 100644 --- a/jasset/urls.py +++ b/jasset/urls.py @@ -4,11 +4,16 @@ from jasset.views import * urlpatterns = patterns('', url(r'^$', index), - url(r'host_add/$', jadd_host), - url(r'host_list/$', jlist_host), - url(r"(\d+.\d+.\d+.\d+)/$",jlist_ip), - url(r'idc_add/$', jadd_idc), - url(r'idc_list/$', jlist_idc), - url(r'group_add/$', jadd_group), - url(r'group_list/$', jlist_group), + url(r'^host_add/$', jadd_host), + url(r'^host_list/$', jlist_host), + url(r"^(\d+.\d+.\d+.\d+)/$",jlist_ip), + url(r'^idc_add/$', jadd_idc), + url(r'^idc_list/$', jlist_idc), + url(r'^idc_del/(\d+)/$', idc_del), + url(r'^group_add/$', jadd_group), + url(r'^group_list/$', jlist_group), + url(r'^group_del/(\d+)/$', group_del), + url(r'^host_del/(\d+.\d+.\d+.\d+)/$', host_del), + url(r'^host_edit/(\d+.\d+.\d+.\d+)/$', host_edit), + url(r'^test/$', test), ) \ No newline at end of file diff --git a/jasset/views.py b/jasset/views.py index 8472d3d3f..02f887b69 100644 --- a/jasset/views.py +++ b/jasset/views.py @@ -1,26 +1,25 @@ # coding:utf-8 +from django.http import HttpResponseRedirect from django.template import RequestContext from django.shortcuts import render_to_response from django.core.paginator import Paginator, EmptyPage from models import IDC, Asset, BisGroup -from models import IDC, Asset, UserGroup from connect import PyCrypt, KEY +cryptor = PyCrypt(KEY) + def index(request): return render_to_response('jasset/jasset.html', ) def jadd_host(request): - header_title, path1, path2 = '添加主机 | Add Host', '资产管理', '添加主机' + login_types = {'L': 'LDAP', 'S': 'SSH_KEY', 'P': 'PASSWORD', 'M': 'MAP'} + header_title, path1, path2 = u'添加主机 | Add Host', u'资产管理', u'添加主机' groups = [] - cryptor = PyCrypt(KEY) eidc = IDC.objects.all() egroup = BisGroup.objects.all() - egroup = UserGroup.objects.all() - is_actived = {'active': 1, 'no_active': 0} - login_typed = {'LDAP': 'L', 'SSH_KEY': 'S', 'PASSWORD': 'P', 'MAP': 'M'} if request.method == 'POST': j_ip = request.POST.get('j_ip') @@ -30,26 +29,23 @@ def jadd_host(request): j_group = request.POST.getlist('j_group') j_active = request.POST.get('j_active') j_comment = request.POST.get('j_comment') - j_idc = IDC.objects.get(name=j_idc) + for group in j_group: c = BisGroup.objects.get(name=group) - c = UserGroup.objects.get(name=group) groups.append(c) if Asset.objects.filter(ip=str(j_ip)): emg = u'该IP已存在!' - return render_to_response('jasset/jadd.html', locals(), context_instance=RequestContext(request)) + return render_to_response('jasset/host_add.html', locals(), context_instance=RequestContext(request)) - if j_type == 'MAP': + if j_type == 'M': j_user = request.POST.get('j_user') j_password = cryptor.encrypt(request.POST.get('j_password')) j_root = request.POST.get('j_root') j_passwd = cryptor.encrypt(request.POST.get('j_passwd')) - a = Asset(ip=j_ip, - port=j_port, - login_type=j_type, - idc=j_idc, + a = Asset(ip=j_ip, port=j_port, + login_type=j_type, idc=j_idc, is_active=int(j_active), comment=j_comment, username_common=j_user, @@ -57,21 +53,21 @@ def jadd_host(request): username_super=j_root, password_super=j_passwd,) else: - a = Asset(ip=j_ip, - port=j_port, - login_type=j_type, - idc=j_idc, + a = Asset(ip=j_ip, port=j_port, + login_type=j_type, idc=j_idc, is_active=int(j_active), comment=j_comment) a.save() + print 'ok' a.bis_group = groups a.save() - - return render_to_response('jasset/jadd.html', locals(), context_instance=RequestContext(request)) + smg = u'主机 %s 添加成功' %j_ip + return render_to_response('jasset/host_add.html', locals(), context_instance=RequestContext(request)) def jlist_host(request): - header_title, path1, path2 = '查看主机 | List Host', '资产管理', '查看主机' + header_title, path1, path2 = u'查看主机 | List Host', u'资产管理', u'查看主机' + login_types = {'L': 'LDAP', 'S': 'SSH_KEY', 'P': 'PASSWORD', 'M': 'MAP'} posts = contact_list = Asset.objects.all().order_by('ip') print posts p = paginator = Paginator(contact_list, 5) @@ -85,16 +81,77 @@ def jlist_host(request): except (EmptyPage, InvalidPage): contacts = paginator.page(paginator.num_pages) - return render_to_response('jasset/jlist.html', locals(), context_instance=RequestContext(request)) + return render_to_response('jasset/host_list.html', locals(), context_instance=RequestContext(request)) + +def host_del(request, offset): + Asset.objects.filter(ip=str(offset)).delete() + return HttpResponseRedirect('/jasset/host_list/') + +def host_edit(request, offset): + actives = {1: u'激活', 0: u'禁用'} + login_types = {'L': 'LDAP', 'S': 'SSH_KEY', 'P': 'PASSWORD', 'M': 'MAP'} + header_title, path1, path2 = u'修改主机 | Edit Host', u'资产管理', u'修改主机' + groups, e_group = [], [] + eidc = IDC.objects.all() + egroup = BisGroup.objects.all() + for g in Asset.objects.get(ip=offset).bis_group.all(): + e_group.append(g) + post = Asset.objects.get(ip = str(offset)) + if request.method == 'POST': + j_ip = request.POST.get('j_ip') + j_idc = request.POST.get('j_idc') + j_port = request.POST.get('j_port') + j_type = request.POST.get('j_type') + j_group = request.POST.getlist('j_group') + j_active = request.POST.get('j_active') + j_comment = request.POST.get('j_comment') + j_idc = IDC.objects.get(name=j_idc) + for group in j_group: + c = BisGroup.objects.get(name=group) + groups.append(c) + + a = Asset.objects.get(ip=str(offset)) + + if j_type == 'M': + j_user = request.POST.get('j_user') + j_password = cryptor.encrypt(request.POST.get('j_password')) + j_root = request.POST.get('j_root') + j_passwd = cryptor.encrypt(request.POST.get('j_passwd')) + a.ip = j_ip + a.port = j_port + a.login_type = j_type + a.idc = j_idc + a.is_active = j_active + a.comment = j_comment + a.username_common = j_user + a.password_common = j_password + a.username_super = j_root + a.password_super = j_passwd + else: + a.ip = j_ip + a.port = j_port + a.idc = j_idc + a.login_type = j_type + a.is_active = j_active + a.comment = j_comment + + a.save() + a.bis_group = groups + a.save() + smg = u'主机 %s 修改成功' %j_ip + return HttpResponseRedirect('/jasset/host_list') + + return render_to_response('jasset/host_edit.html', locals(), context_instance=RequestContext(request)) + def jlist_ip(request, offset): - header_title, path1, path2 = '主机详细信息 | Host Detail.', '资产管理', '主机详情' + header_title, path1, path2 = u'主机详细信息 | Host Detail.', u'资产管理', u'主机详情' print offset post = contact_list = Asset.objects.get(ip = str(offset)) return render_to_response('jasset/jlist_ip.html', locals(), context_instance=RequestContext(request)) def jadd_idc(request): - header_title, path1, path2 = '添加IDC | Add IDC', '资产管理', '添加IDC' + header_title, path1, path2 = u'添加IDC | Add IDC', u'资产管理', u'添加IDC' if request.method == 'POST': j_idc = request.POST.get('j_idc') j_comment = request.POST.get('j_comment') @@ -102,37 +159,47 @@ def jadd_idc(request): if IDC.objects.filter(name=j_idc): emg = u'该IDC已存在!' - return render_to_response('jasset/jadd_idc.html', - {'emg': emg, 'j_idc': j_idc, 'j_comment': j_comment,}, - context_instance=RequestContext(request)) + return render_to_response('jasset/idc_add.html', locals(), context_instance=RequestContext(request)) else: + smg = u'IDC:%s添加成功' %j_idc IDC.objects.create(name=j_idc, comment=j_comment) - return render_to_response('jasset/jadd_idc.html', locals(), context_instance=RequestContext(request)) + return render_to_response('jasset/idc_add.html', locals(), context_instance=RequestContext(request)) def jlist_idc(request): - header_title, path1, path2 = '查看IDC | List Host', '资产管理', '查看IDC' + header_title, path1, path2 = u'查看IDC | List Host', u'资产管理', u'查看IDC' posts = IDC.objects.all().order_by('id') - return render_to_response('jasset/jlist_idc.html', locals(), context_instance=RequestContext(request)) + return render_to_response('jasset/idc_list.html', locals(), context_instance=RequestContext(request)) +def idc_del(request, offset): + IDC.objects.filter(id=offset).delete() + return HttpResponseRedirect('/jasset/idc_list/') def jadd_group(request): - header_title, path1, path2 = '添加业务组 | Add Group', '资产管理', '添加业务组' + header_title, path1, path2 = u'添加业务组 | Add Group', u'资产管理', u'添加业务组' if request.method == 'POST': j_group = request.POST.get('j_group') j_comment = request.POST.get('j_comment') if BisGroup.objects.filter(name=j_group): emg = u'该业务组已存在!' - return render_to_response('jasset/jadd_group.html', locals(), context_instance=RequestContext(request)) + return render_to_response('jasset/group_add.html', locals(), context_instance=RequestContext(request)) else: + smg = u'业务组%s添加成功' %j_group BisGroup.objects.create(name=j_group, comment=j_comment) - return render_to_response('jasset/jadd_group.html', locals(), context_instance=RequestContext(request)) + return render_to_response('jasset/group_add.html', locals(), context_instance=RequestContext(request)) def jlist_group(request): - header_title, path1, path2 = '添加业务组 | Add Group', '资产管理', '查看业务组' + header_title, path1, path2 = u'查看业务组 | Add Group', u'资产管理', u'查看业务组' posts = BisGroup.objects.all().order_by('id') - return render_to_response('jasset/jlist_group.html', locals(), context_instance=RequestContext(request)) + return render_to_response('jasset/group_list.html', locals(), context_instance=RequestContext(request)) + +def group_del(request, offset): + BisGroup.objects.filter(id=offset).delete() + return HttpResponseRedirect('/jasset/group_list/') + +def test(request): + return render_to_response('jasset/test.html', locals()) \ No newline at end of file diff --git a/jumpserver/templatetags/mytags.py b/jumpserver/templatetags/mytags.py index 3ef015a5c..19224af43 100644 --- a/jumpserver/templatetags/mytags.py +++ b/jumpserver/templatetags/mytags.py @@ -15,3 +15,7 @@ def stamp2str(value): @register.filter(name='int2str') def int2str(value): return str(value) + +@register.filter(name='get_item') +def get_item(dictionary, key): + return dictionary.get(key) diff --git a/juser/views.py b/juser/views.py index 09e262b2c..8387e5914 100644 --- a/juser/views.py +++ b/juser/views.py @@ -158,7 +158,6 @@ def user_list(request): def db_add_user(**kwargs): groups_post = kwargs.pop('groups') user = User(**kwargs) - group_select = [] for group_id in groups_post: group = UserGroup.objects.filter(id=group_id) group_select.extend(group) diff --git a/templates/jasset/jadd_group.html b/templates/jasset/group_add.html similarity index 60% rename from templates/jasset/jadd_group.html rename to templates/jasset/group_add.html index 179794ebb..f610d740f 100644 --- a/templates/jasset/jadd_group.html +++ b/templates/jasset/group_add.html @@ -30,14 +30,17 @@ {% if emg %}
    {{ emg }}
    {% endif %} -
    + {% if smg %} +
    {{ smg }}
    + {% endif %} +
    -
    +
    -
    +
    @@ -54,52 +57,23 @@
  • - - - - - - - - - - - diff --git a/templates/jasset/jlist_idc.html b/templates/jasset/group_list.html similarity index 62% rename from templates/jasset/jlist_idc.html rename to templates/jasset/group_list.html index 182dd2b23..8f707d213 100644 --- a/templates/jasset/jlist_idc.html +++ b/templates/jasset/group_list.html @@ -29,23 +29,29 @@
    - - - + + + + {% for post in posts %} - - - + + + + {% endfor %} diff --git a/templates/jasset/jadd.html b/templates/jasset/host_add.html similarity index 70% rename from templates/jasset/jadd.html rename to templates/jasset/host_add.html index 1ba125809..24ee3a98e 100644 --- a/templates/jasset/jadd.html +++ b/templates/jasset/host_add.html @@ -32,53 +32,55 @@ -
    +
    {% if emg %}
    {{ emg }}
    {% endif %} - + {% if smg %} +
    {{ smg }}
    + {% endif %} +
    -
    +
    -
    +
    -
    -
    -
    -
    +
    +
    +
    +
    -
    @@ -111,13 +113,13 @@
    -
    +
    - +
    @@ -129,79 +131,71 @@
    + +{% endblock %} \ No newline at end of file diff --git a/templates/jasset/jlist.html b/templates/jasset/host_list.html similarity index 60% rename from templates/jasset/jlist.html rename to templates/jasset/host_list.html index 7798b3a2a..eae48d9e4 100644 --- a/templates/jasset/jlist.html +++ b/templates/jasset/host_list.html @@ -1,10 +1,11 @@ {% extends 'base.html' %} +{% load mytags %} {% block content %} {% include 'nav_cat_bar.html' %}
    -
    +
    主机详细信息列表
    @@ -29,35 +30,43 @@
    ID 机房名 备注 ID 机房名 备注 操作
    {{ post.id }} {{ post.name }} {{ post.comment }} {{ post.id }} {{ post.name }} {{ post.comment }} + 详情 + 编辑 + 删除 +
    - - - - - - - + + + + + + + + + {% for post in contacts.object_list %} - - - - - + + + + + - - + + + {% endfor %} diff --git a/templates/jasset/jadd_idc.html b/templates/jasset/idc_add.html similarity index 64% rename from templates/jasset/jadd_idc.html rename to templates/jasset/idc_add.html index 5a2b66f72..32ba1e8b8 100644 --- a/templates/jasset/jadd_idc.html +++ b/templates/jasset/idc_add.html @@ -30,7 +30,10 @@ {% if emg %}
    {{ emg }}
    {% endif %} - + {% if smg %} +
    {{ smg }}
    + {% endif %} +
    @@ -44,7 +47,7 @@
    - +
    @@ -54,53 +57,23 @@ - - - - - - - - - - - {% endblock %} \ No newline at end of file diff --git a/templates/jasset/jlist_group.html b/templates/jasset/idc_list.html similarity index 62% rename from templates/jasset/jlist_group.html rename to templates/jasset/idc_list.html index 182dd2b23..05087e030 100644 --- a/templates/jasset/jlist_group.html +++ b/templates/jasset/idc_list.html @@ -29,23 +29,29 @@
    IP地址 端口号 登录方式 所属IDC 所属业务组 添加时间 备注 IP地址 端口号 登录方式 所属IDC 所属业务组 添加时间 备注 操作
    {{ post.ip }} {{ post.port }} {{ post.get_login_type}} {{ post.idc.name }} + {{ post.ip }} {{ post.port }} {{ login_types|get_item:post.login_type }} {{ post.idc.name }} {% for group in post.bis_group.all %} {{ group }} {% endfor %} {{ post.date_added }} {{ post.comment }} {{ post.date_added }} {{ post.comment }} + 详情 + 编辑 + 删除 +
    - - - + + + + {% for post in posts %} - - - + + + + {% endfor %} diff --git a/templates/jasset/test.html b/templates/jasset/test.html new file mode 100644 index 000000000..6ece5b502 --- /dev/null +++ b/templates/jasset/test.html @@ -0,0 +1,30 @@ + + +
    +
    +
    全名
    +
    + +
    +
    +
    +
    电子邮件地址
    +
    + +
    +
    +
    +
    创建密码
    +
    + +
    +
    +
    +
    选择你的用户名
    +
    + +
    +
    +
    + + \ No newline at end of file From 9b194946c331f26f053cd995d5d108c413340e96 Mon Sep 17 00:00:00 2001 From: halcyon <864072399@qq.com> Date: Wed, 21 Jan 2015 18:54:31 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=BB=84=E4=B8=8D=E9=80=89=E6=B2=A1=E6=9C=89=E6=8F=90=E7=A4=BA?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/jasset/host_add.html | 4 ++-- templates/jasset/host_edit.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/jasset/host_add.html b/templates/jasset/host_add.html index 24ee3a98e..dc862a315 100644 --- a/templates/jasset/host_add.html +++ b/templates/jasset/host_add.html @@ -164,10 +164,10 @@ $('#assetForm').validator({ msg: {required: "必须填写!"} }, "j_group": { - rule: "required", + rule: "checked", tip: "选择业务组", ok: "", - msg: {required: "至少选择一个组"} + msg: {checked: "至少选择一个组"} }, "j_user": { rule: "required(type_m)", diff --git a/templates/jasset/host_edit.html b/templates/jasset/host_edit.html index 0d70ccd77..d3a3f2f00 100644 --- a/templates/jasset/host_edit.html +++ b/templates/jasset/host_edit.html @@ -175,10 +175,10 @@ $('#assetForm').validator({ msg: {required: "必须填写!"} }, "j_group": { - rule: "required", + rule: "checked", tip: "选择业务组", ok: "", - msg: {required: "至少选择一个组"} + msg: {checked: "至少选择一个组"} }, "j_user": { rule: "required(type_m)",
    ID 机房名 备注 ID 机房名 备注 操作
    {{ post.id }} {{ post.name }} {{ post.comment }} {{ post.id }} {{ post.name }} {{ post.comment }} + 详情 + 编辑 + 删除 +