Skip to content

Commit

Permalink
0.1.0.4 增加 导出全部功能。
Browse files Browse the repository at this point in the history
  • Loading branch information
hequan2017 committed Mar 17, 2018
1 parent 6cc0a8c commit 63cefb4
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 9 deletions.
Binary file modified asset/__pycache__/urls.cpython-36.pyc
Binary file not shown.
Binary file modified asset/__pycache__/views.cpython-36.pyc
Binary file not shown.
42 changes: 42 additions & 0 deletions asset/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Generated by Django 2.0 on 2018-03-17 16:26

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='asset',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('hostname', models.CharField(max_length=64, unique=True, verbose_name='主机名')),
('network_ip', models.GenericIPAddressField(blank=True, null=True, verbose_name='外网IP')),
('inner_ip', models.GenericIPAddressField(blank=True, null=True, verbose_name='内网IP')),
('is_active', models.BooleanField(default=True, verbose_name='是否运行')),
('system', models.CharField(blank=True, max_length=128, null=True, verbose_name='系统版本')),
('cpu', models.CharField(blank=True, max_length=64, null=True, verbose_name='CPU')),
('memory', models.CharField(blank=True, max_length=64, null=True, verbose_name='内存')),
('disk', models.CharField(blank=True, max_length=256, null=True, verbose_name='硬盘')),
('bandwidth', models.IntegerField(blank=True, default='1', null=True, verbose_name='带宽')),
('platform', models.CharField(choices=[('阿里云', '阿里云'), ('AWS', 'AWS'), ('其他', '其他')], max_length=128, verbose_name='平台')),
('Instance_id', models.CharField(blank=True, max_length=64, null=True, verbose_name='实例ID')),
('region', models.CharField(blank=True, max_length=256, null=True, verbose_name='地区')),
('manager', models.CharField(choices=[('何全', '何全'), ('其他', '其他')], max_length=128, verbose_name='负责人')),
('ctime', models.DateTimeField(verbose_name='购买时间')),
('utime', models.DateTimeField(verbose_name='到期时间')),
('ps', models.CharField(blank=True, max_length=1024, null=True, verbose_name='备注')),
],
options={
'verbose_name': '资产管理',
'verbose_name_plural': '资产管理',
'db_table': 'asset',
'permissions': {('read_asset', '只读资产管理')},
},
),
]
Binary file not shown.
2 changes: 2 additions & 0 deletions asset/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
path('asset-all-del.html',views.AssetAllDel.as_view(),name='asset_all_del'),
path('asset-detail-<int:pk>.html',views.AssetDetail.as_view(),name='asset_detail'),
path('asset-update-<int:pk>.html', views.AssetUpdate.as_view(), name='asset_update'),

path('asset-export.html',views.AssetExport.as_view(),name='asset_export'),
]

app_name="asset"
13 changes: 10 additions & 3 deletions asset/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
from django.conf import settings
from django.db.models import Q
import json



from djqscsv import render_to_csv_response

class AssetListAll(LoginRequiredMixin,ListView):
'''
Expand Down Expand Up @@ -129,3 +127,12 @@ def post(self, request):
return HttpResponse(json.dumps(ret))



class AssetExport(View):
"""
导出
"""
def get(self, *args, **kwargs):
filename = '资产信息'
qs = asset.objects.all()
return render_to_csv_response(qs,filename=filename,)
Binary file modified chain/__pycache__/settings.cpython-36.pyc
Binary file not shown.
1 change: 1 addition & 0 deletions chain/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
'django.contrib.staticfiles',
'bootstrap3',
'asset',

]

MIDDLEWARE = [
Expand Down
Binary file added db.sqlite3
Binary file not shown.
Binary file modified index/__pycache__/views.cpython-36.pyc
Binary file not shown.
3 changes: 1 addition & 2 deletions index/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
from django.contrib.auth.models import User



@login_required(login_url="/login.html")
def index(request):
"""
首页
:param request:
:return:
"""

return render(request, 'index/index.html', )


Expand All @@ -33,7 +33,6 @@ def login_view(request):
u = request.POST.get("username")
p = request.POST.get("password")
user = authenticate(request,username=u, password=p)
print(123)
if user is not None:
if user.is_active:
login(request, user)
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
django==2.0.3
django-bootstrap3
django-bootstrap3
django-queryset-csv
36 changes: 33 additions & 3 deletions templates/asset/asset.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ <h5>资产信息</h5>

<a href="{% url 'asset:asset_add' %}" class="btn btn-sm btn-primary ">
添加</a>

<a href="{% url 'asset:asset_export' %}" class="btn btn-sm btn-primary " id="export" >
导出全部</a>

<a class="btn btn-sm btn-danger asset_all_del"
>批量删除
Expand All @@ -80,7 +81,7 @@ <h5>资产信息</h5>
<th width="20"><input type="checkbox" id="CheckedAll"></th>
<th>主机名</th>
<th>外网IP</th>
<th>管理IP</th>
<th>内网IP</th>
<th>平台</th>
<th>系统版本</th>
<th>负责人</th>
Expand All @@ -99,7 +100,7 @@ <h5>资产信息</h5>
href="{% url "asset:asset_detail" pk=row.id %}">{{ row.hostname }}</a>
</td>
<td class="center">{{ row.network_ip }}</td>
<td class="center">{{ row.manage_ip }}</td>
<td class="center">{{ row.inner_ip }}</td>
<td class="center">{{ row.platform }}</td>
<td class="center">{{ row.system }}</td>
<td class="center">{{ row.manager }}</td>
Expand Down Expand Up @@ -198,8 +199,37 @@ <h5>资产信息</h5>


<script>





$(function () {








$(document).ready(function(){

$("#export").click(function(){
$.ajax({
url: "/asset/asset-export.html",
type: 'POST',
data: $('#del_form_asset_all').serialize(),
success: function (data) {
{# window.location= "/asset/asset-export.html"#}
}
});
});
});




$(document).on('click', '.asset_del_1', function () {
var id = $(this).parent().parent().attr('id');
swal({
Expand Down

0 comments on commit 63cefb4

Please sign in to comment.