Commit 164c5eba authored by ibuler's avatar ibuler

Merge branch 'dev' of github.com:jumpserver/jumpserver into dev

parents dbdcdb72 b56d73ba
...@@ -71,14 +71,14 @@ function initTable2() { ...@@ -71,14 +71,14 @@ function initTable2() {
function onSelected2(event, treeNode) { function onSelected2(event, treeNode) {
var url = asset_table2.ajax.url(); var url = asset_table2.ajax.url();
url = setUrlParam(url, "node_id", treeNode.node_id); url = setUrlParam(url, "node_id", treeNode.meta.node.id);
setCookie('node_selected', treeNode.id);
asset_table2.ajax.url(url); asset_table2.ajax.url(url);
asset_table2.ajax.reload(); asset_table2.ajax.reload();
} }
function initTree2() { function initTree2() {
var url = '{% url 'api-assets:node-children-tree' %}?assets=0';
var setting = { var setting = {
view: { view: {
dblClickExpand: false, dblClickExpand: false,
...@@ -89,29 +89,17 @@ function initTree2() { ...@@ -89,29 +89,17 @@ function initTree2() {
enable: true enable: true
} }
}, },
async: {
enable: true,
url: url,
autoParam: ["id=key", "name=n", "level=lv"],
type: 'get'
},
callback: { callback: {
onSelected: onSelected2 onSelected: onSelected2
} }
}; };
zTree2 = $.fn.zTree.init($("#assetTree2"), setting);
var zNodes = [];
$.get("{% url 'api-assets:node-list' %}", function(data, status){
$.each(data, function (index, value) {
value["node_id"] = value["id"];
value["id"] = value["tree_id"];
value["pId"] = value["tree_parent"];
{#value["open"] = true;#}
if (value["key"] === "0") {
value["open"] = true;
}
value["name"] = value["value"] + ' (' + value['assets_amount'] + ')';
});
zNodes = data;
$.fn.zTree.init($("#assetTree2"), setting, zNodes);
zTree2 = $.fn.zTree.getZTreeObj("assetTree2");
var root = zTree2.getNodes()[0];
zTree2.expandNode(root);
});
} }
......
...@@ -8,7 +8,7 @@ msgid "" ...@@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Jumpserver 0.3.3\n" "Project-Id-Version: Jumpserver 0.3.3\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-12-17 17:51+0800\n" "POT-Creation-Date: 2018-12-17 20:06+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: ibuler <ibuler@qq.com>\n" "Last-Translator: ibuler <ibuler@qq.com>\n"
"Language-Team: Jumpserver team<ibuler@qq.com>\n" "Language-Team: Jumpserver team<ibuler@qq.com>\n"
...@@ -480,7 +480,7 @@ msgid "Default" ...@@ -480,7 +480,7 @@ msgid "Default"
msgstr "默认" msgstr "默认"
#: assets/models/cluster.py:36 assets/models/label.py:14 #: assets/models/cluster.py:36 assets/models/label.py:14
#: users/models/user.py:420 #: users/models/user.py:432
msgid "System" msgid "System"
msgstr "系统" msgstr "系统"
...@@ -617,7 +617,7 @@ msgstr "默认资产组" ...@@ -617,7 +617,7 @@ msgstr "默认资产组"
#: terminal/templates/terminal/command_list.html:72 #: terminal/templates/terminal/command_list.html:72
#: terminal/templates/terminal/session_list.html:33 #: terminal/templates/terminal/session_list.html:33
#: terminal/templates/terminal/session_list.html:71 users/forms.py:314 #: terminal/templates/terminal/session_list.html:71 users/forms.py:314
#: users/models/user.py:33 users/models/user.py:408 #: users/models/user.py:33 users/models/user.py:420
#: users/templates/users/user_group_detail.html:78 #: users/templates/users/user_group_detail.html:78
#: users/templates/users/user_group_list.html:13 users/views/user.py:386 #: users/templates/users/user_group_list.html:13 users/views/user.py:386
#: xpack/plugins/orgs/forms.py:26 #: xpack/plugins/orgs/forms.py:26
...@@ -1021,7 +1021,7 @@ msgstr "测试" ...@@ -1021,7 +1021,7 @@ msgstr "测试"
#: users/templates/users/user_detail.html:25 #: users/templates/users/user_detail.html:25
#: users/templates/users/user_group_detail.html:28 #: users/templates/users/user_group_detail.html:28
#: users/templates/users/user_group_list.html:43 #: users/templates/users/user_group_list.html:43
#: users/templates/users/user_list.html:77 #: users/templates/users/user_list.html:80
#: users/templates/users/user_profile.html:155 #: users/templates/users/user_profile.html:155
#: users/templates/users/user_profile.html:185 #: users/templates/users/user_profile.html:185
#: users/templates/users/user_profile.html:194 #: users/templates/users/user_profile.html:194
...@@ -1055,8 +1055,8 @@ msgstr "更新" ...@@ -1055,8 +1055,8 @@ msgstr "更新"
#: users/templates/users/user_detail.html:30 #: users/templates/users/user_detail.html:30
#: users/templates/users/user_group_detail.html:32 #: users/templates/users/user_group_detail.html:32
#: users/templates/users/user_group_list.html:45 #: users/templates/users/user_group_list.html:45
#: users/templates/users/user_list.html:81 #: users/templates/users/user_list.html:84
#: users/templates/users/user_list.html:85 #: users/templates/users/user_list.html:88
#: xpack/plugins/cloud/templates/cloud/account_detail.html:29 #: xpack/plugins/cloud/templates/cloud/account_detail.html:29
#: xpack/plugins/cloud/templates/cloud/account_list.html:40 #: xpack/plugins/cloud/templates/cloud/account_list.html:40
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:32 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:32
...@@ -1090,7 +1090,7 @@ msgstr "选择节点" ...@@ -1090,7 +1090,7 @@ msgstr "选择节点"
#: users/templates/users/user_detail.html:480 #: users/templates/users/user_detail.html:480
#: users/templates/users/user_group_create_update.html:32 #: users/templates/users/user_group_create_update.html:32
#: users/templates/users/user_group_list.html:88 #: users/templates/users/user_group_list.html:88
#: users/templates/users/user_list.html:205 #: users/templates/users/user_list.html:208
#: users/templates/users/user_profile.html:236 #: users/templates/users/user_profile.html:236
#: xpack/plugins/cloud/templates/cloud/account_create_update.html:34 #: xpack/plugins/cloud/templates/cloud/account_create_update.html:34
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_create.html:36 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_create.html:36
...@@ -1175,7 +1175,6 @@ msgstr "快速修改" ...@@ -1175,7 +1175,6 @@ msgstr "快速修改"
#: users/templates/users/user_detail.html:144 #: users/templates/users/user_detail.html:144
#: users/templates/users/user_granted_asset.html:46 #: users/templates/users/user_granted_asset.html:46
#: users/templates/users/user_group_granted_asset.html:46 #: users/templates/users/user_group_granted_asset.html:46
#: users/templates/users/user_list.html:28
#: users/templates/users/user_profile.html:63 #: users/templates/users/user_profile.html:63
msgid "Active" msgid "Active"
msgstr "激活中" msgstr "激活中"
...@@ -1308,7 +1307,7 @@ msgstr "重命名失败,不能更改root节点的名称" ...@@ -1308,7 +1307,7 @@ msgstr "重命名失败,不能更改root节点的名称"
#: users/templates/users/user_detail.html:406 #: users/templates/users/user_detail.html:406
#: users/templates/users/user_detail.html:474 #: users/templates/users/user_detail.html:474
#: users/templates/users/user_group_list.html:82 #: users/templates/users/user_group_list.html:82
#: users/templates/users/user_list.html:199 #: users/templates/users/user_list.html:202
msgid "Are you sure?" msgid "Are you sure?"
msgstr "你确认吗?" msgstr "你确认吗?"
...@@ -1324,7 +1323,7 @@ msgstr "删除选择资产" ...@@ -1324,7 +1323,7 @@ msgstr "删除选择资产"
#: users/templates/users/user_detail.html:478 #: users/templates/users/user_detail.html:478
#: users/templates/users/user_group_create_update.html:31 #: users/templates/users/user_group_create_update.html:31
#: users/templates/users/user_group_list.html:86 #: users/templates/users/user_group_list.html:86
#: users/templates/users/user_list.html:203 #: users/templates/users/user_list.html:206
#: xpack/plugins/orgs/templates/orgs/org_create_update.html:32 #: xpack/plugins/orgs/templates/orgs/org_create_update.html:32
msgid "Cancel" msgid "Cancel"
msgstr "取消" msgstr "取消"
...@@ -3330,7 +3329,7 @@ msgstr "添加到用户组" ...@@ -3330,7 +3329,7 @@ msgstr "添加到用户组"
msgid "Public key should not be the same as your old one." msgid "Public key should not be the same as your old one."
msgstr "不能和原来的密钥相同" msgstr "不能和原来的密钥相同"
#: users/forms.py:114 users/forms.py:249 users/serializers/v1.py:51 #: users/forms.py:114 users/forms.py:249 users/serializers/v1.py:38
msgid "Not a valid ssh public key" msgid "Not a valid ssh public key"
msgstr "ssh密钥不合法" msgstr "ssh密钥不合法"
...@@ -3457,7 +3456,7 @@ msgstr "Agent" ...@@ -3457,7 +3456,7 @@ msgstr "Agent"
msgid "Date login" msgid "Date login"
msgstr "登录日期" msgstr "登录日期"
#: users/models/user.py:32 users/models/user.py:416 #: users/models/user.py:32 users/models/user.py:428
msgid "Administrator" msgid "Administrator"
msgstr "管理员" msgstr "管理员"
...@@ -3503,7 +3502,7 @@ msgstr "用户来源" ...@@ -3503,7 +3502,7 @@ msgstr "用户来源"
msgid "Date password last updated" msgid "Date password last updated"
msgstr "最后更新密码日期" msgstr "最后更新密码日期"
#: users/models/user.py:419 #: users/models/user.py:431
msgid "Administrator is the super user of system" msgid "Administrator is the super user of system"
msgstr "Administrator是初始的超级管理员" msgstr "Administrator是初始的超级管理员"
...@@ -3924,23 +3923,37 @@ msgstr "用户组删除" ...@@ -3924,23 +3923,37 @@ msgstr "用户组删除"
msgid "UserGroup Deleting failed." msgid "UserGroup Deleting failed."
msgstr "用户组删除失败" msgstr "用户组删除失败"
#: users/templates/users/user_list.html:200 #: users/templates/users/user_list.html:28 xpack/plugins/cloud/models.py:52
#: xpack/plugins/cloud/templates/cloud/account_detail.html:60
#: xpack/plugins/cloud/templates/cloud/account_list.html:14
msgid "Validity"
msgstr "账户状态"
#: users/templates/users/user_list.html:203
msgid "This will delete the selected users !!!" msgid "This will delete the selected users !!!"
msgstr "删除选中用户 !!!" msgstr "删除选中用户 !!!"
#: users/templates/users/user_list.html:209 #: users/templates/users/user_list.html:212
msgid "User Deleted." msgid "User Deleted."
msgstr "已被删除" msgstr "已被删除"
#: users/templates/users/user_list.html:210 #: users/templates/users/user_list.html:213
#: users/templates/users/user_list.html:215 #: users/templates/users/user_list.html:218
msgid "User Delete" msgid "User Delete"
msgstr "删除" msgstr "删除"
#: users/templates/users/user_list.html:214 #: users/templates/users/user_list.html:217
msgid "User Deleting failed." msgid "User Deleting failed."
msgstr "用户删除失败" msgstr "用户删除失败"
#: users/templates/users/user_list.html:253
msgid "User is expired"
msgstr "用户已失效"
#: users/templates/users/user_list.html:256
msgid "User is inactive"
msgstr "用户已禁用"
#: users/templates/users/user_otp_authentication.html:6 #: users/templates/users/user_otp_authentication.html:6
#: users/templates/users/user_password_authentication.html:6 #: users/templates/users/user_password_authentication.html:6
msgid "Authenticate" msgid "Authenticate"
...@@ -4407,12 +4420,6 @@ msgstr "" ...@@ -4407,12 +4420,6 @@ msgstr ""
msgid "Access key secret" msgid "Access key secret"
msgstr "" msgstr ""
#: xpack/plugins/cloud/models.py:52
#: xpack/plugins/cloud/templates/cloud/account_detail.html:60
#: xpack/plugins/cloud/templates/cloud/account_list.html:14
msgid "Validity"
msgstr "账户状态"
#: xpack/plugins/cloud/models.py:120 #: xpack/plugins/cloud/models.py:120
msgid "Regions" msgid "Regions"
msgstr "地域" msgstr "地域"
...@@ -4606,6 +4613,11 @@ msgstr "创建组织" ...@@ -4606,6 +4613,11 @@ msgstr "创建组织"
msgid "Update org" msgid "Update org"
msgstr "更新组织" msgstr "更新组织"
#, fuzzy
#~| msgid "Validity"
#~ msgid "Valid"
#~ msgstr "账户状态"
#~ msgid "You can't update the root node name" #~ msgid "You can't update the root node name"
#~ msgstr "不能修改根节点名称" #~ msgstr "不能修改根节点名称"
......
...@@ -6,7 +6,7 @@ from rest_framework_bulk import BulkModelViewSet ...@@ -6,7 +6,7 @@ from rest_framework_bulk import BulkModelViewSet
from rest_framework.pagination import LimitOffsetPagination from rest_framework.pagination import LimitOffsetPagination
from ..serializers import UserGroupSerializer, \ from ..serializers import UserGroupSerializer, \
UserGroupUpdateMemeberSerializer UserGroupUpdateMemberSerializer
from ..models import UserGroup from ..models import UserGroup
from common.permissions import IsOrgAdmin from common.permissions import IsOrgAdmin
from common.mixins import IDInFilterMixin from common.mixins import IDInFilterMixin
...@@ -26,5 +26,5 @@ class UserGroupViewSet(IDInFilterMixin, BulkModelViewSet): ...@@ -26,5 +26,5 @@ class UserGroupViewSet(IDInFilterMixin, BulkModelViewSet):
class UserGroupUpdateUserApi(generics.RetrieveUpdateAPIView): class UserGroupUpdateUserApi(generics.RetrieveUpdateAPIView):
queryset = UserGroup.objects.all() queryset = UserGroup.objects.all()
serializer_class = UserGroupUpdateMemeberSerializer serializer_class = UserGroupUpdateMemberSerializer
permission_classes = (IsOrgAdmin,) permission_classes = (IsOrgAdmin,)
...@@ -142,6 +142,18 @@ class User(AbstractUser): ...@@ -142,6 +142,18 @@ class User(AbstractUser):
return True return True
return False return False
@property
def groups_display(self):
return ' '.join(self.groups.all().values_list('name', flat=True))
@property
def role_display(self):
return self.get_role_display()
@property
def source_display(self):
return self.get_source_display()
@property @property
def is_expired(self): def is_expired(self):
if self.date_expired and self.date_expired < timezone.now(): if self.date_expired and self.date_expired < timezone.now():
......
...@@ -13,31 +13,18 @@ signer = get_signer() ...@@ -13,31 +13,18 @@ signer = get_signer()
class UserSerializer(BulkSerializerMixin, serializers.ModelSerializer): class UserSerializer(BulkSerializerMixin, serializers.ModelSerializer):
groups_display = serializers.SerializerMethodField()
groups = serializers.PrimaryKeyRelatedField(
many=True, queryset=UserGroup.objects.all(), required=False
)
class Meta: class Meta:
model = User model = User
list_serializer_class = BulkListSerializer list_serializer_class = BulkListSerializer
exclude = [ fields = [
'first_name', 'last_name', 'password', '_private_key', 'id', 'name', 'username', 'email', 'groups', 'groups_display',
'_public_key', '_otp_secret_key', 'user_permissions' 'role', 'role_display', 'avatar_url', 'wechat', 'phone',
'otp_level', 'comment', 'source', 'source_display',
'is_valid', 'is_expired', 'is_active',
'created_by', 'is_first_login',
'date_password_last_updated', 'date_expired',
] ]
# validators = []
def get_field_names(self, declared_fields, info):
fields = super(UserSerializer, self).get_field_names(declared_fields, info)
fields.extend([
'groups_display', 'get_role_display',
'get_source_display', 'is_valid'
])
return fields
@staticmethod
def get_groups_display(obj):
return " ".join([group.name for group in obj.groups.all()])
class UserPKUpdateSerializer(serializers.ModelSerializer): class UserPKUpdateSerializer(serializers.ModelSerializer):
...@@ -74,7 +61,7 @@ class UserGroupSerializer(BulkSerializerMixin, serializers.ModelSerializer): ...@@ -74,7 +61,7 @@ class UserGroupSerializer(BulkSerializerMixin, serializers.ModelSerializer):
return [user.name for user in obj.users.all()] return [user.name for user in obj.users.all()]
class UserGroupUpdateMemeberSerializer(serializers.ModelSerializer): class UserGroupUpdateMemberSerializer(serializers.ModelSerializer):
users = serializers.PrimaryKeyRelatedField(many=True, queryset=User.objects.all()) users = serializers.PrimaryKeyRelatedField(many=True, queryset=User.objects.all())
class Meta: class Meta:
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<th class="text-center">{% trans 'Role' %}</th> <th class="text-center">{% trans 'Role' %}</th>
<th class="text-center">{% trans 'User group' %}</th> <th class="text-center">{% trans 'User group' %}</th>
<th class="text-center">{% trans 'Source' %}</th> <th class="text-center">{% trans 'Source' %}</th>
<th class="text-center">{% trans 'Active' %}</th> <th class="text-center">{% trans 'Validity' %}</th>
<th class="text-center">{% trans 'Action' %}</th> <th class="text-center">{% trans 'Action' %}</th>
</tr> </tr>
</thead> </thead>
...@@ -66,11 +66,14 @@ function initTable() { ...@@ -66,11 +66,14 @@ function initTable() {
var innerHtml = cellData.length > 20 ? cellData.substring(0, 20) + '...': cellData; var innerHtml = cellData.length > 20 ? cellData.substring(0, 20) + '...': cellData;
$(td).html('<span href="javascript:void(0);" data-toggle="tooltip" title="' + cellData + '">' + innerHtml + '</span>'); $(td).html('<span href="javascript:void(0);" data-toggle="tooltip" title="' + cellData + '">' + innerHtml + '</span>');
}}, }},
{targets: 6, createdCell: function (td, cellData) { {targets: 6, createdCell: function (td, cellData, rowData) {
if (!cellData) { if (cellData) {
$(td).html('<i class="fa fa-times text-danger"></i>')
} else {
$(td).html('<i class="fa fa-check text-navy"></i>') $(td).html('<i class="fa fa-check text-navy"></i>')
} else if (!rowData.is_active) {
$(td).html('<i class="fa fa-times text-danger inactive"></i>')
} else if (rowData.is_expired) {
$(td).html('<i class="fa fa-times text-danger expired"></i>')
} }
}}, }},
{targets: 7, createdCell: function (td, cellData, rowData) { {targets: 7, createdCell: function (td, cellData, rowData) {
...@@ -91,9 +94,9 @@ function initTable() { ...@@ -91,9 +94,9 @@ function initTable() {
ajax_url: '{% url "api-users:user-list" %}', ajax_url: '{% url "api-users:user-list" %}',
columns: [ columns: [
{data: "id"}, {data: "name" }, {data: "username" }, {data: "id"}, {data: "name" }, {data: "username" },
{data: "get_role_display", orderable: false}, {data: "role_display", orderable: false},
{data: "groups_display", orderable: false}, {data: "groups_display", orderable: false},
{data: "get_source_display", orderable: false}, {data: "source_display", orderable: false},
{data: "is_valid", orderable: false}, {data: "is_valid", orderable: false},
{data: "id", orderable: false} {data: "id", orderable: false}
], ],
...@@ -246,6 +249,13 @@ $(document).ready(function(){ ...@@ -246,6 +249,13 @@ $(document).ready(function(){
var uid = $this.data('uid'); var uid = $this.data('uid');
var the_url = '{% url "api-users:user-detail" pk=DEFAULT_PK %}'.replace("{{ DEFAULT_PK }}", uid); var the_url = '{% url "api-users:user-detail" pk=DEFAULT_PK %}'.replace("{{ DEFAULT_PK }}", uid);
objectDelete($this, name, the_url); objectDelete($this, name, the_url);
}).on('click', '.expired', function () {
var msg = '{% trans "User is expired" %}';
toastr.error(msg)
}).on('click', '.inactive', function () {
var msg = '{% trans 'User is inactive' %}';
toastr.error(msg)
}) })
</script> </script>
{% endblock %} {% endblock %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment