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
1fbf4ac0
Commit
1fbf4ac0
authored
Jan 30, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 删除部分资产属性
parent
da4c5f48
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
4 additions
and
87 deletions
+4
-87
forms.py
apps/assets/forms.py
+4
-11
asset.py
apps/assets/models/asset.py
+0
-26
serializers.py
apps/assets/serializers.py
+0
-1
asset_create.html
apps/assets/templates/assets/asset_create.html
+0
-2
asset_detail.html
apps/assets/templates/assets/asset_detail.html
+0
-38
asset_update.html
apps/assets/templates/assets/asset_update.html
+0
-9
No files found.
apps/assets/forms.py
View file @
1fbf4ac0
...
@@ -12,9 +12,8 @@ class AssetCreateForm(forms.ModelForm):
...
@@ -12,9 +12,8 @@ class AssetCreateForm(forms.ModelForm):
class
Meta
:
class
Meta
:
model
=
Asset
model
=
Asset
fields
=
[
fields
=
[
'hostname'
,
'ip'
,
'public_ip'
,
'port'
,
'type'
,
'comment'
,
'hostname'
,
'ip'
,
'public_ip'
,
'port'
,
'comment'
,
'cluster'
,
'cluster'
,
'groups'
,
'status'
,
'env'
,
'is_active'
,
'groups'
,
'is_active'
,
'admin_user'
,
'labels'
'admin_user'
,
'labels'
]
]
widgets
=
{
widgets
=
{
...
@@ -61,8 +60,7 @@ class AssetUpdateForm(forms.ModelForm):
...
@@ -61,8 +60,7 @@ class AssetUpdateForm(forms.ModelForm):
model
=
Asset
model
=
Asset
fields
=
[
fields
=
[
'hostname'
,
'ip'
,
'port'
,
'groups'
,
"cluster"
,
'is_active'
,
'hostname'
,
'ip'
,
'port'
,
'groups'
,
"cluster"
,
'is_active'
,
'type'
,
'env'
,
'status'
,
'public_ip'
,
'remote_card_ip'
,
'cabinet_no'
,
'public_ip'
,
'number'
,
'comment'
,
'admin_user'
,
'labels'
'cabinet_pos'
,
'number'
,
'comment'
,
'admin_user'
,
'labels'
]
]
widgets
=
{
widgets
=
{
'groups'
:
forms
.
SelectMultiple
(
attrs
=
{
'groups'
:
forms
.
SelectMultiple
(
attrs
=
{
...
@@ -94,10 +92,6 @@ class AssetUpdateForm(forms.ModelForm):
...
@@ -94,10 +92,6 @@ class AssetUpdateForm(forms.ModelForm):
raise
forms
.
ValidationError
(
_
(
"You need set a admin user if cluster not have"
))
raise
forms
.
ValidationError
(
_
(
"You need set a admin user if cluster not have"
))
return
self
.
cleaned_data
[
'admin_user'
]
return
self
.
cleaned_data
[
'admin_user'
]
def
is_valid
(
self
):
print
(
self
.
data
)
return
super
()
.
is_valid
()
class
AssetBulkUpdateForm
(
forms
.
ModelForm
):
class
AssetBulkUpdateForm
(
forms
.
ModelForm
):
assets
=
forms
.
ModelMultipleChoiceField
(
assets
=
forms
.
ModelMultipleChoiceField
(
...
@@ -117,8 +111,7 @@ class AssetBulkUpdateForm(forms.ModelForm):
...
@@ -117,8 +111,7 @@ class AssetBulkUpdateForm(forms.ModelForm):
class
Meta
:
class
Meta
:
model
=
Asset
model
=
Asset
fields
=
[
fields
=
[
'assets'
,
'port'
,
'groups'
,
"cluster"
,
'assets'
,
'port'
,
'groups'
,
"cluster"
,
'labels'
'type'
,
'env'
,
]
]
widgets
=
{
widgets
=
{
'groups'
:
forms
.
SelectMultiple
(
'groups'
:
forms
.
SelectMultiple
(
...
...
apps/assets/models/asset.py
View file @
1fbf4ac0
...
@@ -29,25 +29,6 @@ def default_cluster():
...
@@ -29,25 +29,6 @@ def default_cluster():
class
Asset
(
models
.
Model
):
class
Asset
(
models
.
Model
):
# Todo: Move them to settings
STATUS_CHOICES
=
(
(
'In use'
,
_
(
'In use'
)),
(
'Out of use'
,
_
(
'Out of use'
)),
)
TYPE_CHOICES
=
(
(
'Server'
,
_
(
'Server'
)),
(
'VM'
,
_
(
'VM'
)),
(
'Switch'
,
_
(
'Switch'
)),
(
'Router'
,
_
(
'Router'
)),
(
'Firewall'
,
_
(
'Firewall'
)),
(
'Storage'
,
_
(
"Storage"
)),
)
ENV_CHOICES
=
(
(
'Prod'
,
_
(
'Production'
)),
(
'Dev'
,
_
(
'Development'
)),
(
'Test'
,
_
(
'Testing'
)),
)
# Important
# Important
id
=
models
.
UUIDField
(
default
=
uuid
.
uuid4
,
primary_key
=
True
)
id
=
models
.
UUIDField
(
default
=
uuid
.
uuid4
,
primary_key
=
True
)
ip
=
models
.
GenericIPAddressField
(
max_length
=
32
,
verbose_name
=
_
(
'IP'
),
db_index
=
True
)
ip
=
models
.
GenericIPAddressField
(
max_length
=
32
,
verbose_name
=
_
(
'IP'
),
db_index
=
True
)
...
@@ -56,18 +37,12 @@ class Asset(models.Model):
...
@@ -56,18 +37,12 @@ class Asset(models.Model):
groups
=
models
.
ManyToManyField
(
AssetGroup
,
blank
=
True
,
related_name
=
'assets'
,
verbose_name
=
_
(
'Asset groups'
))
groups
=
models
.
ManyToManyField
(
AssetGroup
,
blank
=
True
,
related_name
=
'assets'
,
verbose_name
=
_
(
'Asset groups'
))
cluster
=
models
.
ForeignKey
(
Cluster
,
related_name
=
'assets'
,
default
=
default_cluster
,
on_delete
=
models
.
SET_DEFAULT
,
verbose_name
=
_
(
'Cluster'
))
cluster
=
models
.
ForeignKey
(
Cluster
,
related_name
=
'assets'
,
default
=
default_cluster
,
on_delete
=
models
.
SET_DEFAULT
,
verbose_name
=
_
(
'Cluster'
))
is_active
=
models
.
BooleanField
(
default
=
True
,
verbose_name
=
_
(
'Is active'
))
is_active
=
models
.
BooleanField
(
default
=
True
,
verbose_name
=
_
(
'Is active'
))
type
=
models
.
CharField
(
choices
=
TYPE_CHOICES
,
max_length
=
16
,
blank
=
True
,
null
=
True
,
default
=
'Server'
,
verbose_name
=
_
(
'Asset type'
),)
env
=
models
.
CharField
(
choices
=
ENV_CHOICES
,
max_length
=
8
,
blank
=
True
,
null
=
True
,
default
=
'Prod'
,
verbose_name
=
_
(
'Asset environment'
),)
status
=
models
.
CharField
(
choices
=
STATUS_CHOICES
,
max_length
=
12
,
null
=
True
,
blank
=
True
,
default
=
'In use'
,
verbose_name
=
_
(
'Asset status'
))
# Auth
# Auth
admin_user
=
models
.
ForeignKey
(
'assets.AdminUser'
,
null
=
True
,
blank
=
True
,
on_delete
=
models
.
SET_NULL
,
verbose_name
=
_
(
"Admin user"
))
admin_user
=
models
.
ForeignKey
(
'assets.AdminUser'
,
null
=
True
,
blank
=
True
,
on_delete
=
models
.
SET_NULL
,
verbose_name
=
_
(
"Admin user"
))
# Some information
# Some information
public_ip
=
models
.
GenericIPAddressField
(
max_length
=
32
,
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
'Public IP'
))
public_ip
=
models
.
GenericIPAddressField
(
max_length
=
32
,
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
'Public IP'
))
remote_card_ip
=
models
.
CharField
(
max_length
=
16
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Remote control card IP'
))
cabinet_no
=
models
.
CharField
(
max_length
=
32
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Cabinet number'
))
cabinet_pos
=
models
.
IntegerField
(
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Cabinet position'
))
number
=
models
.
CharField
(
max_length
=
32
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Asset number'
))
number
=
models
.
CharField
(
max_length
=
32
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Asset number'
))
# Collect
# Collect
...
@@ -89,7 +64,6 @@ class Asset(models.Model):
...
@@ -89,7 +64,6 @@ class Asset(models.Model):
hostname_raw
=
models
.
CharField
(
max_length
=
128
,
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
'Hostname raw'
))
hostname_raw
=
models
.
CharField
(
max_length
=
128
,
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
'Hostname raw'
))
labels
=
models
.
ManyToManyField
(
'assets.Label'
,
blank
=
True
,
related_name
=
'assets'
,
verbose_name
=
_
(
"Labels"
))
labels
=
models
.
ManyToManyField
(
'assets.Label'
,
blank
=
True
,
related_name
=
'assets'
,
verbose_name
=
_
(
"Labels"
))
created_by
=
models
.
CharField
(
max_length
=
32
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Created by'
))
created_by
=
models
.
CharField
(
max_length
=
32
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Created by'
))
date_created
=
models
.
DateTimeField
(
auto_now_add
=
True
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Date created'
))
date_created
=
models
.
DateTimeField
(
auto_now_add
=
True
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Date created'
))
comment
=
models
.
TextField
(
max_length
=
128
,
default
=
''
,
blank
=
True
,
verbose_name
=
_
(
'Comment'
))
comment
=
models
.
TextField
(
max_length
=
128
,
default
=
''
,
blank
=
True
,
verbose_name
=
_
(
'Comment'
))
...
...
apps/assets/serializers.py
View file @
1fbf4ac0
...
@@ -173,7 +173,6 @@ class AssetSerializer(BulkSerializerMixin, serializers.ModelSerializer):
...
@@ -173,7 +173,6 @@ class AssetSerializer(BulkSerializerMixin, serializers.ModelSerializer):
def
get_field_names
(
self
,
declared_fields
,
info
):
def
get_field_names
(
self
,
declared_fields
,
info
):
fields
=
super
()
.
get_field_names
(
declared_fields
,
info
)
fields
=
super
()
.
get_field_names
(
declared_fields
,
info
)
fields
.
extend
([
fields
.
extend
([
'get_type_display'
,
'get_env_display'
,
'hardware_info'
,
'is_connective'
,
'hardware_info'
,
'is_connective'
,
])
])
return
fields
return
fields
...
...
apps/assets/templates/assets/asset_create.html
View file @
1fbf4ac0
...
@@ -19,8 +19,6 @@
...
@@ -19,8 +19,6 @@
{% bootstrap_field form.port layout="horizontal" %}
{% bootstrap_field form.port layout="horizontal" %}
{% bootstrap_field form.cluster layout="horizontal" %}
{% bootstrap_field form.cluster layout="horizontal" %}
{% bootstrap_field form.public_ip layout="horizontal" %}
{% bootstrap_field form.public_ip layout="horizontal" %}
{% bootstrap_field form.type layout="horizontal" %}
{% bootstrap_field form.env layout="horizontal" %}
<div
class=
"hr-line-dashed"
></div>
<div
class=
"hr-line-dashed"
></div>
<h3>
{% trans 'Auth' %}
</h3>
<h3>
{% trans 'Auth' %}
</h3>
...
...
apps/assets/templates/assets/asset_detail.html
View file @
1fbf4ac0
...
@@ -77,22 +77,10 @@
...
@@ -77,22 +77,10 @@
<td></td>
<td></td>
{% endif %}
{% endif %}
</tr>
</tr>
<tr>
<td>
{% trans 'Remote card IP' %}:
</td>
<td><b>
{{ asset.remote_card_ip|default:"" }}
</b></td>
</tr>
<tr>
<tr>
<td>
{% trans 'Cluster' %}:
</td>
<td>
{% trans 'Cluster' %}:
</td>
<td><b>
{{ asset.cluster.name }}
</b></td>
<td><b>
{{ asset.cluster.name }}
</b></td>
</tr>
</tr>
<tr>
<td>
{% trans 'Cabinet number' %}:
</td>
<td><b>
{{ asset.cabinet_no|default:"" }}
</b></td>
</tr>
<tr>
<td>
{% trans 'Cabinet position' %}:
</td>
<td><b>
{{ asset.cabinet_pos|default:"" }}
</b></td>
</tr>
<tr>
<tr>
<td>
{% trans 'Vendor' %}:
</td>
<td>
{% trans 'Vendor' %}:
</td>
<td><b>
{{ asset.vendor|default:"" }}
</b></td>
<td><b>
{{ asset.vendor|default:"" }}
</b></td>
...
@@ -121,22 +109,10 @@
...
@@ -121,22 +109,10 @@
<td>
{% trans 'OS' %}:
</td>
<td>
{% trans 'OS' %}:
</td>
<td><b>
{{ asset.os|default:"" }} {{ asset.os_version|default:"" }} {{ asset.os_arch|default:"" }}
</b></td>
<td><b>
{{ asset.os|default:"" }} {{ asset.os_version|default:"" }} {{ asset.os_arch|default:"" }}
</b></td>
</tr>
</tr>
<tr>
<td>
{% trans 'Asset status' %}:
</td>
<td><b>
{{ asset.status }}
</b></td>
</tr>
<tr>
<tr>
<td>
{% trans 'Is active' %}:
</td>
<td>
{% trans 'Is active' %}:
</td>
<td><b>
{{ asset.is_active|yesno:"Yes,No" }}
</b></td>
<td><b>
{{ asset.is_active|yesno:"Yes,No" }}
</b></td>
</tr>
</tr>
<tr>
<td>
{% trans 'Asset type' %}:
</td>
<td><b>
{{ asset.type }}
</b></td>
</tr>
<tr>
<td>
{% trans 'Asset environment' %}:
</td>
<td><b>
{{ asset.env }}
</b></td>
</tr>
<tr>
<tr>
<td>
{% trans 'Serial number' %}:
</td>
<td>
{% trans 'Serial number' %}:
</td>
<td><b>
{{ asset.sn|default:"" }}
</b></td>
<td><b>
{{ asset.sn|default:"" }}
</b></td>
...
@@ -250,20 +226,6 @@
...
@@ -250,20 +226,6 @@
<i
class=
"fa fa-info-circle"
></i>
{% trans 'Labels' %}
<i
class=
"fa fa-info-circle"
></i>
{% trans 'Labels' %}
</div>
</div>
<div
class=
"panel-body"
>
<div
class=
"panel-body"
>
{#
<table
class=
"table"
>
#}
{#
<tbody>
#}
{# {% for label in asset.labels.all %}#}
{#
<tr
{%
if
forloop
.
counter =
=
1
%}
class=
"no-borders-tr"
{%
endif
%}
>
#}
{#
<td>
{{ label.name }}
</td>
#}
{#
<td>
#}
{#
<span
class=
"pull-right"
>
#}
{# {{ label.value }}#}
{#
</span>
#}
{#
</td>
#}
{#
</tr>
#}
{# {% endfor %}#}
{#
</tbody>
#}
{#
</table>
#}
<ul
class=
"tag-list"
style=
"padding: 0"
>
<ul
class=
"tag-list"
style=
"padding: 0"
>
{% for label in asset.labels.all %}
{% for label in asset.labels.all %}
<li
><a
href=
""
><i
class=
"fa fa-tag"
></i>
{{ label.name }}:{{ label.value }}
</a></li>
<li
><a
href=
""
><i
class=
"fa fa-tag"
></i>
{{ label.name }}:{{ label.value }}
</a></li>
...
...
apps/assets/templates/assets/asset_update.html
View file @
1fbf4ac0
...
@@ -24,8 +24,6 @@
...
@@ -24,8 +24,6 @@
{% bootstrap_field form.port layout="horizontal" %}
{% bootstrap_field form.port layout="horizontal" %}
{% bootstrap_field form.cluster layout="horizontal" %}
{% bootstrap_field form.cluster layout="horizontal" %}
{% bootstrap_field form.public_ip layout="horizontal" %}
{% bootstrap_field form.public_ip layout="horizontal" %}
{% bootstrap_field form.type layout="horizontal" %}
{% bootstrap_field form.env layout="horizontal" %}
<div
class=
"hr-line-dashed"
></div>
<div
class=
"hr-line-dashed"
></div>
<h3>
{% trans 'Auth' %}
</h3>
<h3>
{% trans 'Auth' %}
</h3>
...
@@ -59,16 +57,9 @@
...
@@ -59,16 +57,9 @@
<div
class=
"hr-line-dashed"
></div>
<div
class=
"hr-line-dashed"
></div>
<h3>
{% trans 'Configuration' %}
</h3>
<h3>
{% trans 'Configuration' %}
</h3>
{% bootstrap_field form.number layout="horizontal" %}
{% bootstrap_field form.number layout="horizontal" %}
{% bootstrap_field form.remote_card_ip layout="horizontal" %}
<div
class=
"hr-line-dashed"
></div>
<h3>
{% trans 'Location' %}
</h3>
{% bootstrap_field form.cabinet_no layout="horizontal" %}
{% bootstrap_field form.cabinet_pos layout="horizontal" %}
<div
class=
"hr-line-dashed"
></div>
<div
class=
"hr-line-dashed"
></div>
<h3>
{% trans 'Other' %}
</h3>
<h3>
{% trans 'Other' %}
</h3>
{% bootstrap_field form.status layout="horizontal" %}
{% bootstrap_field form.comment layout="horizontal" %}
{% bootstrap_field form.comment layout="horizontal" %}
{% bootstrap_field form.is_active layout="horizontal" %}
{% bootstrap_field form.is_active layout="horizontal" %}
...
...
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