Commit 0916757e authored by ibuler's avatar ibuler

[Bugfix] 修复一些bug

parent 0b299344
...@@ -47,12 +47,9 @@ ...@@ -47,12 +47,9 @@
{% block custom_foot_js %} {% block custom_foot_js %}
<script> <script>
$(document).ready(function () { $(document).ready(function () {
$('.select2').select2(); $('.select2').select2({
{# $("#id_tags").select2({#} allowClear: true
{# tags: true,#} });
{# maximumSelectionLength: 8 //最多能够选择的个数#}
{# //closeOnSelect: false#}
{# });#}
}) })
</script> </script>
{% endblock %} {% endblock %}
\ No newline at end of file
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<th class="text-center">{% trans 'Env' %}</th> <th class="text-center">{% trans 'Env' %}</th>
<th class="text-center">{% trans 'Hardware' %}</th> <th class="text-center">{% trans 'Hardware' %}</th>
<th class="text-center">{% trans 'Active' %}</th> <th class="text-center">{% trans 'Active' %}</th>
<th class="text-center">{% trans 'Connective' %}</th> <th class="text-center">{% trans 'Reachable' %}</th>
<th class="text-center">{% trans 'Action' %}</th> <th class="text-center">{% trans 'Action' %}</th>
</tr> </tr>
</thead> </thead>
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
from django import template from django import template
from django.utils import timezone from django.utils import timezone
from django.utils.translation import gettext as _
from django.utils.html import escape from django.utils.html import escape
register = template.Library() register = template.Library()
...@@ -67,3 +68,18 @@ def ts_to_date(ts): ...@@ -67,3 +68,18 @@ def ts_to_date(ts):
@register.filter @register.filter
def to_html(s): def to_html(s):
return escape(s).replace('\n', '<br />') return escape(s).replace('\n', '<br />')
@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 ''
...@@ -14,7 +14,8 @@ class AssetPermissionForm(forms.ModelForm): ...@@ -14,7 +14,8 @@ class AssetPermissionForm(forms.ModelForm):
queryset=User.objects.exclude(role=User.ROLE_APP), queryset=User.objects.exclude(role=User.ROLE_APP),
widget=forms.SelectMultiple( widget=forms.SelectMultiple(
attrs={'class': 'select2', 'data-placeholder': _('Select users')}, attrs={'class': 'select2', 'data-placeholder': _('Select users')},
) ),
label=_("User")
) )
class Meta: class Meta:
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
{% load static %} {% load static %}
{% load bootstrap3 %} {% load bootstrap3 %}
{% block custom_head_css_js %} {% block custom_head_css_js %}
<link href="{% static "css/plugins/select2/select2.min.css" %}" rel="stylesheet"> <link href="{% static 'css/plugins/select2/select2.min.css' %}" rel="stylesheet">
<script src="{% static "js/plugins/select2/select2.full.min.js" %}"></script> <script src="{% static 'js/plugins/select2/select2.full.min.js' %}"></script>
<link href="{% static "css/plugins/datepicker/datepicker3.css" %}" rel="stylesheet"> <link href="{% static 'css/plugins/datepicker/datepicker3.css' %}" rel="stylesheet">
{% endblock %} {% endblock %}
{% block content %} {% block content %}
......
...@@ -37,11 +37,16 @@ ...@@ -37,11 +37,16 @@
$(document).ready(function () { $(document).ready(function () {
}) })
.on('click', '#switch_admin', function () { .on('click', '#switch_admin', function () {
setTimeout(function () {
setCookie("IN_ADMIN_PAGE", "Yes"); setCookie("IN_ADMIN_PAGE", "Yes");
window.location = "/" window.location = "/"
}, 100)
}) })
.on('click', '#switch_user', function () { .on('click', '#switch_user', function () {
setTimeout(function () {
console.log("Set to No");
setCookie("IN_ADMIN_PAGE", "No"); setCookie("IN_ADMIN_PAGE", "No");
window.location = "/" window.location = "/"
}, 100);
}) })
</script> </script>
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
{% load i18n %} {% load i18n %}
{% load static %} {% load static %}
{% load terminal_tags %} {% load terminal_tags %}
{% load common_tags %}
{% block custom_head_css_js %} {% block custom_head_css_js %}
<link href="{% static 'css/plugins/datepicker/datepicker3.css' %}" rel="stylesheet"> <link href="{% static 'css/plugins/datepicker/datepicker3.css' %}" rel="stylesheet">
<link href="{% static "css/plugins/select2/select2.min.css" %}" rel="stylesheet"> <link href="{% static "css/plugins/select2/select2.min.css" %}" rel="stylesheet">
...@@ -91,7 +92,7 @@ ...@@ -91,7 +92,7 @@
<td class="text-center">{{ session.id | get_session_command_amount }}</td> <td class="text-center">{{ session.id | get_session_command_amount }}</td>
<td class="text-center">{{ session.date_start }}</td> <td class="text-center">{{ session.date_start }}</td>
<td class="text-center">{{ session.date_end|timeuntil:session.date_start }}</td> <td class="text-center">{{ session.date_start|time_util_with_seconds:session.date_end }}</td>
<td> <td>
{% if session.is_finished %} {% if session.is_finished %}
<a onclick="window.open('/luna/replay/{{ session.id }}','luna', 'height=600, width=800, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, location=no, status=no')" class="btn btn-xs btn-warning btn-replay" >{% trans "Replay" %}</a> <a onclick="window.open('/luna/replay/{{ session.id }}','luna', 'height=600, width=800, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, location=no, status=no')" class="btn btn-xs btn-warning btn-replay" >{% trans "Replay" %}</a>
......
...@@ -21,9 +21,9 @@ ...@@ -21,9 +21,9 @@
<li class="active"> <li class="active">
<a href="{% url 'users:user-group-detail' pk=user_group.id %}" class="text-center"><i class="fa fa-laptop"></i> {% trans 'User group detail' %} </a> <a href="{% url 'users:user-group-detail' pk=user_group.id %}" class="text-center"><i class="fa fa-laptop"></i> {% trans 'User group detail' %} </a>
</li> </li>
<li> {# <li>#}
<a href="{% url 'users:user-group-granted-asset' pk=user_group.id %}" class="text-center"><i class="fa fa-cubes"></i> {% trans 'Asset granted' %}</a> {# <a href="{% url 'users:user-group-granted-asset' pk=user_group.id %}" class="text-center"><i class="fa fa-cubes"></i> {% trans 'Asset granted' %}</a>#}
</li> {# </li>#}
<li class="pull-right"> <li class="pull-right">
<a class="btn btn-outline btn-default" href="{% url 'users:user-group-update' pk=user_group.id %}"><i class="fa fa-edit"></i>Update</a> <a class="btn btn-outline btn-default" href="{% url 'users:user-group-update' pk=user_group.id %}"><i class="fa fa-edit"></i>Update</a>
</li> </li>
......
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