Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
3d4f79ca
Commit
3d4f79ca
authored
Oct 28, 2016
by
江世峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
asset:add assets_bulk_update
parent
f88c1490
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
120 additions
and
59 deletions
+120
-59
api.py
apps/assets/api.py
+7
-11
forms.py
apps/assets/forms.py
+1
-1
serializers.py
apps/assets/serializers.py
+1
-1
asset_list.html
apps/assets/templates/assets/asset_list.html
+1
-1
asset_modal_update.html
apps/assets/templates/assets/asset_modal_update.html
+39
-4
utils.py
apps/assets/utils.py
+2
-2
views.py
apps/assets/views.py
+69
-39
No files found.
apps/assets/api.py
View file @
3d4f79ca
...
@@ -29,29 +29,26 @@ class IDCSerializer(serializers.ModelSerializer):
...
@@ -29,29 +29,26 @@ class IDCSerializer(serializers.ModelSerializer):
class
AssetGroupViewSet
(
viewsets
.
ModelViewSet
):
class
AssetGroupViewSet
(
viewsets
.
ModelViewSet
):
""" API endpoint that allows AssetGroup to be viewed or edited.
""" API endpoint that allows AssetGroup to be viewed or edited.
some other comment
some other comment
"""
"""
queryset
=
AssetGroup
.
objects
.
all
()
queryset
=
AssetGroup
.
objects
.
all
()
serializer_class
=
AssetGroupSerializer
serializer_class
=
AssetGroupSerializer
class
AssetViewSet
(
viewsets
.
ModelViewSet
):
class
AssetViewSet
(
viewsets
.
ModelViewSet
):
"""
"""API endpoint that allows Asset to be viewed or edited."""
API endpoint that allows Asset to be viewed or edited.
"""
queryset
=
Asset
.
objects
.
all
()
queryset
=
Asset
.
objects
.
all
()
serializer_class
=
AssetSerializer
serializer_class
=
AssetSerializer
class
IDCViewSet
(
viewsets
.
ReadOnlyModelViewSet
):
class
IDCViewSet
(
viewsets
.
ReadOnlyModelViewSet
):
"""
"""API endpoint that allows IDC to be viewed or edited."""
API endpoint that allows IDC to be viewed or edited.
"""
queryset
=
IDC
.
objects
.
all
()
queryset
=
IDC
.
objects
.
all
()
serializer_class
=
IDCSerializer
serializer_class
=
IDCSerializer
class
AssetListUpdateApi
(
BulkDeleteApiMixin
,
ListBulkCreateUpdateDestroyAPIView
):
class
AssetListUpdateApi
(
BulkDeleteApiMixin
,
ListBulkCreateUpdateDestroyAPIView
):
queryset
=
Asset
.
objects
.
all
()
queryset
=
Asset
.
objects
.
all
()
serializer_class
=
AssetBulkUpdateSerializer
serializer_class
=
AssetBulkUpdateSerializer
\ No newline at end of file
apps/assets/forms.py
View file @
3d4f79ca
...
@@ -45,7 +45,7 @@ class AssetCreateForm(forms.ModelForm):
...
@@ -45,7 +45,7 @@ class AssetCreateForm(forms.ModelForm):
fields
=
[
fields
=
[
'hostname'
,
'ip'
,
'port'
,
'type'
,
'comment'
,
'admin_user'
,
'system_users'
,
'idc'
,
'groups'
,
'hostname'
,
'ip'
,
'port'
,
'type'
,
'comment'
,
'admin_user'
,
'system_users'
,
'idc'
,
'groups'
,
'other_ip'
,
'remote_card_ip'
,
'mac_address'
,
'brand'
,
'cpu'
,
'memory'
,
'disk'
,
'os'
,
'cabinet_no'
,
'other_ip'
,
'remote_card_ip'
,
'mac_address'
,
'brand'
,
'cpu'
,
'memory'
,
'disk'
,
'os'
,
'cabinet_no'
,
'cabinet_pos'
,
'number'
,
'status'
,
'env'
,
'sn'
,
'tags'
,
'cabinet_pos'
,
'number'
,
'status'
,
'env'
,
'sn'
,
'tags'
,
]
]
tags
=
forms
.
ModelMultipleChoiceField
(
queryset
=
Tag
.
objects
.
all
())
tags
=
forms
.
ModelMultipleChoiceField
(
queryset
=
Tag
.
objects
.
all
())
widgets
=
{
widgets
=
{
...
...
apps/assets/serializers.py
View file @
3d4f79ca
...
@@ -13,7 +13,7 @@ class AssetBulkUpdateSerializer(BulkSerializerMixin, serializers.ModelSerializer
...
@@ -13,7 +13,7 @@ class AssetBulkUpdateSerializer(BulkSerializerMixin, serializers.ModelSerializer
class
Meta
(
object
):
class
Meta
(
object
):
model
=
Asset
model
=
Asset
list_serializer_class
=
BulkListSerializer
list_serializer_class
=
BulkListSerializer
fields
=
[
'id'
,
'
is_active'
,
'hostname
'
]
fields
=
[
'id'
,
'
port'
,
'idc
'
]
# def get_group_display(self, obj):
# def get_group_display(self, obj):
# return " ".join([group.name for group in obj.groups.all()])
# return " ".join([group.name for group in obj.groups.all()])
...
...
apps/assets/templates/assets/asset_list.html
View file @
3d4f79ca
...
@@ -136,7 +136,7 @@ div.dataTables_wrapper div.dataTables_filter,
...
@@ -136,7 +136,7 @@ div.dataTables_wrapper div.dataTables_filter,
show
:
false
,
show
:
false
,
backdrop
:
'static'
,
backdrop
:
'static'
,
keyboard
:
'false'
,
keyboard
:
'false'
,
remote
:
"{% url 'assets:asset-modal-update' %}"
,
//
remote:"{% url 'assets:asset-modal-update' %}",
});
});
$
(
'#asset_bulk_update_modal'
).
on
(
'shown.bs.modal'
,
function
(){
$
(
'#asset_bulk_update_modal'
).
on
(
'shown.bs.modal'
,
function
(){
...
...
apps/assets/templates/assets/asset_modal_update.html
View file @
3d4f79ca
...
@@ -30,6 +30,9 @@
...
@@ -30,6 +30,9 @@
<label
class=
"control-label col-sm-2 col-lg-2 "
id=
"asset_on_count"
>
已选主机({{ assets_count }})
</label>
<label
class=
"control-label col-sm-2 col-lg-2 "
id=
"asset_on_count"
>
已选主机({{ assets_count }})
</label>
<div
class=
"col-sm-9"
id=
"asset_sed"
>
<div
class=
"col-sm-9"
id=
"asset_sed"
>
<div
class=
"form-asset-on"
id=
"add_asset"
>
<div
class=
"form-asset-on"
id=
"add_asset"
>
{% for asset in assets_on_list %}
<input
type=
'hidden'
name=
'assets'
value=
'{{ asset.id }}'
>
{% endfor %}
<p
id=
"asset_on_p"
>
<p
id=
"asset_on_p"
>
{% for asset in assets_on_list %}
{% for asset in assets_on_list %}
<button
name=
'asset_hostname'
title=
'{{ asset.ip }}'
type=
'button'
class=
'btn btn-default btn-xs'
>
{{ asset.hostname }}
</button>
<button
name=
'asset_hostname'
title=
'{{ asset.ip }}'
type=
'button'
class=
'btn btn-default btn-xs'
>
{{ asset.hostname }}
</button>
...
@@ -42,7 +45,7 @@
...
@@ -42,7 +45,7 @@
<div
class=
"hr-line-dashed"
></div>
<div
class=
"hr-line-dashed"
></div>
<div
class=
"ydxbd"
id=
"formlists"
style=
"display: block;"
>
<div
class=
"ydxbd"
id=
"formlists"
style=
"display: block;"
>
<p
id=
"tags_p"
class=
"mgl-5 c02"
>
选择属性
</p>
<p
id=
"tags_p"
class=
"mgl-5 c02"
>
选择
需要修改
属性
</p>
<div
class=
"tagBtnList"
>
<div
class=
"tagBtnList"
>
<a
onclick=
"AddAllForm(this)"
class=
"tagBtn2 label label-primary"
id=
"changeall"
>
全选
</a>
<a
onclick=
"AddAllForm(this)"
class=
"tagBtn2 label label-primary"
id=
"changeall"
>
全选
</a>
<a
onclick=
"AddForm(this,'id_port')"
class=
"tagBtn2 label label-default"
name=
"changebtn"
>
端口
</a>
<a
onclick=
"AddForm(this,'id_port')"
class=
"tagBtn2 label label-default"
name=
"changebtn"
>
端口
</a>
...
@@ -65,14 +68,17 @@
...
@@ -65,14 +68,17 @@
</div>
</div>
</div>
</div>
<input
name=
"assets_ids"
type=
"hidden"
value=
"111"
>
<input
name=
"assets_ids"
type=
"hidden"
value=
"112"
>
<div
class=
"hr-line-dashed"
></div>
<div
class=
"hr-line-dashed"
></div>
<form
action=
""
method=
"post"
class=
"form-horizontal"
id=
"add_form"
>
<form
action=
"
/assets/asset/27/update
"
method=
"post"
class=
"form-horizontal"
id=
"add_form"
>
{% csrf_token %}
{% csrf_token %}
<input
name=
"ip"
required=
""
type=
"hidden"
value=
"1.0.0.0"
>
<div
class=
"form-group"
name=
"formbtn"
id=
"formbtn"
>
<div
class=
"form-group"
name=
"formbtn"
id=
"formbtn"
>
<div
class=
"col-sm-4 col-sm-offset-2"
>
<div
class=
"col-sm-4 col-sm-offset-2"
>
<button
class=
"btn btn-white"
type=
"reset"
>
{% trans 'Reset' %}
</button>
<button
class=
"btn btn-white"
type=
"reset"
>
{% trans 'Reset' %}
</button>
<button
id=
"submit_button"
class=
"btn btn-primary"
type=
"
submit
"
>
{% trans 'Submit' %}
</button>
<button
id=
"submit_button"
class=
"btn btn-primary"
type=
"
button"
onclick=
"fsubmit()
"
>
{% trans 'Submit' %}
</button>
</div>
</div>
</div>
</div>
</form>
</form>
...
@@ -173,5 +179,34 @@
...
@@ -173,5 +179,34 @@
SetSelect2
();
SetSelect2
();
};
};
};
};
function
fsubmit
(){
var
assets_id
=
document
.
getElementsByName
(
"assets"
);
var
oForm
=
document
.
getElementById
(
'add_form'
);
var
parentElem
=
document
.
getElementById
(
"add_form"
);
var
aDiv
=
parentElem
.
getElementsByClassName
(
'form-group'
);
if
(
assets_id
.
length
===
0
)
{
swal
({
title
:
"未选择需要修改的主机"
,
text
:
"请点击选择"
});
}
else
if
(
aDiv
.
length
===
1
)
{
swal
({
title
:
"未选需要修改的属性"
,
text
:
"请点击选择"
});
}
else
{
var
m
=
document
.
getElementsByName
(
'assets_ids'
);
alert
(
m
.
length
);
for
(
var
i
=
0
;
i
<
m
.
length
;
i
++
){
alert
(
m
[
0
].
value
);
oForm
.
appendChild
(
m
[
0
]);
};
action
=
"/assets/asset/"
+
assets_id
[
0
].
value
+
"/update"
;
oForm
.
action
=
action
;
oForm
.
submit
();
};
}
</script>
</script>
{% endblock %}
{% endblock %}
apps/assets/utils.py
View file @
3d4f79ca
...
@@ -18,8 +18,8 @@ class CreateAssetTagsMiXin(CreateView):
...
@@ -18,8 +18,8 @@ class CreateAssetTagsMiXin(CreateView):
for
t
in
tags_list
:
for
t
in
tags_list
:
try
:
try
:
oTag
=
Tag
.
objects
.
get
(
pk
=
int
(
t
))
oTag
=
Tag
.
objects
.
get
(
pk
=
int
(
t
))
except
(
Tag
.
DoesNotExist
,
UnicodeEncodeError
):
except
(
Tag
.
DoesNotExist
,
UnicodeEncodeError
):
oTag
=
Tag
(
name
=
t
,
created_by
=
self
.
request
.
user
.
username
or
'Admin'
)
oTag
=
Tag
(
name
=
t
,
created_by
=
self
.
request
.
user
.
username
or
'Admin'
)
oTag
.
save
()
oTag
.
save
()
post_data
.
update
({
'tags'
:
oTag
.
pk
})
post_data
.
update
({
'tags'
:
oTag
.
pk
})
else
:
else
:
...
...
apps/assets/views.py
View file @
3d4f79ca
# coding:utf-8
# coding:utf-8
from
__future__
import
absolute_import
,
unicode_literals
from
__future__
import
absolute_import
,
unicode_literals
from
django.utils.translation
import
ugettext
as
_
from
django.utils.translation
import
ugettext
as
_
from
django.conf
import
settings
from
django.conf
import
settings
from
django.db.models
import
Q
from
django.db.models
import
Q
...
@@ -10,7 +9,6 @@ from django.urls import reverse_lazy
...
@@ -10,7 +9,6 @@ from django.urls import reverse_lazy
from
django.contrib.messages.views
import
SuccessMessageMixin
from
django.contrib.messages.views
import
SuccessMessageMixin
from
django.views.generic.detail
import
DetailView
,
SingleObjectMixin
from
django.views.generic.detail
import
DetailView
,
SingleObjectMixin
from
django.shortcuts
import
get_object_or_404
,
reverse
,
redirect
from
django.shortcuts
import
get_object_or_404
,
reverse
,
redirect
from
common.utils
import
int_seq
from
common.utils
import
int_seq
from
.utils
import
CreateAssetTagsMiXin
,
UpdateAssetTagsMiXin
from
.utils
import
CreateAssetTagsMiXin
,
UpdateAssetTagsMiXin
from
.models
import
Asset
,
AssetGroup
,
IDC
,
AssetExtend
,
AdminUser
,
SystemUser
,
Tag
from
.models
import
Asset
,
AssetGroup
,
IDC
,
AssetExtend
,
AdminUser
,
SystemUser
,
Tag
...
@@ -65,22 +63,22 @@ class AssetCreateView(AdminUserRequiredMixin,CreateAssetTagsMiXin,CreateView):
...
@@ -65,22 +63,22 @@ class AssetCreateView(AdminUserRequiredMixin,CreateAssetTagsMiXin,CreateView):
print
(
form
.
errors
)
print
(
form
.
errors
)
return
super
(
AssetCreateView
,
self
)
.
form_invalid
(
form
)
return
super
(
AssetCreateView
,
self
)
.
form_invalid
(
form
)
def
get_context_data
(
self
,
**
kwargs
):
def
get_context_data
(
self
,
**
kwargs
):
context
=
{
context
=
{
'app'
:
'Assets'
,
'app'
:
'Assets'
,
'action'
:
'Create asset'
,
'action'
:
'Create asset'
,
}
}
kwargs
.
update
(
context
)
kwargs
.
update
(
context
)
return
super
(
AssetCreateView
,
self
)
.
get_context_data
(
**
kwargs
)
return
super
(
AssetCreateView
,
self
)
.
get_context_data
(
**
kwargs
)
class
AssetModalCreateView
(
AdminUserRequiredMixin
,
CreateAssetTagsMiXin
,
ListView
):
class
AssetModalCreateView
(
AdminUserRequiredMixin
,
CreateAssetTagsMiXin
,
ListView
):
model
=
Asset
model
=
Asset
# tag_type = 'asset'
# tag_type = 'asset'
form_class
=
AssetCreateForm
form_class
=
AssetCreateForm
template_name
=
'assets/asset_modal_update.html'
template_name
=
'assets/asset_modal_update.html'
success_url
=
reverse_lazy
(
'assets:asset-list'
)
success_url
=
reverse_lazy
(
'assets:asset-list'
)
def
get_queryset
(
self
):
def
get_queryset
(
self
):
self
.
queryset
=
super
(
AssetModalCreateView
,
self
)
.
get_queryset
()
self
.
queryset
=
super
(
AssetModalCreateView
,
self
)
.
get_queryset
()
self
.
s
=
self
.
request
.
GET
.
get
(
'plain_id_lists'
)
self
.
s
=
self
.
request
.
GET
.
get
(
'plain_id_lists'
)
...
@@ -88,10 +86,10 @@ class AssetModalCreateView(AdminUserRequiredMixin,CreateAssetTagsMiXin,ListView)
...
@@ -88,10 +86,10 @@ class AssetModalCreateView(AdminUserRequiredMixin,CreateAssetTagsMiXin,ListView)
self
.
plain_id_lists
=
[
int
(
x
)
for
x
in
self
.
s
.
split
(
','
)]
self
.
plain_id_lists
=
[
int
(
x
)
for
x
in
self
.
s
.
split
(
','
)]
else
:
else
:
self
.
plain_id_lists
=
[
self
.
s
]
self
.
plain_id_lists
=
[
self
.
s
]
return
self
.
queryset
return
self
.
queryset
def
get_context_data
(
self
,
**
kwargs
):
asset_on_list
=
Asset
.
objects
.
filter
(
id__in
=
self
.
plain_id_lists
)
def
get_context_data
(
self
,
**
kwargs
):
asset_on_list
=
Asset
.
objects
.
filter
(
id__in
=
self
.
plain_id_lists
)
context
=
{
context
=
{
'app'
:
'Assets'
,
'app'
:
'Assets'
,
'action'
:
'Bulk Update asset'
,
'action'
:
'Bulk Update asset'
,
...
@@ -102,11 +100,38 @@ class AssetModalCreateView(AdminUserRequiredMixin,CreateAssetTagsMiXin,ListView)
...
@@ -102,11 +100,38 @@ class AssetModalCreateView(AdminUserRequiredMixin,CreateAssetTagsMiXin,ListView)
kwargs
.
update
(
context
)
kwargs
.
update
(
context
)
return
super
(
AssetModalCreateView
,
self
)
.
get_context_data
(
**
kwargs
)
return
super
(
AssetModalCreateView
,
self
)
.
get_context_data
(
**
kwargs
)
class
AssetUpdateView
(
AdminUserRequiredMixin
,
UpdateAssetTagsMiXin
,
UpdateView
):
class
AssetUpdateView
(
AdminUserRequiredMixin
,
UpdateAssetTagsMiXin
,
UpdateView
):
model
=
Asset
model
=
Asset
form_class
=
AssetCreateForm
form_class
=
AssetCreateForm
template_name
=
'assets/asset_update.html'
template_name
=
'assets/asset_update.html'
success_url
=
reverse_lazy
(
'assets:asset-list'
)
success_url
=
reverse_lazy
(
'assets:asset-list'
)
new_form
=
''
assets_ids
=
''
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
default_keys
=
[
'csrfmiddlewaretoken'
,
'assets_ids'
,
'ip'
,
'number'
,
'hostname'
,
'system_users'
,
'admin_user'
,
]
self
.
assets_ids
=
self
.
request
.
POST
.
getlist
(
'assets_ids'
)
print
self
.
assets_ids
self
.
new_form
=
self
.
request
.
POST
.
copy
()
print
len
(
self
.
new_form
)
print
type
(
self
.
new_form
)
for
i
in
default_keys
:
if
self
.
new_form
.
has_key
(
i
):
self
.
new_form
.
pop
(
i
)
print
self
.
new_form
.
items
()
for
i
in
self
.
new_form
:
print
i
return
super
(
AssetUpdateView
,
self
)
.
post
(
request
,
*
args
,
**
kwargs
)
def
get_context_data
(
self
,
**
kwargs
):
def
get_context_data
(
self
,
**
kwargs
):
context
=
{
context
=
{
...
@@ -120,6 +145,29 @@ class AssetUpdateView(AdminUserRequiredMixin,UpdateAssetTagsMiXin,UpdateView):
...
@@ -120,6 +145,29 @@ class AssetUpdateView(AdminUserRequiredMixin,UpdateAssetTagsMiXin,UpdateView):
print
(
form
.
errors
)
print
(
form
.
errors
)
return
super
(
AssetUpdateView
,
self
)
.
form_invalid
(
form
)
return
super
(
AssetUpdateView
,
self
)
.
form_invalid
(
form
)
def
form_valid
(
self
,
form
):
print
self
.
new_form
.
keys
()
print
form
.
clean
()
.
keys
()
asset
=
form
.
save
(
commit
=
False
)
print
"1111"
def
prn_obj_key
(
obj_form
):
return
obj_form
.
clean
()
.
keys
()
for
i
in
prn_obj_key
(
form
):
if
i
not
in
self
.
new_form
.
keys
():
print
i
#delattr(asset, '"%s" % i')
#del asset.i
asset
.
save
()
asset
.
id
=
27
# asset.created_by = self.request.user.username or 'Admin'
asset
.
save
()
asset
.
id
=
28
asset
.
save
()
return
super
(
AssetUpdateView
,
self
)
.
form_valid
(
form
)
class
AssetDeleteView
(
DeleteView
):
class
AssetDeleteView
(
DeleteView
):
model
=
Asset
model
=
Asset
...
@@ -144,27 +192,27 @@ class AssetDetailView(DetailView):
...
@@ -144,27 +192,27 @@ class AssetDetailView(DetailView):
kwargs
.
update
(
context
)
kwargs
.
update
(
context
)
return
super
(
AssetDetailView
,
self
)
.
get_context_data
(
**
kwargs
)
return
super
(
AssetDetailView
,
self
)
.
get_context_data
(
**
kwargs
)
class
AssetModalListView
(
AdminUserRequiredMixin
,
ListView
):
class
AssetModalListView
(
AdminUserRequiredMixin
,
ListView
):
paginate_by
=
settings
.
CONFIG
.
DISPLAY_PER_PAGE
paginate_by
=
settings
.
CONFIG
.
DISPLAY_PER_PAGE
model
=
Asset
model
=
Asset
context_object_name
=
'asset_modal_list'
context_object_name
=
'asset_modal_list'
template_name
=
'assets/asset_modal_list.html'
template_name
=
'assets/asset_modal_list.html'
def
get_context_data
(
self
,
**
kwargs
):
def
get_context_data
(
self
,
**
kwargs
):
group_id
=
self
.
request
.
GET
.
get
(
'group_id'
)
group_id
=
self
.
request
.
GET
.
get
(
'group_id'
)
tag_id
=
self
.
request
.
GET
.
get
(
'tag_id'
)
tag_id
=
self
.
request
.
GET
.
get
(
'tag_id'
)
plain_id_lists
=
self
.
request
.
GET
.
get
(
'plain_id_lists'
)
plain_id_lists
=
self
.
request
.
GET
.
get
(
'plain_id_lists'
)
self
.
s
=
self
.
request
.
GET
.
get
(
'plain_id_lists'
)
self
.
s
=
self
.
request
.
GET
.
get
(
'plain_id_lists'
)
if
","
in
str
(
self
.
s
):
self
.
plain_id_lists
=
[
int
(
x
)
for
x
in
self
.
s
.
split
(
','
)]
else
:
self
.
plain_id_lists
=
[
self
.
s
]
print
plain_id_lists
if
plain_id_lists
:
if
plain_id_lists
:
if
","
in
str
(
self
.
s
):
plain_id_lists
=
[
int
(
x
)
for
x
in
self
.
s
.
split
(
','
)]
else
:
plain_id_lists
=
[
int
(
self
.
s
)]
context
=
{
context
=
{
'all_assets'
:
plain_id_lists
'all_assets'
:
plain_id_lists
}
}
kwargs
.
update
(
context
)
if
group_id
:
if
group_id
:
group
=
AssetGroup
.
objects
.
get
(
id
=
group_id
)
group
=
AssetGroup
.
objects
.
get
(
id
=
group_id
)
context
=
{
context
=
{
...
@@ -179,6 +227,7 @@ class AssetModalListView(AdminUserRequiredMixin, ListView):
...
@@ -179,6 +227,7 @@ class AssetModalListView(AdminUserRequiredMixin, ListView):
kwargs
.
update
(
context
)
kwargs
.
update
(
context
)
return
super
(
AssetModalListView
,
self
)
.
get_context_data
(
**
kwargs
)
return
super
(
AssetModalListView
,
self
)
.
get_context_data
(
**
kwargs
)
class
AssetGroupCreateView
(
AdminUserRequiredMixin
,
CreateView
):
class
AssetGroupCreateView
(
AdminUserRequiredMixin
,
CreateView
):
model
=
AssetGroup
model
=
AssetGroup
form_class
=
AssetGroupForm
form_class
=
AssetGroupForm
...
@@ -197,7 +246,6 @@ class AssetGroupCreateView(AdminUserRequiredMixin, CreateView):
...
@@ -197,7 +246,6 @@ class AssetGroupCreateView(AdminUserRequiredMixin, CreateView):
kwargs
.
update
(
context
)
kwargs
.
update
(
context
)
return
super
(
AssetGroupCreateView
,
self
)
.
get_context_data
(
**
kwargs
)
return
super
(
AssetGroupCreateView
,
self
)
.
get_context_data
(
**
kwargs
)
def
form_valid
(
self
,
form
):
def
form_valid
(
self
,
form
):
asset_group
=
form
.
save
()
asset_group
=
form
.
save
()
assets_id_list
=
self
.
request
.
POST
.
getlist
(
'assets'
,
[])
assets_id_list
=
self
.
request
.
POST
.
getlist
(
'assets'
,
[])
...
@@ -207,7 +255,8 @@ class AssetGroupCreateView(AdminUserRequiredMixin, CreateView):
...
@@ -207,7 +255,8 @@ class AssetGroupCreateView(AdminUserRequiredMixin, CreateView):
asset_group
.
save
()
asset_group
.
save
()
return
super
(
AssetGroupCreateView
,
self
)
.
form_valid
(
form
)
return
super
(
AssetGroupCreateView
,
self
)
.
form_valid
(
form
)
class
AssetGroupListView
(
AdminUserRequiredMixin
,
ListView
):
class
AssetGroupListView
(
AdminUserRequiredMixin
,
ListView
):
model
=
AssetGroup
model
=
AssetGroup
paginate_by
=
settings
.
CONFIG
.
DISPLAY_PER_PAGE
paginate_by
=
settings
.
CONFIG
.
DISPLAY_PER_PAGE
context_object_name
=
'asset_group_list'
context_object_name
=
'asset_group_list'
...
@@ -255,6 +304,7 @@ class AssetGroupDetailView(SingleObjectMixin, AdminUserRequiredMixin, ListView):
...
@@ -255,6 +304,7 @@ class AssetGroupDetailView(SingleObjectMixin, AdminUserRequiredMixin, ListView):
kwargs
.
update
(
context
)
kwargs
.
update
(
context
)
return
super
(
AssetGroupDetailView
,
self
)
.
get_context_data
(
**
kwargs
)
return
super
(
AssetGroupDetailView
,
self
)
.
get_context_data
(
**
kwargs
)
class
AssetGroupUpdateView
(
AdminUserRequiredMixin
,
UpdateView
):
class
AssetGroupUpdateView
(
AdminUserRequiredMixin
,
UpdateView
):
model
=
AssetGroup
model
=
AssetGroup
form_class
=
AssetGroupForm
form_class
=
AssetGroupForm
...
@@ -334,6 +384,7 @@ class IDCCreateView(AdminUserRequiredMixin, CreateView):
...
@@ -334,6 +384,7 @@ class IDCCreateView(AdminUserRequiredMixin, CreateView):
# IDC_add_success_next(user)
# IDC_add_success_next(user)
return
super
(
IDCCreateView
,
self
)
.
form_valid
(
form
)
return
super
(
IDCCreateView
,
self
)
.
form_valid
(
form
)
class
IDCUpdateView
(
AdminUserRequiredMixin
,
UpdateView
):
class
IDCUpdateView
(
AdminUserRequiredMixin
,
UpdateView
):
model
=
IDC
model
=
IDC
form_class
=
IDCForm
form_class
=
IDCForm
...
@@ -365,7 +416,6 @@ class IDCDeleteView(AdminUserRequiredMixin, DeleteView):
...
@@ -365,7 +416,6 @@ class IDCDeleteView(AdminUserRequiredMixin, DeleteView):
success_url
=
reverse_lazy
(
'assets:idc-list'
)
success_url
=
reverse_lazy
(
'assets:idc-list'
)
class
AdminUserListView
(
AdminUserRequiredMixin
,
ListView
):
class
AdminUserListView
(
AdminUserRequiredMixin
,
ListView
):
model
=
AdminUser
model
=
AdminUser
paginate_by
=
settings
.
CONFIG
.
DISPLAY_PER_PAGE
paginate_by
=
settings
.
CONFIG
.
DISPLAY_PER_PAGE
...
@@ -588,29 +638,6 @@ class SystemUserAssetView(AdminUserRequiredMixin, SingleObjectMixin, ListView):
...
@@ -588,29 +638,6 @@ class SystemUserAssetView(AdminUserRequiredMixin, SingleObjectMixin, ListView):
return
super
(
SystemUserAssetView
,
self
)
.
get_context_data
(
**
kwargs
)
return
super
(
SystemUserAssetView
,
self
)
.
get_context_data
(
**
kwargs
)
# class SystemUserAssetGroupView(AdminUserRequiredMixin, SingleObjectMixin, ListView):
# paginate_by = settings.CONFIG.DISPLAY_PER_PAGE
# template_name = 'assets/system_user_asset_group.html'
# context_object_name = 'system_user'
#
# def get(self, request, *args, **kwargs):
# self.object = self.get_object(queryset=SystemUser.objects.all())
# return super(SystemUserAssetGroupView, self).get(request, *args, **kwargs)
#
# Todo: queryset default order by connectivity, need ops support
# def get_queryset(self):
# return self.object.asset_groups.all()
#
# def get_context_data(self, **kwargs):
# context = {
# 'app': 'assets',
# 'action': 'System user asset group',
# 'asset_groups': self.get_queryset(),
# }
# kwargs.update(context)
# return super(SystemUserAssetGroupView, self).get_context_data(**kwargs)
class
TagView
(
ListView
):
class
TagView
(
ListView
):
context_object_name
=
'asset_list'
context_object_name
=
'asset_list'
template_name
=
'assets/asset_list.html'
template_name
=
'assets/asset_list.html'
...
@@ -643,6 +670,7 @@ class TagsListView(AdminUserRequiredMixin, ListView):
...
@@ -643,6 +670,7 @@ class TagsListView(AdminUserRequiredMixin, ListView):
kwargs
.
update
(
context
)
kwargs
.
update
(
context
)
return
super
(
TagsListView
,
self
)
.
get_context_data
(
**
kwargs
)
return
super
(
TagsListView
,
self
)
.
get_context_data
(
**
kwargs
)
class
AssetTagCreateView
(
AdminUserRequiredMixin
,
CreateView
):
class
AssetTagCreateView
(
AdminUserRequiredMixin
,
CreateView
):
model
=
Tag
model
=
Tag
form_class
=
AssetTagForm
form_class
=
AssetTagForm
...
@@ -670,6 +698,7 @@ class AssetTagCreateView(AdminUserRequiredMixin, CreateView):
...
@@ -670,6 +698,7 @@ class AssetTagCreateView(AdminUserRequiredMixin, CreateView):
asset_tag
.
save
()
asset_tag
.
save
()
return
super
(
AssetTagCreateView
,
self
)
.
form_valid
(
form
)
return
super
(
AssetTagCreateView
,
self
)
.
form_valid
(
form
)
class
AssetTagDetailView
(
SingleObjectMixin
,
AdminUserRequiredMixin
,
ListView
):
class
AssetTagDetailView
(
SingleObjectMixin
,
AdminUserRequiredMixin
,
ListView
):
template_name
=
'assets/asset_tag_detail.html'
template_name
=
'assets/asset_tag_detail.html'
paginate_by
=
settings
.
CONFIG
.
DISPLAY_PER_PAGE
paginate_by
=
settings
.
CONFIG
.
DISPLAY_PER_PAGE
...
@@ -690,6 +719,7 @@ class AssetTagDetailView(SingleObjectMixin, AdminUserRequiredMixin, ListView):
...
@@ -690,6 +719,7 @@ class AssetTagDetailView(SingleObjectMixin, AdminUserRequiredMixin, ListView):
kwargs
.
update
(
context
)
kwargs
.
update
(
context
)
return
super
(
AssetTagDetailView
,
self
)
.
get_context_data
(
**
kwargs
)
return
super
(
AssetTagDetailView
,
self
)
.
get_context_data
(
**
kwargs
)
class
AssetTagUpdateView
(
AdminUserRequiredMixin
,
UpdateView
):
class
AssetTagUpdateView
(
AdminUserRequiredMixin
,
UpdateView
):
model
=
Tag
model
=
Tag
form_class
=
AssetTagForm
form_class
=
AssetTagForm
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment