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
acfe8950
Commit
acfe8950
authored
Sep 17, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MOdify asset create
parent
502c7e75
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
12 deletions
+23
-12
forms.py
apps/assets/forms.py
+0
-1
models.py
apps/assets/models.py
+22
-11
asset_create_update.html
apps/assets/templates/assets/asset_create_update.html
+1
-0
No files found.
apps/assets/forms.py
View file @
acfe8950
...
@@ -40,7 +40,6 @@ class AssetCreateForm(forms.ModelForm):
...
@@ -40,7 +40,6 @@ class AssetCreateForm(forms.ModelForm):
help_texts
=
{
help_texts
=
{
'hostname'
:
'* required'
,
'hostname'
:
'* required'
,
'ip'
:
'* required'
,
'ip'
:
'* required'
,
'type'
:
'* required'
,
}
}
...
...
apps/assets/models.py
View file @
acfe8950
...
@@ -54,10 +54,10 @@ class IDC(models.Model):
...
@@ -54,10 +54,10 @@ class IDC(models.Model):
class
AssetExtend
(
models
.
Model
):
class
AssetExtend
(
models
.
Model
):
key
=
models
.
CharField
(
max_length
=
64
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'KEY'
))
key
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
_
(
'KEY'
))
value
=
models
.
CharField
(
max_length
=
64
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'VALUE'
))
value
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
_
(
'VALUE'
))
created_by
=
models
.
CharField
(
max_length
=
32
,
blank
=
True
,
verbose_name
=
_
(
"Created by"
))
created_by
=
models
.
CharField
(
max_length
=
32
,
blank
=
True
,
verbose_name
=
_
(
"Created by"
))
date_created
=
models
.
DateTimeField
(
auto_now
=
True
,
null
=
True
,
blank
=
True
)
date_created
=
models
.
DateTimeField
(
auto_now
=
True
,
null
=
True
)
comment
=
models
.
TextField
(
blank
=
True
,
verbose_name
=
_
(
'Comment'
))
comment
=
models
.
TextField
(
blank
=
True
,
verbose_name
=
_
(
'Comment'
))
def
__unicode__
(
self
):
def
__unicode__
(
self
):
...
@@ -77,11 +77,13 @@ class AssetExtend(models.Model):
...
@@ -77,11 +77,13 @@ class AssetExtend(models.Model):
(
_
(
'env'
),
_
(
'Production'
)),
(
_
(
'env'
),
_
(
'Production'
)),
(
_
(
'env'
),
_
(
'Development'
)),
(
_
(
'env'
),
_
(
'Development'
)),
(
_
(
'env'
),
_
(
'Testing'
)),
(
_
(
'env'
),
_
(
'Testing'
)),
(
_
(
'zone'
),
_
(
'Default'
)),
):
):
cls
.
objects
.
create
(
key
=
k
,
value
=
v
,
created_by
=
'System'
)
cls
.
objects
.
create
(
key
=
k
,
value
=
v
,
created_by
=
'System'
)
class
Meta
:
class
Meta
:
db_table
=
'asset_extend'
db_table
=
'asset_extend'
index_together
=
(
'key'
,
'value'
)
class
AdminUser
(
models
.
Model
):
class
AdminUser
(
models
.
Model
):
...
@@ -248,7 +250,7 @@ class AssetGroup(models.Model):
...
@@ -248,7 +250,7 @@ class AssetGroup(models.Model):
@classmethod
@classmethod
def
initial
(
cls
):
def
initial
(
cls
):
asset_group
=
cls
(
name
=
_
(
'Default'
),
comm
o
nt
=
_
(
'Default asset group'
))
asset_group
=
cls
(
name
=
_
(
'Default'
),
comm
e
nt
=
_
(
'Default asset group'
))
asset_group
.
save
()
asset_group
.
save
()
@classmethod
@classmethod
...
@@ -271,6 +273,10 @@ class AssetGroup(models.Model):
...
@@ -271,6 +273,10 @@ class AssetGroup(models.Model):
class
Asset
(
models
.
Model
):
class
Asset
(
models
.
Model
):
STATUS_DEFAULT
=
AssetExtend
.
objects
.
get_or_create
(
key
=
'status'
,
value
=
_
(
'In use'
))
TYPE_DEFAULT
=
AssetExtend
.
objects
.
get_or_create
(
key
=
'type'
,
value
=
_
(
'Server'
))
ZONE_DEFAULT
=
AssetExtend
.
objects
.
get_or_create
(
key
=
'zone'
,
value
=
_
(
'Default'
))
ip
=
models
.
CharField
(
max_length
=
32
,
verbose_name
=
_
(
'IP'
))
ip
=
models
.
CharField
(
max_length
=
32
,
verbose_name
=
_
(
'IP'
))
other_ip
=
models
.
CharField
(
max_length
=
255
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Other IP'
))
other_ip
=
models
.
CharField
(
max_length
=
255
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Other IP'
))
remote_card_ip
=
models
.
CharField
(
max_length
=
16
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Remote card IP'
))
remote_card_ip
=
models
.
CharField
(
max_length
=
16
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Remote card IP'
))
...
@@ -291,13 +297,13 @@ class Asset(models.Model):
...
@@ -291,13 +297,13 @@ class Asset(models.Model):
cabinet_pos
=
models
.
IntegerField
(
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Cabinet position'
))
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'
))
status
=
models
.
ForeignKey
(
AssetExtend
,
null
=
True
,
blank
=
True
,
related_name
=
"status_asset"
,
status
=
models
.
ForeignKey
(
AssetExtend
,
null
=
True
,
blank
=
True
,
related_name
=
"status_asset"
,
verbose_name
=
_
(
'Asset status'
))
default
=
STATUS_DEFAULT
,
verbose_name
=
_
(
'Asset status'
))
type
=
models
.
ForeignKey
(
AssetExtend
,
null
=
True
,
blank
=
True
,
related_name
=
"type_asset"
,
type
=
models
.
ForeignKey
(
AssetExtend
,
null
=
True
,
limit_choices_to
=
{
'key'
:
'type'
}
,
verbose_name
=
_
(
'Asset type'
))
default
=
TYPE_DEFAULT
,
related_name
=
"type_asset"
,
verbose_name
=
_
(
'Asset type'
))
env
=
models
.
ForeignKey
(
AssetExtend
,
null
=
True
,
blank
=
True
,
related_name
=
"env_asset"
,
env
=
models
.
ForeignKey
(
AssetExtend
,
null
=
True
,
limit_choices_to
=
{
'key'
:
'env'
}
,
verbose_name
=
_
(
'Asset environment'
))
related_name
=
"env_asset"
,
verbose_name
=
_
(
'Asset environment'
))
zone
=
models
.
ForeignKey
(
AssetExtend
,
null
=
True
,
blank
=
True
,
related_name
=
"zone_asset"
,
zone
=
models
.
ForeignKey
(
AssetExtend
,
null
=
True
,
limit_choices_to
=
{
'key'
:
'zone'
},
default
=
ZONE_DEFAULT
,
verbose_name
=
_
(
'Asset zone'
))
related_name
=
"zone_asset"
,
verbose_name
=
_
(
'Asset zone'
))
sn
=
models
.
CharField
(
max_length
=
128
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Serial number'
))
sn
=
models
.
CharField
(
max_length
=
128
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Serial number'
))
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'
))
is_active
=
models
.
BooleanField
(
default
=
True
,
verbose_name
=
_
(
'Is active'
))
is_active
=
models
.
BooleanField
(
default
=
True
,
verbose_name
=
_
(
'Is active'
))
...
@@ -352,6 +358,11 @@ class Tag(models.Model):
...
@@ -352,6 +358,11 @@ class Tag(models.Model):
db_table
=
'label'
db_table
=
'label'
def
initial
():
for
cls
in
(
AssetExtend
,
AssetGroup
):
cls
.
initial
()
def
generate_fake
():
def
generate_fake
():
for
cls
in
(
AssetGroup
,
IDC
,
AdminUser
,
SystemUser
,
Asset
):
for
cls
in
(
AssetGroup
,
IDC
,
AdminUser
,
SystemUser
,
Asset
):
cls
.
generate_fake
()
cls
.
generate_fake
()
apps/assets/templates/assets/asset_create_update.html
View file @
acfe8950
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
{{ form.ip|bootstrap_horizontal }}
{{ form.ip|bootstrap_horizontal }}
{{ form.port|bootstrap_horizontal }}
{{ form.port|bootstrap_horizontal }}
{{ form.type|bootstrap_horizontal }}
{{ form.type|bootstrap_horizontal }}
{{ form.zone|bootstrap_horizontal }}
<div
class=
"hr-line-dashed"
></div>
<div
class=
"hr-line-dashed"
></div>
<h3>
{% trans 'Group' %}
</h3>
<h3>
{% trans 'Group' %}
</h3>
...
...
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