From 0916757eb8ec679f2f91e36ce7752a755ab7808f Mon Sep 17 00:00:00 2001 From: ibuler Date: Sun, 31 Dec 2017 21:51:25 +0800 Subject: [PATCH] =?UTF-8?q?[Bugfix]=20=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9B?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/templates/assets/asset_create.html | 9 +++------ apps/assets/templates/assets/asset_list.html | 2 +- apps/common/templatetags/common_tags.py | 16 ++++++++++++++++ apps/perms/forms.py | 3 ++- .../perms/asset_permission_create_update.html | 6 +++--- apps/templates/_user_profile.html | 13 +++++++++---- .../templates/terminal/session_list.html | 3 ++- .../users/templates/users/user_group_detail.html | 6 +++--- 8 files changed, 39 insertions(+), 19 deletions(-) diff --git a/apps/assets/templates/assets/asset_create.html b/apps/assets/templates/assets/asset_create.html index ac0e4d744..f96f1b0fb 100644 --- a/apps/assets/templates/assets/asset_create.html +++ b/apps/assets/templates/assets/asset_create.html @@ -47,12 +47,9 @@ {% block custom_foot_js %} {% endblock %} \ No newline at end of file diff --git a/apps/assets/templates/assets/asset_list.html b/apps/assets/templates/assets/asset_list.html index fc1cc5428..6bab2f5e3 100644 --- a/apps/assets/templates/assets/asset_list.html +++ b/apps/assets/templates/assets/asset_list.html @@ -35,7 +35,7 @@ {% trans 'Env' %} {% trans 'Hardware' %} {% trans 'Active' %} - {% trans 'Connective' %} + {% trans 'Reachable' %} {% trans 'Action' %} diff --git a/apps/common/templatetags/common_tags.py b/apps/common/templatetags/common_tags.py index 2928726f4..9c3e58871 100644 --- a/apps/common/templatetags/common_tags.py +++ b/apps/common/templatetags/common_tags.py @@ -2,6 +2,7 @@ from django import template from django.utils import timezone +from django.utils.translation import gettext as _ from django.utils.html import escape register = template.Library() @@ -67,3 +68,18 @@ def ts_to_date(ts): @register.filter def to_html(s): return escape(s).replace('\n', '
') + + +@register.filter +def time_util_with_seconds(date_from, date_to): + if date_from and date_to: + delta = date_to - date_from + seconds = delta.seconds + if seconds < 60: + return '{} s'.format(seconds) + elif seconds < 60*60: + return '{} m'.format(seconds//60) + else: + return '{} h'.format(seconds//3600) + else: + return '' diff --git a/apps/perms/forms.py b/apps/perms/forms.py index 87c6d2eff..fbb0c8226 100644 --- a/apps/perms/forms.py +++ b/apps/perms/forms.py @@ -14,7 +14,8 @@ class AssetPermissionForm(forms.ModelForm): queryset=User.objects.exclude(role=User.ROLE_APP), widget=forms.SelectMultiple( attrs={'class': 'select2', 'data-placeholder': _('Select users')}, - ) + ), + label=_("User") ) class Meta: diff --git a/apps/perms/templates/perms/asset_permission_create_update.html b/apps/perms/templates/perms/asset_permission_create_update.html index 86a11ba62..85883a77b 100644 --- a/apps/perms/templates/perms/asset_permission_create_update.html +++ b/apps/perms/templates/perms/asset_permission_create_update.html @@ -3,9 +3,9 @@ {% load static %} {% load bootstrap3 %} {% block custom_head_css_js %} - - - + + + {% endblock %} {% block content %} diff --git a/apps/templates/_user_profile.html b/apps/templates/_user_profile.html index bdecc00d6..a8572dfc9 100644 --- a/apps/templates/_user_profile.html +++ b/apps/templates/_user_profile.html @@ -37,11 +37,16 @@ $(document).ready(function () { }) .on('click', '#switch_admin', function () { - setCookie("IN_ADMIN_PAGE", "Yes"); - window.location = "/" + setTimeout(function () { + setCookie("IN_ADMIN_PAGE", "Yes"); + window.location = "/" + }, 100) }) .on('click', '#switch_user', function () { - setCookie("IN_ADMIN_PAGE", "No"); - window.location = "/" + setTimeout(function () { + console.log("Set to No"); + setCookie("IN_ADMIN_PAGE", "No"); + window.location = "/" + }, 100); }) diff --git a/apps/terminal/templates/terminal/session_list.html b/apps/terminal/templates/terminal/session_list.html index 1a2a949d9..7c7499af8 100644 --- a/apps/terminal/templates/terminal/session_list.html +++ b/apps/terminal/templates/terminal/session_list.html @@ -2,6 +2,7 @@ {% load i18n %} {% load static %} {% load terminal_tags %} +{% load common_tags %} {% block custom_head_css_js %} @@ -91,7 +92,7 @@ {{ session.id | get_session_command_amount }} {{ session.date_start }} - {{ session.date_end|timeuntil:session.date_start }} + {{ session.date_start|time_util_with_seconds:session.date_end }} {% if session.is_finished %} {% trans "Replay" %} diff --git a/apps/users/templates/users/user_group_detail.html b/apps/users/templates/users/user_group_detail.html index c471b5f21..f13395764 100644 --- a/apps/users/templates/users/user_group_detail.html +++ b/apps/users/templates/users/user_group_detail.html @@ -21,9 +21,9 @@
  • {% trans 'User group detail' %}
  • -
  • - {% trans 'Asset granted' %} -
  • +{#
  • #} +{# {% trans 'Asset granted' %}#} +{#
  • #}
  • Update