Commit ef717f88 authored by ibuler's avatar ibuler

Merge branch 'dev' into bugfix

parents 3e73dbdb 90890591
......@@ -28,7 +28,7 @@ class RemoteAppListView(PermissionsMixin, TemplateView):
def get_context_data(self, **kwargs):
context = {
'app': _('Assets'),
'app': _('Applications'),
'action': _('RemoteApp list'),
}
kwargs.update(context)
......@@ -44,7 +44,7 @@ class RemoteAppCreateView(PermissionsMixin, SuccessMessageMixin, CreateView):
def get_context_data(self, **kwargs):
context = {
'app': _('Assets'),
'app': _('Applications'),
'action': _('Create RemoteApp'),
}
kwargs.update(context)
......@@ -66,7 +66,7 @@ class RemoteAppUpdateView(PermissionsMixin, SuccessMessageMixin, UpdateView):
def get_context_data(self, **kwargs):
context = {
'app': _('Assets'),
'app': _('Applications'),
'action': _('Update RemoteApp'),
}
kwargs.update(context)
......@@ -84,7 +84,7 @@ class RemoteAppDetailView(PermissionsMixin, DetailView):
def get_context_data(self, **kwargs):
context = {
'app': _('Assets'),
'app': _('Applications'),
'action': _('RemoteApp detail'),
}
kwargs.update(context)
......
# -*- coding: utf-8 -*-
#
from ..base import BaseBackend
from .base import BaseBackend
class VaultBackend(BaseBackend):
@classmethod
def get(cls, username, asset):
pass
@classmethod
def filter(cls, username=None, asset=None, latest=True):
pass
@classmethod
def create(cls, **kwargs):
pass
......@@ -229,6 +229,8 @@ class Asset(OrgModelMixin):
@property
def connectivity(self):
if not self.admin_user:
return self.UNKNOWN
return self.admin_user.get_connectivity_of(self)
@connectivity.setter
......
......@@ -27,8 +27,6 @@ class ProtocolsRelatedField(serializers.RelatedField):
return str(value)
def to_internal_value(self, data):
print(data)
print(type(data))
if isinstance(data, dict):
return data
if '/' not in data:
......@@ -152,7 +150,9 @@ class AssetGrantedSerializer(serializers.ModelSerializer):
"""
被授权资产的数据结构
"""
protocols = ProtocolSerializer(many=True)
protocols = ProtocolsRelatedField(
many=True, queryset=Protocol.objects.all(), label=_("Protocols")
)
system_users_granted = AssetSystemUserSerializer(many=True, read_only=True)
system_users_join = serializers.SerializerMethodField()
# nodes = NodeTMPSerializer(many=True, read_only=True)
......@@ -160,9 +160,9 @@ class AssetGrantedSerializer(serializers.ModelSerializer):
class Meta:
model = Asset
fields = (
"id", "hostname", "ip", "protocols", "system_users_granted",
"is_active", "system_users_join", "os", 'domain',
"platform", "comment", "org_id", "org_name",
"id", "hostname", "ip", "protocol", "port", "protocols",
"system_users_granted", "is_active", "system_users_join", "os",
'domain', "platform", "comment", "org_id", "org_name",
)
@staticmethod
......@@ -187,8 +187,7 @@ class AssetGrantedSerializer(serializers.ModelSerializer):
class AssetSimpleSerializer(serializers.ModelSerializer):
protocols = ProtocolSerializer(many=True)
class Meta:
model = Asset
fields = ['id', 'hostname', 'ip', 'protocols', 'connectivity', 'port']
fields = ['id', 'hostname', 'ip', 'connectivity', 'port']
......@@ -209,9 +209,13 @@ def test_asset_connectivity_util(assets, task_name=None):
)
result = task.run()
summary = result[1]
results_summary['success'] &= summary['success']
results_summary['contacted'].update(summary['contacted'])
results_summary['dark'].update(summary['dark'])
success = summary.get('success', False)
contacted = summary.get('contacted', {})
dark = summary.get('dark', {})
results_summary['success'] &= success
results_summary['contacted'].update(contacted)
results_summary['dark'].update(dark)
for asset in assets:
if asset.hostname in results_summary.get('dark', {}):
......@@ -330,14 +334,17 @@ def test_system_user_connectivity_util(system_user, assets, task_name):
task, created = update_or_create_ansible_task(
task_name=task_name, hosts=value['hosts'], tasks=value['tasks'],
pattern='all', options=const.TASK_OPTIONS,
run_as=system_user.username,
created_by=system_user.org_id,
run_as=system_user.username, created_by=system_user.org_id,
)
result = task.run()
summary = result[1]
results_summary['success'] &= summary['success']
results_summary['contacted'].update(summary['contacted'])
results_summary['dark'].update(summary['dark'])
success = summary.get('success', False)
contacted = summary.get('contacted', {})
dark = summary.get('dark', {})
results_summary['success'] &= success
results_summary['contacted'].update(contacted)
results_summary['dark'].update(dark)
set_system_user_connectivity_info(system_user, results_summary)
return results_summary
......
......@@ -248,7 +248,7 @@ class CommandExecutionListView(UserCommandExecutionListView):
'keyword': self.keyword,
'user_id': self.user_id,
})
return super().get_context_data(**context)
return context
@method_decorator(csrf_exempt, name='dispatch')
......
......@@ -224,7 +224,7 @@ class ApiMessageMixin:
def dispatch(self, request, *args, **kwargs):
resp = super().dispatch(request, *args, **kwargs)
if request.method.lower() in ("get", "delete"):
if request.method.lower() in ("get", "delete", "patch"):
return resp
if resp.status_code >= 400:
return resp
......
This diff is collapsed.
......@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-27 15:53+0800\n"
"POT-Creation-Date: 2019-06-20 16:30+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -17,58 +17,58 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: static/js/jumpserver.js:249
#: static/js/jumpserver.js:263
msgid "Update is successful!"
msgstr "更新成功"
#: static/js/jumpserver.js:251
#: static/js/jumpserver.js:265
msgid "An unknown error occurred while updating.."
msgstr "更新时发生未知错误"
#: static/js/jumpserver.js:315 static/js/jumpserver.js:352
#: static/js/jumpserver.js:355
#: static/js/jumpserver.js:329 static/js/jumpserver.js:366
#: static/js/jumpserver.js:369
msgid "Error"
msgstr "错误"
#: static/js/jumpserver.js:315
#: static/js/jumpserver.js:329
msgid "Being used by the asset, please unbind the asset first."
msgstr "正在被资产使用中,请先解除资产绑定"
#: static/js/jumpserver.js:321 static/js/jumpserver.js:362
#: static/js/jumpserver.js:335 static/js/jumpserver.js:376
msgid "Delete the success"
msgstr "删除成功"
#: static/js/jumpserver.js:327
#: static/js/jumpserver.js:341
msgid "Are you sure about deleting it?"
msgstr "你确定删除吗 ?"
#: static/js/jumpserver.js:331 static/js/jumpserver.js:372
#: static/js/jumpserver.js:345 static/js/jumpserver.js:386
msgid "Cancel"
msgstr "取消"
#: static/js/jumpserver.js:333 static/js/jumpserver.js:374
#: static/js/jumpserver.js:347 static/js/jumpserver.js:388
msgid "Confirm"
msgstr "确认"
#: static/js/jumpserver.js:352
#: static/js/jumpserver.js:366
msgid ""
"The organization contains undeleted information. Please try again after "
"deleting"
msgstr "组织中包含未删除信息,请删除后重试"
#: static/js/jumpserver.js:355
#: static/js/jumpserver.js:369
msgid ""
"Do not perform this operation under this organization. Try again after "
"switching to another organization"
msgstr "请勿在此组织下执行此操作,切换到其他组织后重试"
#: static/js/jumpserver.js:368
#: static/js/jumpserver.js:382
msgid ""
"Please ensure that the following information in the organization has been "
"deleted"
msgstr "请确保组织内的以下信息已删除"
#: static/js/jumpserver.js:369
#: static/js/jumpserver.js:383
msgid ""
"User list、User group、Asset list、Domain list、Admin user、System user、"
"Labels、Asset permission"
......@@ -76,76 +76,80 @@ msgstr ""
"用户列表、用户组、资产列表、网域列表、管理用户、系统用户、标签管理、资产授权"
"规则"
#: static/js/jumpserver.js:408
#: static/js/jumpserver.js:422
msgid "Loading ..."
msgstr "加载中 ..."
#: static/js/jumpserver.js:409
#: static/js/jumpserver.js:423
msgid "Search"
msgstr "搜索"
#: static/js/jumpserver.js:412
#: static/js/jumpserver.js:426
#, javascript-format
msgid "Selected item %d"
msgstr "选中 %d 项"
#: static/js/jumpserver.js:416
#: static/js/jumpserver.js:430
msgid "Per page _MENU_"
msgstr "每页 _MENU_"
#: static/js/jumpserver.js:417
#: static/js/jumpserver.js:431
msgid ""
"Displays the results of items _START_ to _END_; A total of _TOTAL_ entries"
msgstr "显示第 _START_ 至 _END_ 项结果; 总共 _TOTAL_ 项"
#: static/js/jumpserver.js:420
#: static/js/jumpserver.js:434
msgid "No match"
msgstr "没有匹配项"
#: static/js/jumpserver.js:421
#: static/js/jumpserver.js:435
msgid "No record"
msgstr "没有记录"
#: static/js/jumpserver.js:563
#: static/js/jumpserver.js:577
msgid "Unknown error occur"
msgstr ""
#: static/js/jumpserver.js:800
#: static/js/jumpserver.js:816
msgid "Password minimum length {N} bits"
msgstr "密码最小长度 {N} 位"
#: static/js/jumpserver.js:801
#: static/js/jumpserver.js:817
msgid "Must contain capital letters"
msgstr "必须包含大写字母"
#: static/js/jumpserver.js:802
#: static/js/jumpserver.js:818
msgid "Must contain lowercase letters"
msgstr "必须包含小写字母"
#: static/js/jumpserver.js:803
#: static/js/jumpserver.js:819
msgid "Must contain numeric characters"
msgstr "必须包含数字字符"
#: static/js/jumpserver.js:804
#: static/js/jumpserver.js:820
msgid "Must contain special characters"
msgstr "必须包含特殊字符"
#: static/js/jumpserver.js:976
#: static/js/jumpserver.js:995
msgid "Export failed"
msgstr "导出失败"
#: static/js/jumpserver.js:993
#: static/js/jumpserver.js:1012
msgid "Import Success"
msgstr "导入成功"
#: static/js/jumpserver.js:998
#: static/js/jumpserver.js:1017
msgid "Update Success"
msgstr "更新成功"
#: static/js/jumpserver.js:1028
#: static/js/jumpserver.js:1018
msgid "Count"
msgstr "数量"
#: static/js/jumpserver.js:1047
msgid "Import failed"
msgstr "导入失败"
#: static/js/jumpserver.js:1033
#: static/js/jumpserver.js:1052
msgid "Update failed"
msgstr "更新失败"
# ~*~ coding: utf-8 ~*~
#
from orgs.utils import set_to_root_org
__all__ = [
......@@ -116,4 +115,3 @@ class ChangeOrgIfNeedMixin(object):
def get(self, request, *args, **kwargs):
self.change_org_if_need(request, kwargs)
return super().get(request, *args, **kwargs)
......@@ -39,7 +39,7 @@ class MailTestingAPI(APIView):
subject = "Test"
message = "Test smtp setting"
email_from = email_from or email_host_user
send_mail(subject, message, email_from, [email_host_user])
send_mail(subject, message, email_from, [email_from])
except Exception as e:
return Response({"error": str(e)}, status=401)
......
......@@ -1015,7 +1015,7 @@ function APIImportData(props){
$('#updated_failed').html('');
$('#updated_failed_detail').html('');
$('#success_updated').html(gettext("Update Success"));
$('#success_updated_detail').html("Count" + ": " + data.length);
$('#success_updated_detail').html(gettext("Count") + ": " + data.length);
}
props.data_table.ajax.reload()
......
......@@ -4,6 +4,8 @@
<i class="fa fa-files-o" style="width: 14px"></i><span class="nav-label">{% trans 'My assets' %}</span><span class="label label-info pull-right"></span>
</a>
</li>
{% if LICENSE_VALID %}
<li id="applications">
<a>
<i class="fa fa-th" style="width: 14px"></i> <span class="nav-label">{% trans 'My Applications' %}</span><span class="fa arrow"></span>
......@@ -16,6 +18,8 @@
</li>
</ul>
</li>
{% endif %}
{% if SECURITY_COMMAND_EXECUTION %}
<li id="ops">
<a href="{% url 'ops:command-execution-start' %}">
......
......@@ -48,7 +48,7 @@ class CommandListView(DatetimeSearchMixin, PermissionsMixin, ListView):
def get_context_data(self, **kwargs):
context = {
'app': _('Terminal'),
'app': _('Sessions'),
'action': _('Command list'),
'user_list': utils.get_session_user_list(),
'asset_list': utils.get_session_asset_list(),
......
......@@ -71,7 +71,7 @@ class SessionOnlineListView(SessionListView):
def get_context_data(self, **kwargs):
context = {
'app': _('Terminal'),
'app': _('Sessions'),
'action': _('Session online list'),
'type': 'online',
'now': timezone.now(),
......@@ -89,8 +89,8 @@ class SessionOfflineListView(SessionListView):
def get_context_data(self, **kwargs):
context = {
'app': _('Terminal'),
'action': _('Session offline list'),
'app': _('Sessions'),
'action': _('Session offline'),
'now': timezone.now(),
}
kwargs.update(context)
......@@ -113,7 +113,7 @@ class SessionDetailView(SingleObjectMixin, PermissionsMixin, ListView):
def get_context_data(self, **kwargs):
context = {
'app': _('Terminal'),
'app': _('Sessions'),
'action': _('Session detail'),
}
kwargs.update(context)
......
......@@ -28,7 +28,7 @@ class TerminalListView(PermissionsMixin, ListView):
def get_context_data(self, **kwargs):
context = super(TerminalListView, self).get_context_data(**kwargs)
context.update({
'app': _('Terminal'),
'app': _('Sessions'),
'action': _('Terminal list'),
'form': self.form_class()
})
......@@ -44,7 +44,7 @@ class TerminalUpdateView(PermissionsMixin, UpdateView):
def get_context_data(self, **kwargs):
context = super(TerminalUpdateView, self).get_context_data(**kwargs)
context.update({'app': _('Terminal'), 'action': _('Update terminal')})
context.update({'app': _('Sessions'), 'action': _('Update terminal')})
return context
......@@ -57,7 +57,7 @@ class TerminalDetailView(PermissionsMixin, DetailView):
def get_context_data(self, **kwargs):
context = super(TerminalDetailView, self).get_context_data(**kwargs)
context.update({
'app': _('Terminal'),
'app': _('Sessions'),
'action': _('Terminal detail')
})
return context
......
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