Skip to content

Commit

Permalink
0.1.0.1 配置文件修改,说明文件更新
Browse files Browse the repository at this point in the history
0.1.0.1  配置文件修改,说明文件更新
  • Loading branch information
hequan2017 committed Mar 16, 2018
1 parent 7afd79f commit 13b5963
Show file tree
Hide file tree
Showing 31 changed files with 136 additions and 155 deletions.
50 changes: 42 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,41 @@
## Chain

一个基于django2.0版本,最简单的阿里云主机增删改查项目。 适合刚入门的人参考。
一个基于django2.0版本,极简主义的云主机CMDB增删改查项目!

前端模板为 INSPINIA 2.7.1 版本
非常适合django刚入门的人拿来参考!

### 安装
---
### DEMO

```bash
http://47.94.252.25:8001

账号 admin
密码 1qaz.2wsx
```
pip3 install -r requirements.txt


### 环境

前端:INSPINIA 2.7.1 版本

后端:
* django==2.0.3
* django-bootstrap3
* Python3.6.4


### 部署




```bash
git clone https://github.com/hequan2017/chain.git

cd chain

pip3 install -r requirements.txt
python3 manage.py makemigrations
python3 manage.py migrate

Expand All @@ -18,15 +45,22 @@ python3 manage.py runserver 0.0.0.0:80
```


```bash
如果遇到报错 ImportError: No module named '_sqlite3' ,可以执行下面的操作。

yum -y install sqlite-devel

安装python3.6.4 或者重新编译
```


### 截图
![DEMO](static/demo/1.png)
![DEMO](static/demo/2.png)
![DEMO](static/demo/3.png)
![DEMO](static/demo/4.png)


### 贡献者
---
### 作者

#### 1.0
#### 0.1
- 何全
Binary file modified asset/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified asset/__pycache__/admin.cpython-36.pyc
Binary file not shown.
Binary file modified asset/__pycache__/form.cpython-36.pyc
Binary file not shown.
Binary file modified asset/__pycache__/models.cpython-36.pyc
Binary file not shown.
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.
1 change: 1 addition & 0 deletions asset/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
from .models import asset



admin.site.register(asset)
5 changes: 4 additions & 1 deletion asset/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ class Meta:

}
help_texts = {
'network_ip': '必填项目',
'network_ip': '* 必填项目,唯一值',
'manager': '* 必填项目',
"ctime":'* 必填项目',
"utime":'* 必填项目'
}
error_messages = {
'model':{
Expand Down
Binary file modified asset/migrations/__pycache__/0001_initial.cpython-36.pyc
Binary file not shown.
Binary file modified asset/migrations/__pycache__/0002_asset_manager.cpython-36.pyc
Binary file not shown.
Binary file modified asset/migrations/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
2 changes: 0 additions & 2 deletions asset/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
urlpatterns = [
path('asset.html',views.AssetListAll.as_view(),name='asset_list'),
path('asset-add.html',views.AssetAdd.as_view(),name='asset_add'),
path('asset-del.html',views.AssetDel.as_view(),name='asset_del'),
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'),
]


app_name="asset"
73 changes: 18 additions & 55 deletions asset/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@


class AssetListAll(LoginRequiredMixin,ListView):
'''
列表
'''
template_name = 'asset/asset.html'
paginate_by = settings.DISPLAY_PER_PAGE
model = asset
Expand All @@ -31,39 +34,10 @@ def get_context_data(self, **kwargs):
return super(AssetListAll, self).get_context_data(**kwargs)




# def post(self, request):
# query = request.POST.get("name")
#
# user = User.objects.get(username=request.user)
# if user.is_superuser == 1:
# ret = asset.objects.filter(Q(network_ip=query) | Q(manage_ip=query) | Q(hostname=query) | Q(
# inner_ip=query) | Q(model=query) | Q(
# eth0=query) | Q(eth1=query) | Q(eth2=query) | Q(eth3=query) |
# Q(system=query) | Q(system_user__username=query) | Q(
# data_center__data_center_list=query) | Q(
# cabinet=query) |
# Q(position=query) | Q(sn=query)
# | Q(uplink_port=query) | Q(product_line__name=query)
# )
# else:
# product1 = Group.objects.get(user=user)
#
# ret = asset.objects.filter(Q(product_line__name=product1) & Q(network_ip=query) | Q(manage_ip=query) | Q(hostname=query) | Q( inner_ip=query) | Q(model=query) | Q(eth0=query) | Q(eth1=query) | Q(eth2=query) | Q(eth3=query) |
# Q(system=query) | Q(system_user__username=query)
# | Q(data_center__data_center_list=query) | Q(cabinet=query) | Q(position=query) | Q(sn=query)| Q(uplink_port=query))
#
# return render(request, 'asset/asset.html',
# {"Webssh": getattr(settings, 'Webssh_ip'),
# "Webssh_port": getattr(settings, 'Webssh_port'),
# "asset_active": "active",
# "asset_list_active": "active", "asset_list": ret})




class AssetAdd(LoginRequiredMixin,CreateView):
"""
增加
"""
model = asset
form_class = AssetForm
template_name = 'asset/asset-add-update.html'
Expand All @@ -82,6 +56,9 @@ def get_context_data(self, **kwargs):


class AssetUpdate(LoginRequiredMixin,UpdateView):
'''
更新
'''
model = asset
form_class = AssetForm
template_name = 'asset/asset-add-update.html'
Expand All @@ -104,6 +81,9 @@ def form_invalid(self, form):


class AssetDetail(LoginRequiredMixin,DetailView):
'''
详细
'''
model = asset
template_name = 'asset/asset-detail.html'

Expand All @@ -122,37 +102,20 @@ def get_context_data(self, **kwargs):



class AssetDel(LoginRequiredMixin,View):
model = asset


def post(self, request):
ret = {'status': True, 'error': None, }
try:
id = request.POST.get('nid', None)
asset.objects.get(id=id).delete()
except Exception as e:
ret = {
"static": False,
"error": '删除请求错误,没有权限{}'.format(e)
}
finally:
return HttpResponse(json.dumps(ret))




class AssetAllDel(LoginRequiredMixin,View):
"""
删除
"""
model = asset


def post(self, request):
ret = {'status': True, 'error': None, }
try:
ids = request.POST.getlist('id', None)

ids = request.POST.getlist('id', None) or request.POST.get('nid', None)
print(ids)
idstring = ','.join(ids)
asset.objects.extra(where=['id IN (' + idstring + ')']).delete()

except Exception as e:
ret['status'] = False
ret['error'] = '删除请求错误,没有权限{}'.format(e)
Expand Down
Binary file modified chain/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified chain/__pycache__/settings.cpython-36.pyc
Binary file not shown.
Binary file modified chain/__pycache__/urls.cpython-36.pyc
Binary file not shown.
Binary file modified chain/__pycache__/wsgi.cpython-36.pyc
Binary file not shown.
1 change: 0 additions & 1 deletion chain/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@

AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend', # default
'guardian.backends.ObjectPermissionBackend',
)

ANONYMOUS_USER_ID = -1
Expand Down
Binary file modified index/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified index/__pycache__/form.cpython-36.pyc
Binary file not shown.
Binary file modified index/__pycache__/views.cpython-36.pyc
Binary file not shown.
3 changes: 2 additions & 1 deletion index/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def login_view(request):
if request.method == "POST":
u = request.POST.get("username")
p = request.POST.get("password")
user = authenticate(username=u, password=p)
user = authenticate(request,username=u, password=p)
print(123)
if user is not None:
if user.is_active:
login(request, user)
Expand Down
Binary file added static/demo/1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/demo/2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed static/demo/2.png
Binary file not shown.
Binary file added static/demo/3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed static/demo/3.png
Binary file not shown.
Binary file removed static/demo/4.png
Binary file not shown.
25 changes: 3 additions & 22 deletions templates/asset/asset-detail.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{% extends "base.html" %}
{% block title %}资产详情{% endblock %}
{% block header-css %}
{% load bootstrap3 %}

{% load bootstrap3 %}
{% endblock %}


Expand Down Expand Up @@ -114,8 +115,6 @@ <h2>资产详情</h2>
</tr>




<tr>
<td width="20%">CPU:</td>
<td><b>{{ assets.cpu }}</b></td>
Expand Down Expand Up @@ -195,7 +194,7 @@ <h2>资产详情</h2>
closeOnConfirm: false
}, function () {
$.ajax({
url: "/asset/asset-del.html",
url: "/asset/asset-all-del.html",
type: 'POST',
data: {'nid': {{ nid }}},
success: function (data) {
Expand All @@ -216,24 +215,6 @@ <h2>资产详情</h2>
});


$('.asset_hardware_update').click(function () {

alert('关闭alert, 等待完成, 自动刷新页面');
$.ajax({
url: "/asset/asset-hardware-update.html",
type: 'POST',
data: {'nid': {{ nid }}},
success: function (data) {
var obj = JSON.parse(data);
if (obj.status) {
location.reload()
} else {
$('#error2').text(obj.error);
}
}
})
});

});


Expand Down
Loading

0 comments on commit 13b5963

Please sign in to comment.