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
ff85e2ef
Commit
ff85e2ef
authored
Jul 11, 2019
by
八千流
Committed by
老广
Jul 11, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 创建/更新 命令过滤器 使用api (#2926)
parent
6e86e3f1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
3 deletions
+38
-3
cmd_filter.py
apps/assets/serializers/cmd_filter.py
+9
-3
cmd_filter_create_update.html
apps/assets/templates/assets/cmd_filter_create_update.html
+27
-0
cmd_filter.py
apps/assets/views/cmd_filter.py
+2
-0
No files found.
apps/assets/serializers/cmd_filter.py
View file @
ff85e2ef
...
@@ -10,13 +10,19 @@ from orgs.mixins import BulkOrgResourceModelSerializer
...
@@ -10,13 +10,19 @@ from orgs.mixins import BulkOrgResourceModelSerializer
class
CommandFilterSerializer
(
BulkOrgResourceModelSerializer
):
class
CommandFilterSerializer
(
BulkOrgResourceModelSerializer
):
rules
=
serializers
.
PrimaryKeyRelatedField
(
queryset
=
CommandFilterRule
.
objects
.
all
(),
many
=
True
)
system_users
=
serializers
.
PrimaryKeyRelatedField
(
queryset
=
SystemUser
.
objects
.
all
(),
many
=
True
)
class
Meta
:
class
Meta
:
model
=
CommandFilter
model
=
CommandFilter
list_serializer_class
=
AdaptedBulkListSerializer
list_serializer_class
=
AdaptedBulkListSerializer
fields
=
'__all__'
fields
=
[
'id'
,
'name'
,
'org_id'
,
'org_name'
,
'is_active'
,
'comment'
,
'created_by'
,
'date_created'
,
'date_updated'
,
'rules'
,
'system_users'
]
extra_kwargs
=
{
'rules'
:
{
'read_only'
:
True
},
'system_users'
:
{
'read_only'
:
True
}
}
class
CommandFilterRuleSerializer
(
BulkOrgResourceModelSerializer
):
class
CommandFilterRuleSerializer
(
BulkOrgResourceModelSerializer
):
...
...
apps/assets/templates/assets/cmd_filter_create_update.html
View file @
ff85e2ef
...
@@ -18,3 +18,29 @@
...
@@ -18,3 +18,29 @@
</div>
</div>
</form>
</form>
{% endblock %}
{% endblock %}
{% block custom_foot_js %}
<script>
$
(
document
).
ready
(
function
()
{
})
.
on
(
"submit"
,
"form"
,
function
(
evt
)
{
evt
.
preventDefault
();
var
the_url
=
'{% url '
api
-
assets
:
cmd
-
filter
-
list
' %}'
;
var
redirect_to
=
'{% url "assets:cmd-filter-list" %}'
;
var
method
=
"POST"
;
{
%
if
type
==
"update"
%
}
the_url
=
'{% url '
api
-
assets
:
cmd
-
filter
-
detail
' pk=object.id %}'
;
method
=
"PUT"
;
{
%
endif
%
}
var
form
=
$
(
"form"
);
var
data
=
form
.
serializeObject
();
var
props
=
{
url
:
the_url
,
data
:
data
,
method
:
method
,
form
:
form
,
redirect_to
:
redirect_to
};
formSubmit
(
props
);
})
</script>
{% endblock %}
\ No newline at end of file
apps/assets/views/cmd_filter.py
View file @
ff85e2ef
...
@@ -47,6 +47,7 @@ class CommandFilterCreateView(PermissionsMixin, CreateView):
...
@@ -47,6 +47,7 @@ class CommandFilterCreateView(PermissionsMixin, CreateView):
context
=
{
context
=
{
'app'
:
_
(
'Assets'
),
'app'
:
_
(
'Assets'
),
'action'
:
_
(
'Create command filter'
),
'action'
:
_
(
'Create command filter'
),
'type'
:
'create'
}
}
kwargs
.
update
(
context
)
kwargs
.
update
(
context
)
return
super
()
.
get_context_data
(
**
kwargs
)
return
super
()
.
get_context_data
(
**
kwargs
)
...
@@ -64,6 +65,7 @@ class CommandFilterUpdateView(PermissionsMixin, UpdateView):
...
@@ -64,6 +65,7 @@ class CommandFilterUpdateView(PermissionsMixin, UpdateView):
context
=
{
context
=
{
'app'
:
_
(
'Assets'
),
'app'
:
_
(
'Assets'
),
'action'
:
_
(
'Update command filter'
),
'action'
:
_
(
'Update command filter'
),
'type'
:
'update'
}
}
kwargs
.
update
(
context
)
kwargs
.
update
(
context
)
return
super
()
.
get_context_data
(
**
kwargs
)
return
super
()
.
get_context_data
(
**
kwargs
)
...
...
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