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
1cba714b
Commit
1cba714b
authored
Sep 23, 2019
by
BaiJiangJie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 资产主机名提示、限制不被允许的特殊字符
parent
ef122ec1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
0 deletions
+12
-0
asset.py
apps/assets/forms/asset.py
+2
-0
asset.py
apps/assets/serializers/asset.py
+10
-0
No files found.
apps/assets/forms/asset.py
View file @
1cba714b
...
...
@@ -68,6 +68,8 @@ class AssetCreateForm(OrgModelForm):
'nodes'
:
_
(
"Node"
),
}
help_texts
=
{
'hostname'
:
_
(
'Only Numbers, letters, and characters ( {} ) '
'are allowed'
)
.
format
(
" "
.
join
([
'.'
,
'_'
,
'@'
])),
'admin_user'
:
_
(
'root or other NOPASSWD sudo privilege user existed in asset,'
'If asset is windows or other set any one, more see admin user left menu'
...
...
apps/assets/serializers/asset.py
View file @
1cba714b
# -*- coding: utf-8 -*-
#
import
re
from
rest_framework
import
serializers
from
django.db.models
import
Prefetch
from
django.utils.translation
import
ugettext_lazy
as
_
...
...
@@ -91,6 +92,15 @@ class AssetSerializer(BulkOrgResourceModelSerializer):
'org_name'
:
{
'label'
:
_
(
'Org name'
)}
}
@staticmethod
def
validate_hostname
(
hostname
):
pattern
=
r"^[\._@a-zA-Z0-9-]+$"
res
=
re
.
match
(
pattern
,
hostname
)
if
res
is
None
:
msg
=
_
(
"* The hostname contains characters that are not allowed"
)
raise
serializers
.
ValidationError
(
msg
)
return
hostname
@classmethod
def
setup_eager_loading
(
cls
,
queryset
):
""" Perform necessary eager loading of data. """
...
...
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