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
17657deb
Commit
17657deb
authored
Jan 08, 2017
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Bugfix] 和Master分支合并后,修复冲突,DRF 新版本要求 fields和exclude
parent
49861b6a
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
18 additions
and
20 deletions
+18
-20
api.py
apps/applications/api.py
+7
-1
terminal_update.html
.../applications/templates/applications/terminal_update.html
+1
-7
serializers.py
apps/assets/serializers.py
+5
-2
group.py
apps/users/models/group.py
+2
-7
serializers.py
apps/users/serializers.py
+1
-0
_user.html
apps/users/templates/users/_user.html
+0
-1
user_detail.html
apps/users/templates/users/user_detail.html
+2
-2
No files found.
apps/applications/api.py
View file @
17657deb
...
...
@@ -27,7 +27,7 @@ class TerminalRegisterView(ListCreateAPIView):
serializer
=
self
.
serializer_class
(
data
=
{
'name'
:
name
,
'remote_addr'
:
remote_addr
})
if
get_object_or_none
(
Terminal
,
name
=
name
):
return
Response
({
'msg'
:
'
Registed, Need admin
active it'
},
status
=
200
)
return
Response
({
'msg'
:
'
Already register, Need administrator
active it'
},
status
=
200
)
if
serializer
.
is_valid
():
terminal
=
serializer
.
save
()
...
...
@@ -54,6 +54,12 @@ class TerminalViewSet(viewsets.ModelViewSet):
def
create
(
self
,
request
,
*
args
,
**
kwargs
):
return
Response
({
'msg'
:
'Use register view except that'
},
status
=
404
)
def
destroy
(
self
,
request
,
*
args
,
**
kwargs
):
instance
=
self
.
get_object
()
if
instance
.
user
is
not
None
:
instance
.
user
.
delete
()
return
super
(
TerminalViewSet
,
self
)
.
destroy
(
request
,
*
args
,
**
kwargs
)
class
TerminalHeatbeatViewSet
(
viewsets
.
ModelViewSet
):
queryset
=
TerminalHeatbeat
.
objects
.
all
()
...
...
apps/applications/templates/applications/terminal_update.html
View file @
17657deb
...
...
@@ -32,18 +32,12 @@
{% csrf_token %}
<h3>
{% trans 'Info' %}
</h3>
{{ form.name|bootstrap_horizontal }}
{{ form.
ip
|bootstrap_horizontal }}
{{ form.
remote_addr
|bootstrap_horizontal }}
{{ form.type|bootstrap_horizontal }}
{{ form.url|bootstrap_horizontal }}
<div
class=
"hr-line-dashed"
></div>
<h3>
{% trans 'Other' %}
</h3>
<div
class=
"form-group"
>
<label
for=
"{{ form.is_active.id_for_label }}"
class=
"col-sm-2 control-label"
>
{% trans 'Active' %}
</label>
<div
class=
"col-sm-8"
>
{{ form.is_active}}
</div>
</div>
{{ form.comment|bootstrap_horizontal }}
<div
class=
"hr-line-dashed"
></div>
<div
class=
"form-group"
>
...
...
apps/assets/serializers.py
View file @
17657deb
...
...
@@ -13,7 +13,7 @@ class AssetGroupSerializer(BulkSerializerMixin, serializers.ModelSerializer):
class
Meta
:
model
=
AssetGroup
list_serializer_class
=
BulkListSerializer
fields
=
[
'id'
,
'name'
,
'comment'
,
'assets_amount'
]
fields
=
[
'id'
,
'name'
,
'comment'
,
'assets_amount'
,
'assets'
]
@staticmethod
def
get_assets_amount
(
obj
):
...
...
@@ -68,6 +68,7 @@ class TagSerializer(BulkSerializerMixin, serializers.ModelSerializer):
class
Meta
:
model
=
Tag
list_serializer_class
=
BulkListSerializer
fields
=
'__all__'
@staticmethod
def
get_assets_amount
(
obj
):
...
...
@@ -79,6 +80,7 @@ class AdminUserSerializer(serializers.ModelSerializer):
class
Meta
:
model
=
AdminUser
fields
=
'__all__'
def
get_field_names
(
self
,
declared_fields
,
info
):
fields
=
super
(
AdminUserSerializer
,
self
)
.
get_field_names
(
declared_fields
,
info
)
...
...
@@ -127,7 +129,7 @@ class AssetSerializer(BulkSerializerMixin, serializers.ModelSerializer):
class
Meta
(
object
):
model
=
Asset
list_serializer_class
=
BulkListSerializer
fields
=
[
'__all__'
]
fields
=
'__all__'
@staticmethod
def
get_hardware
(
obj
):
...
...
@@ -170,6 +172,7 @@ class IDCSerializer(BulkSerializerMixin, serializers.ModelSerializer):
class
Meta
:
model
=
IDC
fields
=
'__all__'
@staticmethod
def
get_assets_amount
(
obj
):
...
...
apps/users/models/group.py
View file @
17657deb
...
...
@@ -16,18 +16,13 @@ __all__ = ['UserGroup']
class
UserGroup
(
NoDeleteModelMixin
,
Group
):
comment
=
models
.
TextField
(
blank
=
True
,
verbose_name
=
_
(
'Comment'
))
date_created
=
models
.
DateTimeField
(
auto_now_add
=
True
)
date_created
=
models
.
DateTimeField
(
auto_now_add
=
True
,
null
=
True
)
created_by
=
models
.
CharField
(
max_length
=
100
)
def
__unicode__
(
self
):
return
self
.
name
def
has_member
(
self
,
user
):
if
user
in
self
.
users
.
all
():
return
True
return
False
def
delete
(
self
):
def
delete
(
self
,
using
=
None
,
keep_parents
=
False
):
if
self
.
name
!=
'Default'
:
self
.
users
.
clear
()
return
super
(
UserGroup
,
self
)
.
delete
()
...
...
apps/users/serializers.py
View file @
17657deb
...
...
@@ -56,6 +56,7 @@ class UserGroupSerializer(BulkSerializerMixin, serializers.ModelSerializer):
class
Meta
:
model
=
UserGroup
list_serializer_class
=
BulkListSerializer
fields
=
'__all__'
@staticmethod
def
get_user_amount
(
obj
):
...
...
apps/users/templates/users/_user.html
View file @
17657deb
...
...
@@ -27,7 +27,6 @@
<span
class=
"help-block "
>
{{ form.date_expired.errors }}
</span>
</div>
</div>
{{ form.date_expired|bootstrap_horizontal }}
<div
class=
"form-group"
>
<label
for=
"{{ form.enable_otp.id_for_label }}"
class=
"col-sm-2 control-label"
>
{% trans 'Enable OTP' %}
</label>
<div
class=
"col-sm-8"
>
...
...
apps/users/templates/users/user_detail.html
View file @
17657deb
...
...
@@ -346,7 +346,7 @@ $(document).ready(function() {
});
}).on('click', '#btn_reset_pk', function() {
function doReset() {
var the_url = '{% url "
api
-
users
:
user
-
reset
-
pk
" pk=user.id %}';
var the_url = '{% url "
api
-
users
:
user
-
public
-
key
-
reset
" pk=user.id %}';
var body = {};
var success = function() {
var msg = "
{
%
trans
'The reset-ssh-public-key E-mail has been sent successfully. Please inform the user to update his new ssh public key.'
%
}
";
...
...
@@ -372,7 +372,7 @@ $(document).ready(function() {
}).on('click', '#btn_user_update_pk', function(){
var $this = $(this);
var pk = $('#txt_pk').val();
var the_url = '{% url "
api
-
users
:
user
-
update
-
pk
" pk=user.id %}';
var the_url = '{% url "
api
-
users
:
user
-
public
-
key
-
reset
" pk=user.id %}';
var body = {'_public_key': pk};
var success = function() {
$('#txt_pk').val('');
...
...
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