jumpserver/apps/terminal/views/command.py

29 lines
808 B
Python
Raw Normal View History

2017-12-04 08:41:00 +00:00
# -*- coding: utf-8 -*-
#
2019-07-03 14:28:20 +00:00
from django.views.generic import TemplateView
2017-12-04 08:41:00 +00:00
from django.utils.translation import ugettext as _
2019-07-03 08:29:39 +00:00
from django.utils import timezone
2017-12-04 08:41:00 +00:00
from common.permissions import PermissionsMixin, IsOrgAdmin, IsAuditor
2017-12-04 08:41:00 +00:00
2019-07-03 10:03:01 +00:00
__all__ = ['CommandListView']
2017-12-04 08:41:00 +00:00
2019-07-03 14:28:20 +00:00
class CommandListView(PermissionsMixin, TemplateView):
2017-12-04 08:41:00 +00:00
template_name = "terminal/command_list.html"
permission_classes = [IsOrgAdmin | IsAuditor]
2019-07-03 08:29:39 +00:00
default_days_ago = 5
2017-12-04 08:41:00 +00:00
def get_context_data(self, **kwargs):
2019-07-03 08:29:39 +00:00
now = timezone.now()
2017-12-04 08:41:00 +00:00
context = {
'app': _('Sessions'),
2017-12-04 08:41:00 +00:00
'action': _('Command list'),
2019-07-03 08:29:39 +00:00
'date_from': now - timezone.timedelta(days=self.default_days_ago),
'date_to': now,
2017-12-04 08:41:00 +00:00
}
kwargs.update(context)
return super().get_context_data(**kwargs)