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
cafb0e02
Commit
cafb0e02
authored
Jan 22, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改dictfiled
parent
9d399c47
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
32 deletions
+12
-32
fields.py
apps/common/fields.py
+6
-4
forms.py
apps/common/forms.py
+2
-2
_add_terminal_command_storage_modal.html
...templates/common/_add_terminal_command_storage_modal.html
+0
-21
terminal_setting.html
apps/common/templates/common/terminal_setting.html
+2
-3
settings.py
apps/jumpserver/settings.py
+2
-2
No files found.
apps/common/fields.py
View file @
cafb0e02
...
@@ -5,6 +5,7 @@ import json
...
@@ -5,6 +5,7 @@ import json
from
django
import
forms
from
django
import
forms
from
django.utils
import
six
from
django.utils
import
six
from
django.core.exceptions
import
ValidationError
from
django.core.exceptions
import
ValidationError
from
django.utils.translation
import
ugettext
as
_
class
DictField
(
forms
.
Field
):
class
DictField
(
forms
.
Field
):
...
@@ -21,12 +22,13 @@ class DictField(forms.Field):
...
@@ -21,12 +22,13 @@ class DictField(forms.Field):
value
=
json
.
loads
(
value
)
value
=
json
.
loads
(
value
)
return
value
return
value
except
json
.
JSONDecodeError
:
except
json
.
JSONDecodeError
:
pass
return
ValidationError
(
_
(
"Not a valid json"
))
value
=
{}
else
:
return
value
return
ValidationError
(
_
(
"Not a string type"
))
def
validate
(
self
,
value
):
def
validate
(
self
,
value
):
print
(
value
)
if
isinstance
(
value
,
ValidationError
):
raise
value
if
not
value
and
self
.
required
:
if
not
value
and
self
.
required
:
raise
ValidationError
(
self
.
error_messages
[
'required'
],
code
=
'required'
)
raise
ValidationError
(
self
.
error_messages
[
'required'
],
code
=
'required'
)
...
...
apps/common/forms.py
View file @
cafb0e02
...
@@ -26,7 +26,7 @@ def to_form_value(value):
...
@@ -26,7 +26,7 @@ def to_form_value(value):
data
=
value
data
=
value
return
data
return
data
except
json
.
JSONDecodeError
:
except
json
.
JSONDecodeError
:
return
''
return
""
class
BaseForm
(
forms
.
Form
):
class
BaseForm
(
forms
.
Form
):
...
@@ -39,7 +39,7 @@ class BaseForm(forms.Form):
...
@@ -39,7 +39,7 @@ class BaseForm(forms.Form):
if
db_value
is
False
or
db_value
:
if
db_value
is
False
or
db_value
:
field
.
initial
=
to_form_value
(
db_value
)
field
.
initial
=
to_form_value
(
db_value
)
elif
django_value
is
False
or
django_value
:
elif
django_value
is
False
or
django_value
:
field
.
initial
=
django_value
field
.
initial
=
to_form_value
(
to_model_value
(
django_value
))
def
save
(
self
,
category
=
"default"
):
def
save
(
self
,
category
=
"default"
):
if
not
self
.
is_bound
:
if
not
self
.
is_bound
:
...
...
apps/common/templates/common/_add_terminal_command_storage_modal.html
deleted
100644 → 0
View file @
9d399c47
{% extends '_modal.html' %}
{% load i18n %}
{% block modal_id %}add_command_storage_model{% endblock %}
{% block modal_title%}{% trans "Add command storage" %}{% endblock %}
{% block modal_body %}
<form
method=
"post"
action=
""
id=
"add_command_storage_form"
>
{% csrf_token %}
<div
class=
"form-group"
>
<label
class=
"control-label"
for=
"id_assets"
>
{% trans "Template" %}
</label>
<a
href=
"{% url 'assets:asset-export' %}"
style=
"display: block"
>
{% trans 'Download' %}
</a>
</div>
<div
class=
"form-group"
>
<label
class=
"control-label"
for=
"id_users"
>
{% trans "Asset csv file" %}
</label>
<input
id=
"id_assets"
type=
"file"
name=
"file"
/>
<span
class=
"help-block red-fonts"
>
{% trans 'If set id, will use this id update asset existed' %}
</span>
</div>
</form>
{% endblock %}
{% block modal_confirm_id %}btn_asset_import{% endblock %}
apps/common/templates/common/terminal_setting.html
View file @
cafb0e02
...
@@ -73,8 +73,8 @@
...
@@ -73,8 +73,8 @@
</tbody>
</tbody>
</table>
</table>
{#
<button
class=
"btn btn-default btn-circle btn-add-command-storage"
data-toggle=
"modal"
data-target=
"#add_command_storage_model"
tabindex=
"0"
type=
"button"
><i
class=
"fa fa-plus"
></i></button>
#}
{#
<button
class=
"btn btn-default btn-circle btn-add-command-storage"
data-toggle=
"modal"
data-target=
"#add_command_storage_model"
tabindex=
"0"
type=
"button"
><i
class=
"fa fa-plus"
></i></button>
#}
<div
class=
"hr-line-dashed"
></div>
{#
<div
class=
"hr-line-dashed"
></div>
#}
<h3>
{% trans "Replay storage" %}
</h3>
{#
<h3>
{% trans "Replay storage" %}
</h3>
#}
<div
class=
"hr-line-dashed"
></div>
<div
class=
"hr-line-dashed"
></div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
...
@@ -92,7 +92,6 @@
...
@@ -92,7 +92,6 @@
</div>
</div>
</div>
</div>
</div>
</div>
{% include 'common/_add_terminal_command_storage_modal.html' %}
{% endblock %}
{% endblock %}
{% block custom_foot_js %}
{% block custom_foot_js %}
<script>
<script>
...
...
apps/jumpserver/settings.py
View file @
cafb0e02
...
@@ -378,8 +378,8 @@ COMMAND_STORAGE = {
...
@@ -378,8 +378,8 @@ COMMAND_STORAGE = {
}
}
TERMINAL_COMMAND_STORAGE
=
{
TERMINAL_COMMAND_STORAGE
=
{
'default'
:
{
"default"
:
{
'TYPE'
:
'server'
,
"TYPE"
:
"server"
,
},
},
# 'ali-es': {
# 'ali-es': {
# 'TYPE': 'elasticsearch',
# 'TYPE': 'elasticsearch',
...
...
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