diff --git a/apps/applications/forms/__init__.py b/apps/applications/forms/__init__.py
deleted file mode 100644
index a707cfde6..000000000
--- a/apps/applications/forms/__init__.py
+++ /dev/null
@@ -1,2 +0,0 @@
-from .remote_app import *
-from .database_app import *
diff --git a/apps/applications/forms/database_app.py b/apps/applications/forms/database_app.py
deleted file mode 100644
index 2b5a4c0cf..000000000
--- a/apps/applications/forms/database_app.py
+++ /dev/null
@@ -1,26 +0,0 @@
-# coding: utf-8
-#
-
-
-from django import forms
-from django.utils.translation import ugettext_lazy as _
-
-from .. import models
-
-__all__ = ['DatabaseAppMySQLForm']
-
-
-class BaseDatabaseAppForm(forms.ModelForm):
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
- self.fields['type'].widget.attrs['disabled'] = True
-
- class Meta:
- model = models.DatabaseApp
- fields = [
- 'name', 'type', 'host', 'port', 'database', 'comment'
- ]
-
-
-class DatabaseAppMySQLForm(BaseDatabaseAppForm):
- pass
diff --git a/apps/applications/forms/remote_app.py b/apps/applications/forms/remote_app.py
deleted file mode 100644
index 7a097fcc8..000000000
--- a/apps/applications/forms/remote_app.py
+++ /dev/null
@@ -1,120 +0,0 @@
-# coding: utf-8
-#
-
-from django.utils.translation import ugettext as _
-from django import forms
-
-from orgs.mixins.forms import OrgModelForm
-
-from ..models import RemoteApp
-
-
-__all__ = [
- 'RemoteAppChromeForm', 'RemoteAppMySQLWorkbenchForm',
- 'RemoteAppVMwareForm', 'RemoteAppCustomForm'
-]
-
-
-class BaseRemoteAppForm(OrgModelForm):
- default_initial_data = {}
-
- def __init__(self, *args, **kwargs):
- # 过滤RDP资产和系统用户
- super().__init__(*args, **kwargs)
- field_asset = self.fields['asset']
- field_asset.queryset = field_asset.queryset.has_protocol('rdp')
- self.fields['type'].widget.attrs['disabled'] = True
- self.fields.move_to_end('comment')
- self.initial_default()
-
- def initial_default(self):
- for name, value in self.default_initial_data.items():
- field = self.fields.get(name)
- if not field:
- continue
- field.initial = value
-
- class Meta:
- model = RemoteApp
- fields = [
- 'name', 'asset', 'type', 'path', 'comment'
- ]
- widgets = {
- 'asset': forms.Select(attrs={
- 'class': 'select2', 'data-placeholder': _('Asset')
- }),
- }
-
-
-class RemoteAppChromeForm(BaseRemoteAppForm):
- default_initial_data = {
- 'path': r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
- }
-
- chrome_target = forms.CharField(
- max_length=128, label=_('Target URL'), required=False
- )
- chrome_username = forms.CharField(
- max_length=128, label=_('Login username'), required=False
- )
- chrome_password = forms.CharField(
- widget=forms.PasswordInput, strip=True,
- max_length=128, label=_('Login password'), required=False
- )
-
-
-class RemoteAppMySQLWorkbenchForm(BaseRemoteAppForm):
- default_initial_data = {
- 'path': r'C:\Program Files\MySQL\MySQL Workbench 8.0 CE'
- r'\MySQLWorkbench.exe'
- }
-
- mysql_workbench_ip = forms.CharField(
- max_length=128, label=_('Database IP'), required=False
- )
- mysql_workbench_name = forms.CharField(
- max_length=128, label=_('Database name'), required=False
- )
- mysql_workbench_username = forms.CharField(
- max_length=128, label=_('Database username'), required=False
- )
- mysql_workbench_password = forms.CharField(
- widget=forms.PasswordInput, strip=True,
- max_length=128, label=_('Database password'), required=False
- )
-
-
-class RemoteAppVMwareForm(BaseRemoteAppForm):
- default_initial_data = {
- 'path': r'C:\Program Files (x86)\VMware\Infrastructure'
- r'\Virtual Infrastructure Client\Launcher\VpxClient.exe'
- }
-
- vmware_target = forms.CharField(
- max_length=128, label=_('Target address'), required=False
- )
- vmware_username = forms.CharField(
- max_length=128, label=_('Login username'), required=False
- )
- vmware_password = forms.CharField(
- widget=forms.PasswordInput, strip=True,
- max_length=128, label=_('Login password'), required=False
- )
-
-
-class RemoteAppCustomForm(BaseRemoteAppForm):
-
- custom_cmdline = forms.CharField(
- max_length=128, label=_('Operating parameter'), required=False
- )
- custom_target = forms.CharField(
- max_length=128, label=_('Target address'), required=False
- )
- custom_username = forms.CharField(
- max_length=128, label=_('Login username'), required=False
- )
- custom_password = forms.CharField(
- widget=forms.PasswordInput, strip=True,
- max_length=128, label=_('Login password'), required=False
- )
-
diff --git a/apps/applications/templates/applications/database_app_create_update.html b/apps/applications/templates/applications/database_app_create_update.html
deleted file mode 100644
index 84635e2d0..000000000
--- a/apps/applications/templates/applications/database_app_create_update.html
+++ /dev/null
@@ -1,55 +0,0 @@
-{% extends '_base_create_update.html' %}
-{% load static %}
-{% load bootstrap3 %}
-{% load i18n %}
-
-{% block form %}
-
-{% endblock %}
-
-{% block custom_foot_js %}
-
-{% endblock %}
\ No newline at end of file
diff --git a/apps/applications/templates/applications/database_app_detail.html b/apps/applications/templates/applications/database_app_detail.html
deleted file mode 100644
index 153bfa98a..000000000
--- a/apps/applications/templates/applications/database_app_detail.html
+++ /dev/null
@@ -1,103 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block content %}
-
-
-
-
-
-
-
-
-
-
{{ database_app.name }}
-
-
-
-
-
-
- {% trans 'Name' %}:
- {{ database_app.name }}
-
-
- {% trans 'Type' %}:
- {{ database_app.get_type_display }}
-
-
- {% trans 'Host' %}:
- {{ database_app.host }}
-
-
- {% trans 'Port' %}:
- {{ database_app.port }}
-
-
- {% trans 'Database' %}:
- {{ database_app.database }}
-
-
- {% trans 'Date created' %}:
- {{ database_app.date_created }}
-
-
- {% trans 'Created by' %}:
- {{ database_app.created_by }}
-
-
- {% trans 'Comment' %}:
- {{ database_app.comment }}
-
-
-
-
-
-
-
-
-
-
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/applications/templates/applications/database_app_list.html b/apps/applications/templates/applications/database_app_list.html
deleted file mode 100644
index 74a5c907e..000000000
--- a/apps/applications/templates/applications/database_app_list.html
+++ /dev/null
@@ -1,88 +0,0 @@
-{% extends '_base_list.html' %}
-{% load i18n static %}
-{% block help_message %}
-{% endblock %}
-{% block table_search %}{% endblock %}
-{% block table_container %}
-
-
- {% trans "Create DatabaseApp" %}
-
-
-
-
-{% endblock %}
-{% block content_bottom_left %}{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/applications/templates/applications/remote_app_create_update.html b/apps/applications/templates/applications/remote_app_create_update.html
deleted file mode 100644
index 440219936..000000000
--- a/apps/applications/templates/applications/remote_app_create_update.html
+++ /dev/null
@@ -1,71 +0,0 @@
-{% extends '_base_create_update.html' %}
-{% load static %}
-{% load bootstrap3 %}
-{% load i18n %}
-
-{% block form %}
-
-{% endblock %}
-
-{% block custom_foot_js %}
-
-{% endblock %}
\ No newline at end of file
diff --git a/apps/applications/templates/applications/remote_app_detail.html b/apps/applications/templates/applications/remote_app_detail.html
deleted file mode 100644
index da7c2e72d..000000000
--- a/apps/applications/templates/applications/remote_app_detail.html
+++ /dev/null
@@ -1,100 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block content %}
-
-
-
-
-
-
-
-
-
-
{{ remote_app.name }}
-
-
-
-
-
-
- {% trans 'Name' %}:
- {{ remote_app.name }}
-
-
- {% trans 'Asset' %}:
- {{ remote_app.asset.hostname }}
-
-
- {% trans 'App type' %}:
- {{ remote_app.get_type_display }}
-
-
- {% trans 'App path' %}:
- {{ remote_app.path }}
-
-
- {% trans 'Date created' %}:
- {{ remote_app.date_created }}
-
-
- {% trans 'Created by' %}:
- {{ remote_app.created_by }}
-
-
- {% trans 'Comment' %}:
- {{ remote_app.comment }}
-
-
-
-
-
-
-
-
-
-
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/applications/templates/applications/remote_app_list.html b/apps/applications/templates/applications/remote_app_list.html
deleted file mode 100644
index 709152489..000000000
--- a/apps/applications/templates/applications/remote_app_list.html
+++ /dev/null
@@ -1,92 +0,0 @@
-{% extends '_base_list.html' %}
-{% load i18n static %}
-{% block help_message %}
- {% trans 'Before using this feature, make sure that the application loader has been uploaded to the application server and successfully published as a RemoteApp application' %}
- {% trans 'Download application loader' %}
-{% endblock %}
-{% block table_search %}{% endblock %}
-{% block table_container %}
-
-
- {% trans "Create RemoteApp" %}
-
-
-
-
-{% endblock %}
-{% block content_bottom_left %}{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/applications/templates/applications/user_database_app_list.html b/apps/applications/templates/applications/user_database_app_list.html
deleted file mode 100644
index 1edaacd76..000000000
--- a/apps/applications/templates/applications/user_database_app_list.html
+++ /dev/null
@@ -1,83 +0,0 @@
-{% extends 'base.html' %}
-{% load i18n static %}
-
-{% block custom_head_css_js %}
-
-{% endblock %}
-
-{% block content %}
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/applications/templates/applications/user_remote_app_list.html b/apps/applications/templates/applications/user_remote_app_list.html
deleted file mode 100644
index 576c7ed14..000000000
--- a/apps/applications/templates/applications/user_remote_app_list.html
+++ /dev/null
@@ -1,73 +0,0 @@
-{% extends 'base.html' %}
-{% load i18n static %}
-
-{% block custom_head_css_js %}
-
-{% endblock %}
-
-{% block content %}
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/applications/urls/views_urls.py b/apps/applications/urls/views_urls.py
index 663b0878d..2b09baf9f 100644
--- a/apps/applications/urls/views_urls.py
+++ b/apps/applications/urls/views_urls.py
@@ -1,23 +1,7 @@
# coding:utf-8
from django.urls import path
-from .. import views
app_name = 'applications'
urlpatterns = [
- # RemoteApp
- path('remote-app/', views.RemoteAppListView.as_view(), name='remote-app-list'),
- path('remote-app/create/', views.RemoteAppCreateView.as_view(), name='remote-app-create'),
- path('remote-app//update/', views.RemoteAppUpdateView.as_view(), name='remote-app-update'),
- path('remote-app//', views.RemoteAppDetailView.as_view(), name='remote-app-detail'),
- # User RemoteApp view
- path('user-remote-app/', views.UserRemoteAppListView.as_view(), name='user-remote-app-list'),
-
- path('database-app/', views.DatabaseAppListView.as_view(), name='database-app-list'),
- path('database-app/create/', views.DatabaseAppCreateView.as_view(), name='database-app-create'),
- path('database-app//update/', views.DatabaseAppUpdateView.as_view(), name='database-app-update'),
- path('database-app//', views.DatabaseAppDetailView.as_view(), name='database-app-detail'),
- # User DatabaseApp view
- path('user-database-app/', views.UserDatabaseAppListView.as_view(), name='user-database-app-list'),
-
]
diff --git a/apps/applications/views/__init__.py b/apps/applications/views/__init__.py
deleted file mode 100644
index a707cfde6..000000000
--- a/apps/applications/views/__init__.py
+++ /dev/null
@@ -1,2 +0,0 @@
-from .remote_app import *
-from .database_app import *
diff --git a/apps/applications/views/database_app.py b/apps/applications/views/database_app.py
deleted file mode 100644
index 21d2b4f7c..000000000
--- a/apps/applications/views/database_app.py
+++ /dev/null
@@ -1,115 +0,0 @@
-# coding: utf-8
-#
-
-from django.http import Http404
-from django.views.generic import TemplateView
-from django.views.generic.edit import CreateView, UpdateView
-from django.utils.translation import ugettext_lazy as _
-from django.views.generic.detail import DetailView
-
-from common.permissions import PermissionsMixin, IsOrgAdmin, IsValidUser
-
-from .. import models, const, forms
-
-__all__ = [
- 'DatabaseAppListView', 'DatabaseAppCreateView', 'DatabaseAppUpdateView',
- 'DatabaseAppDetailView', 'UserDatabaseAppListView',
-]
-
-
-class DatabaseAppListView(PermissionsMixin, TemplateView):
- template_name = 'applications/database_app_list.html'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _("Application"),
- 'action': _('DatabaseApp list'),
- 'type_choices': const.DATABASE_APP_TYPE_CHOICES
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class BaseDatabaseAppCreateUpdateView:
- template_name = 'applications/database_app_create_update.html'
- model = models.DatabaseApp
- permission_classes = [IsOrgAdmin]
- default_type = const.DATABASE_APP_TYPE_MYSQL
- form_class = forms.DatabaseAppMySQLForm
- form_class_choices = {
- const.DATABASE_APP_TYPE_MYSQL: forms.DatabaseAppMySQLForm,
- }
-
- def get_initial(self):
- return {'type': self.get_type()}
-
- def get_type(self):
- return self.default_type
-
- def get_form_class(self):
- tp = self.get_type()
- form_class = self.form_class_choices.get(tp)
- if not form_class:
- raise Http404()
- return form_class
-
-
-class DatabaseAppCreateView(BaseDatabaseAppCreateUpdateView, CreateView):
-
- def get_type(self):
- tp = self.request.GET.get("type")
- if tp:
- return tp.lower()
- return super().get_type()
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Applications'),
- 'action': _('Create DatabaseApp'),
- 'api_action': 'create'
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class DatabaseAppUpdateView(BaseDatabaseAppCreateUpdateView, UpdateView):
-
- def get_type(self):
- return self.object.type
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Applications'),
- 'action': _('Create DatabaseApp'),
- 'api_action': 'update'
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class DatabaseAppDetailView(PermissionsMixin, DetailView):
- template_name = 'applications/database_app_detail.html'
- model = models.DatabaseApp
- context_object_name = 'database_app'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Applications'),
- 'action': _('DatabaseApp detail'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class UserDatabaseAppListView(PermissionsMixin, TemplateView):
- template_name = 'applications/user_database_app_list.html'
- permission_classes = [IsValidUser]
-
- def get_context_data(self, **kwargs):
- context = {
- 'action': _('My DatabaseApp'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
diff --git a/apps/applications/views/remote_app.py b/apps/applications/views/remote_app.py
deleted file mode 100644
index 92b436005..000000000
--- a/apps/applications/views/remote_app.py
+++ /dev/null
@@ -1,128 +0,0 @@
-# coding: utf-8
-#
-
-from django.http import Http404
-from django.utils.translation import ugettext as _
-from django.views.generic import TemplateView
-from django.views.generic.edit import CreateView, UpdateView
-from django.views.generic.detail import DetailView
-
-from common.permissions import PermissionsMixin, IsOrgAdmin, IsValidUser
-
-from ..models import RemoteApp
-from .. import forms, const
-
-
-__all__ = [
- 'RemoteAppListView', 'RemoteAppCreateView', 'RemoteAppUpdateView',
- 'RemoteAppDetailView', 'UserRemoteAppListView',
-]
-
-
-class RemoteAppListView(PermissionsMixin, TemplateView):
- template_name = 'applications/remote_app_list.html'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Applications'),
- 'action': _('RemoteApp list'),
- 'type_choices': const.REMOTE_APP_TYPE_CHOICES,
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class BaseRemoteAppCreateUpdateView:
- template_name = 'applications/remote_app_create_update.html'
- model = RemoteApp
- permission_classes = [IsOrgAdmin]
- default_type = const.REMOTE_APP_TYPE_CHROME
- form_class = forms.RemoteAppChromeForm
- form_class_choices = {
- const.REMOTE_APP_TYPE_CHROME: forms.RemoteAppChromeForm,
- const.REMOTE_APP_TYPE_MYSQL_WORKBENCH: forms.RemoteAppMySQLWorkbenchForm,
- const.REMOTE_APP_TYPE_VMWARE_CLIENT: forms.RemoteAppVMwareForm,
- const.REMOTE_APP_TYPE_CUSTOM: forms.RemoteAppCustomForm
- }
-
- def get_initial(self):
- return {'type': self.get_type()}
-
- def get_type(self):
- return self.default_type
-
- def get_form_class(self):
- tp = self.get_type()
- form_class = self.form_class_choices.get(tp)
- if not form_class:
- raise Http404()
- return form_class
-
-
-class RemoteAppCreateView(BaseRemoteAppCreateUpdateView,
- PermissionsMixin, CreateView):
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Applications'),
- 'action': _('Create RemoteApp'),
- 'api_action': 'create'
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
- def get_type(self):
- tp = self.request.GET.get("type")
- if tp:
- return tp.lower()
- return super().get_type()
-
-
-class RemoteAppUpdateView(BaseRemoteAppCreateUpdateView,
- PermissionsMixin, UpdateView):
-
- def get_initial(self):
- initial_data = super().get_initial()
- params = {k: v for k, v in self.object.params.items()}
- initial_data.update(params)
- return initial_data
-
- def get_type(self):
- return self.object.type
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Applications'),
- 'action': _('Update RemoteApp'),
- 'api_action': 'update'
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class RemoteAppDetailView(PermissionsMixin, DetailView):
- template_name = 'applications/remote_app_detail.html'
- model = RemoteApp
- context_object_name = 'remote_app'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Applications'),
- 'action': _('RemoteApp detail'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class UserRemoteAppListView(PermissionsMixin, TemplateView):
- template_name = 'applications/user_remote_app_list.html'
- permission_classes = [IsValidUser]
-
- def get_context_data(self, **kwargs):
- context = {
- 'action': _('My RemoteApp'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
diff --git a/apps/assets/forms/__init__.py b/apps/assets/forms/__init__.py
deleted file mode 100644
index 39b39a45a..000000000
--- a/apps/assets/forms/__init__.py
+++ /dev/null
@@ -1,8 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-from .asset import *
-from .label import *
-from .user import *
-from .domain import *
-from .cmd_filter import *
-from .platform import *
diff --git a/apps/assets/forms/asset.py b/apps/assets/forms/asset.py
deleted file mode 100644
index 54d97f036..000000000
--- a/apps/assets/forms/asset.py
+++ /dev/null
@@ -1,172 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-from itertools import groupby
-from django import forms
-from django.utils.translation import gettext_lazy as _
-
-from common.utils import get_logger
-from orgs.mixins.forms import OrgModelForm
-
-from ..models import Asset, Platform
-
-
-logger = get_logger(__file__)
-__all__ = [
- 'AssetCreateUpdateForm', 'AssetBulkUpdateForm', 'ProtocolForm',
-]
-
-
-class ProtocolForm(forms.Form):
- name = forms.ChoiceField(
- choices=Asset.PROTOCOL_CHOICES, label=_("Name"), initial='ssh',
- widget=forms.Select(attrs={'class': 'form-control protocol-name'})
- )
- port = forms.IntegerField(
- max_value=65534, min_value=1, label=_("Port"), initial=22,
- widget=forms.TextInput(attrs={'class': 'form-control protocol-port'})
- )
-
-
-class AssetCreateUpdateForm(OrgModelForm):
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
- self.set_platform_to_name()
- self.set_fields_queryset()
-
- def set_fields_queryset(self):
- nodes_field = self.fields['nodes']
- nodes_choices = []
- if self.instance:
- nodes_choices = [
- (n.id, n.full_value) for n in
- self.instance.nodes.all()
- ]
- nodes_field.choices = nodes_choices
-
- @staticmethod
- def sorted_platform(platform):
- if platform['base'] == 'Other':
- return 'zz'
- return platform['base']
-
- def set_platform_to_name(self):
- choices = []
- platforms = Platform.objects.all().values('name', 'base')
- platforms_sorted = sorted(platforms, key=self.sorted_platform)
- platforms_grouped = groupby(platforms_sorted, key=lambda x: x['base'])
- for i in platforms_grouped:
- base = i[0]
- grouped = sorted(i[1], key=lambda x: x['name'])
- grouped = [(j['name'], j['name']) for j in grouped]
- choices.append(
- (base, grouped)
- )
- platform_field = self.fields['platform']
- platform_field.choices = choices
- if self.instance:
- self.initial['platform'] = self.instance.platform.name
-
- def add_nodes_initial(self, node):
- nodes_field = self.fields['nodes']
- nodes_field.choices.append((node.id, node.full_value))
- nodes_field.initial = [node]
-
- class Meta:
- model = Asset
- fields = [
- 'hostname', 'ip', 'public_ip', 'protocols', 'comment',
- 'nodes', 'is_active', 'admin_user', 'labels', 'platform',
- 'domain', 'number',
- ]
- widgets = {
- 'nodes': forms.SelectMultiple(attrs={
- 'class': 'nodes-select2', 'data-placeholder': _('Nodes')
- }),
- 'admin_user': forms.Select(attrs={
- 'class': 'select2', 'data-placeholder': _('Admin user')
- }),
- 'labels': forms.SelectMultiple(attrs={
- 'class': 'select2', 'data-placeholder': _('Label')
- }),
- 'domain': forms.Select(attrs={
- 'class': 'select2', 'data-placeholder': _('Domain')
- }),
- 'platform': forms.Select(attrs={
- 'class': 'select2', 'data-placeholder': _('Platform')
- }),
- }
- labels = {
- 'nodes': _("Node"),
- }
- help_texts = {
- 'admin_user': _(
- 'root or other NOPASSWD sudo privilege user existed in asset,'
- 'If asset is windows or other set any one, more see admin user left menu'
- ),
- 'platform': _("Windows 2016 RDP protocol is different, If is window 2016, set it"),
- 'domain': _("If your have some network not connect with each other, you can set domain")
- }
-
-
-class AssetBulkUpdateForm(OrgModelForm):
- assets = forms.ModelMultipleChoiceField(
- required=True,
- label=_('Select assets'), queryset=Asset.objects,
- widget=forms.SelectMultiple(
- attrs={
- 'class': 'select2',
- 'data-placeholder': _('Select assets')
- }
- )
- )
-
- class Meta:
- model = Asset
- fields = [
- 'assets', 'admin_user', 'labels', 'platform',
- 'domain',
- ]
- widgets = {
- 'labels': forms.SelectMultiple(
- attrs={'class': 'select2', 'data-placeholder': _('Label')}
- ),
- 'nodes': forms.SelectMultiple(
- attrs={'class': 'select2', 'data-placeholder': _('Node')}
- ),
- }
-
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
- self.set_fields_queryset()
-
- # 重写其他字段为不再required
- for name, field in self.fields.items():
- if name != 'assets':
- field.required = False
-
- def set_fields_queryset(self):
- assets_field = self.fields['assets']
- if hasattr(self, 'data'):
- assets_field.queryset = Asset.objects.all()
-
- def save(self, commit=True):
- changed_fields = []
- for field in self._meta.fields:
- if self.data.get(field) not in [None, '']:
- changed_fields.append(field)
-
- cleaned_data = {k: v for k, v in self.cleaned_data.items()
- if k in changed_fields}
- assets = cleaned_data.pop('assets')
- labels = cleaned_data.pop('labels', [])
- nodes = cleaned_data.pop('nodes', None)
- assets = Asset.objects.filter(id__in=[asset.id for asset in assets])
- assets.update(**cleaned_data)
-
- if labels:
- for asset in assets:
- asset.labels.set(labels)
- if nodes:
- for asset in assets:
- asset.nodes.set(nodes)
- return assets
diff --git a/apps/assets/forms/cmd_filter.py b/apps/assets/forms/cmd_filter.py
deleted file mode 100644
index 46f8fc244..000000000
--- a/apps/assets/forms/cmd_filter.py
+++ /dev/null
@@ -1,40 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-from django import forms
-from django.core.exceptions import ValidationError
-from django.utils.translation import ugettext_lazy as _
-import re
-
-from orgs.mixins.forms import OrgModelForm
-from ..models import CommandFilter, CommandFilterRule
-
-__all__ = ['CommandFilterForm', 'CommandFilterRuleForm']
-
-
-class CommandFilterForm(OrgModelForm):
- class Meta:
- model = CommandFilter
- fields = ['name', 'comment']
-
-
-class CommandFilterRuleForm(OrgModelForm):
- invalid_pattern = re.compile(r'[\.\*\+\[\\\?\{\}\^\$\|\(\)\#\<\>]')
-
- class Meta:
- model = CommandFilterRule
- fields = [
- 'filter', 'type', 'content', 'priority', 'action', 'comment'
- ]
- widgets = {
- 'content': forms.Textarea(attrs={
- 'placeholder': 'eg:\r\nreboot\r\nrm -rf'
- }),
- }
-
- def clean_content(self):
- content = self.cleaned_data.get("content")
- if self.invalid_pattern.search(content):
- invalid_char = self.invalid_pattern.pattern.replace('\\', '')
- msg = _("Content should not be contain: {}").format(invalid_char)
- raise ValidationError(msg)
- return content
diff --git a/apps/assets/forms/domain.py b/apps/assets/forms/domain.py
deleted file mode 100644
index 71d9f6cfa..000000000
--- a/apps/assets/forms/domain.py
+++ /dev/null
@@ -1,79 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-from django import forms
-from django.utils.translation import gettext_lazy as _
-
-from orgs.mixins.forms import OrgModelForm
-from ..models import Domain, Asset, Gateway
-from .user import PasswordAndKeyAuthForm
-
-__all__ = ['DomainForm', 'GatewayForm']
-
-
-class DomainForm(forms.ModelForm):
- assets = forms.ModelMultipleChoiceField(
- queryset=Asset.objects, label=_('Asset'), required=False,
- widget=forms.SelectMultiple(
- attrs={'class': 'select2', 'data-placeholder': _('Select assets')}
- )
- )
-
- class Meta:
- model = Domain
- fields = ['name', 'comment', 'assets']
-
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
- self.set_fields_queryset()
-
- def set_fields_queryset(self):
- assets_field = self.fields.get('assets')
-
- # 没有data代表是渲染表单, 有data代表是提交创建/更新表单
- if not self.data:
- # 有instance 代表渲染更新表单, 否则是创建表单
- # 前端渲染优化, 防止过多资产, 设置assets queryset为none
- if self.instance:
- assets_field.initial = self.instance.assets.all()
- assets_field.queryset = self.instance.assets.all()
- else:
- assets_field.queryset = Asset.objects.none()
- else:
- assets_field.queryset = Asset.objects.all()
-
- def save(self, commit=True):
- instance = super().save(commit=commit)
- assets = self.cleaned_data['assets']
- instance.assets.set(assets)
- return instance
-
-
-class GatewayForm(PasswordAndKeyAuthForm, OrgModelForm):
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
- password_field = self.fields.get('password')
- password_field.help_text = _('Password should not contain special characters')
- protocol_field = self.fields.get('protocol')
- protocol_field.choices = [Gateway.PROTOCOL_CHOICES[0]]
-
- def save(self, commit=True):
- # Because we define custom field, so we need rewrite :method: `save`
- instance = super().save()
- password = self.cleaned_data.get('password')
- private_key, public_key = super().gen_keys()
- instance.set_auth(password=password, private_key=private_key)
- return instance
-
- class Meta:
- model = Gateway
- fields = [
- 'name', 'ip', 'port', 'username', 'protocol', 'domain', 'password',
- 'private_key', 'is_active', 'comment',
- ]
- help_texts = {
- 'protocol': _("SSH gateway support proxy SSH,RDP,VNC")
- }
- widgets = {
- 'name': forms.TextInput(attrs={'placeholder': _('Name')}),
- 'username': forms.TextInput(attrs={'placeholder': _('Username')}),
- }
diff --git a/apps/assets/forms/label.py b/apps/assets/forms/label.py
deleted file mode 100644
index 1f2f13987..000000000
--- a/apps/assets/forms/label.py
+++ /dev/null
@@ -1,46 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-from django import forms
-from django.utils.translation import gettext_lazy as _
-
-from ..models import Label, Asset
-
-__all__ = ['LabelForm']
-
-
-class LabelForm(forms.ModelForm):
- assets = forms.ModelMultipleChoiceField(
- queryset=Asset.objects.none(), label=_('Asset'), required=False,
- widget=forms.SelectMultiple(
- attrs={'class': 'select2', 'data-placeholder': _('Select assets')}
- )
- )
-
- class Meta:
- model = Label
- fields = ['name', 'value', 'assets']
-
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
- self.set_fields_queryset()
-
- def set_fields_queryset(self):
- assets_field = self.fields.get('assets')
-
- # 没有data代表是渲染表单, 有data代表是提交创建/更新表单
- if not self.data:
- # 有instance 代表渲染更新表单, 否则是创建表单
- # 前端渲染优化, 防止过多资产, 设置assets queryset为none
- if self.instance:
- assets_field.initial = self.instance.assets.all()
- assets_field.queryset = self.instance.assets.all()
- else:
- assets_field.queryset = Asset.objects.none()
- else:
- assets_field.queryset = Asset.objects.all()
-
- def save(self, commit=True):
- label = super().save(commit=commit)
- assets = self.cleaned_data['assets']
- label.assets.set(assets)
- return label
diff --git a/apps/assets/forms/platform.py b/apps/assets/forms/platform.py
deleted file mode 100644
index 88c4365d4..000000000
--- a/apps/assets/forms/platform.py
+++ /dev/null
@@ -1,42 +0,0 @@
-# -*- coding: utf-8 -*-
-
-from django import forms
-from django.utils.translation import ugettext_lazy as _
-
-from ..models import Platform
-
-
-__all__ = ['PlatformForm', 'PlatformMetaForm']
-
-
-class PlatformMetaForm(forms.Form):
- SECURITY_CHOICES = (
- ('rdp', "RDP"),
- ('nla', "NLA"),
- ('tls', 'TLS'),
- ('any', "Any"),
- )
- CONSOLE_CHOICES = (
- (True, _('Yes')),
- (False, _('No')),
- )
- security = forms.ChoiceField(
- choices=SECURITY_CHOICES, initial='any', label=_("RDP security"),
- required=False,
- )
- console = forms.ChoiceField(
- choices=CONSOLE_CHOICES, initial=False, label=_("RDP console"),
- required=False,
- )
-
-
-class PlatformForm(forms.ModelForm):
- class Meta:
- model = Platform
- fields = [
- 'name', 'base', 'comment',
- ]
- labels = {
- 'base': _("Base platform")
- }
-
diff --git a/apps/assets/forms/user.py b/apps/assets/forms/user.py
deleted file mode 100644
index ff8d27dfd..000000000
--- a/apps/assets/forms/user.py
+++ /dev/null
@@ -1,115 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-from django import forms
-from django.utils.translation import gettext_lazy as _
-
-from common.utils import validate_ssh_private_key, ssh_pubkey_gen, get_logger
-from orgs.mixins.forms import OrgModelForm
-from ..models import AdminUser, SystemUser
-
-logger = get_logger(__file__)
-__all__ = [
- 'FileForm', 'SystemUserForm', 'AdminUserForm', 'PasswordAndKeyAuthForm',
-]
-
-
-class FileForm(forms.Form):
- file = forms.FileField()
-
-
-class PasswordAndKeyAuthForm(forms.ModelForm):
- # Form field name can not start with `_`, so redefine it,
- password = forms.CharField(
- widget=forms.PasswordInput, max_length=128,
- strip=True, required=False,
- help_text=_('Password or private key passphrase'),
- label=_("Password"),
- )
- # Need use upload private key file except paste private key content
- private_key = forms.FileField(required=False, label=_("Private key"))
-
- def clean_private_key(self):
- private_key_f = self.cleaned_data['private_key']
- password = self.cleaned_data['password']
-
- if private_key_f:
- key_string = private_key_f.read()
- private_key_f.seek(0)
- key_string = key_string.decode()
-
- if not validate_ssh_private_key(key_string, password):
- msg = _('Invalid private key, Only support '
- 'RSA/DSA format key')
- raise forms.ValidationError(msg)
- return private_key_f
-
- def validate_password_key(self):
- password = self.cleaned_data['password']
- private_key_f = self.cleaned_data.get('private_key', '')
-
- if not password and not private_key_f:
- raise forms.ValidationError(_(
- 'Password and private key file must be input one'
- ))
-
- def gen_keys(self):
- password = self.cleaned_data.get('password', '') or None
- private_key_f = self.cleaned_data['private_key']
- public_key = private_key = None
-
- if private_key_f:
- private_key = private_key_f.read().strip().decode('utf-8')
- public_key = ssh_pubkey_gen(private_key=private_key, password=password)
- return private_key, public_key
-
-
-class AdminUserForm(PasswordAndKeyAuthForm):
- def save(self, commit=True):
- raise forms.ValidationError("Use api to save")
-
- class Meta:
- model = AdminUser
- fields = ['name', 'username', 'password', 'private_key', 'comment']
- widgets = {
- 'name': forms.TextInput(attrs={'placeholder': _('Name')}),
- 'username': forms.TextInput(attrs={'placeholder': _('Username')}),
- }
-
-
-class SystemUserForm(OrgModelForm, PasswordAndKeyAuthForm):
- # Admin user assets define, let user select, save it in form not in view
- auto_generate_key = forms.BooleanField(initial=True, required=False)
-
- def save(self, commit=True):
- raise forms.ValidationError("Use api to save")
-
- class Meta:
- model = SystemUser
- fields = [
- 'name', 'username', 'protocol', 'auto_generate_key',
- 'password', 'private_key', 'auto_push', 'sudo',
- 'username_same_with_user',
- 'comment', 'shell', 'priority', 'login_mode', 'cmd_filters',
- 'sftp_root',
- ]
- widgets = {
- 'name': forms.TextInput(attrs={'placeholder': _('Name')}),
- 'username': forms.TextInput(attrs={'placeholder': _('Username')}),
- 'cmd_filters': forms.SelectMultiple(attrs={
- 'class': 'select2', 'data-placeholder': _('Command filter')
- }),
- }
- labels = {
- 'username_same_with_user': _("Username same with user"),
- }
- help_texts = {
- 'auto_push': _('Auto push system user to asset'),
- 'priority': _('1-100, High level will be using login asset as default, '
- 'if user was granted more than 2 system user'),
- 'login_mode': _('If you choose manual login mode, you do not '
- 'need to fill in the username and password.'),
- 'sudo': _("Use comma split multi command, ex: /bin/whoami,/bin/ifconfig"),
- 'sftp_root': _("SFTP root dir, tmp, home or custom"),
- 'username_same_with_user': _("Username is dynamic, When connect asset, using current user's username"),
- # 'username_same_with_user': _("用户名是动态的,登录资产时使用当前用户的用户名登录"),
- }
diff --git a/apps/assets/templates/assets/_asset_group_bulk_update_modal.html b/apps/assets/templates/assets/_asset_group_bulk_update_modal.html
deleted file mode 100644
index 7df6c4ede..000000000
--- a/apps/assets/templates/assets/_asset_group_bulk_update_modal.html
+++ /dev/null
@@ -1,41 +0,0 @@
-{% extends '_modal.html' %}
-{% load i18n %}
-{% block modal_id %}asset_group_bulk_update_modal{% endblock %}
-{% block modal_class %}modal-lg{% endblock %}
-{% block modal_title%}{% trans "Update asset group" %}{% endblock %}
-{% block modal_body %}
-{% load bootstrap3 %}
-{% trans "Hint: only change the field you want to update." %}
-
-{% endblock %}
-{% block modal_confirm_id %}btn_asset_group_bulk_update{% endblock %}
diff --git a/apps/assets/templates/assets/_asset_list_modal.html b/apps/assets/templates/assets/_asset_list_modal.html
deleted file mode 100644
index dea2c3e1e..000000000
--- a/apps/assets/templates/assets/_asset_list_modal.html
+++ /dev/null
@@ -1,224 +0,0 @@
-{% extends '_modal.html' %}
-{% load i18n %}
-{% load static %}
-
-{% block modal_class %}modal-lg{% endblock %}
-{% block modal_id %}asset_list_modal{% endblock %}
-{% block modal_title%}{% trans "Asset list" %}{% endblock %}
-{% block modal_body %}
-
-
-
-
-
-
-
-
-
-
-
-
- {% trans 'Loading' %} ...
-
-
-
-
-
-
-
-
-
-
-
-
-
-{% endblock %}
-
-{% block modal_button %}
- {{ block.super }}
-{% endblock %}
-{% block modal_confirm_id %}btn_asset_modal_confirm{% endblock %}
-
-
-
diff --git a/apps/assets/templates/assets/_asset_user_auth_update_modal.html b/apps/assets/templates/assets/_asset_user_auth_update_modal.html
deleted file mode 100644
index fe88b7426..000000000
--- a/apps/assets/templates/assets/_asset_user_auth_update_modal.html
+++ /dev/null
@@ -1,87 +0,0 @@
-{% extends '_modal.html' %}
-{% load i18n %}
-{% block modal_id %}asset_user_auth_update_modal{% endblock %}
-{% block modal_title%}{% trans "Update asset user auth" %}{% endblock %}
-{% block modal_body %}
-
-
-{% endblock %}
-{% block modal_confirm_id %}btn_asset_user_auth_update_modal_confirm{% endblock %}
diff --git a/apps/assets/templates/assets/_asset_user_auth_view_modal.html b/apps/assets/templates/assets/_asset_user_auth_view_modal.html
deleted file mode 100644
index 8cc3a78de..000000000
--- a/apps/assets/templates/assets/_asset_user_auth_view_modal.html
+++ /dev/null
@@ -1,102 +0,0 @@
-{% extends '_modal.html' %}
-{% load i18n %}
-{% load static %}
-{% block modal_id %}asset_user_auth_view{% endblock %}
-{% block modal_title%}{% trans "Asset user auth" %}{% endblock %}
-{% block modal_body %}
-
-
-
-
-{% endblock %}
-{% block modal_button %}
- {% trans "Close" %}
-{% endblock %}
diff --git a/apps/assets/templates/assets/_asset_user_list.html b/apps/assets/templates/assets/_asset_user_list.html
deleted file mode 100644
index d43cea10f..000000000
--- a/apps/assets/templates/assets/_asset_user_list.html
+++ /dev/null
@@ -1,188 +0,0 @@
-{% load i18n %}
-
-
-
-{% include 'assets/_asset_user_auth_update_modal.html' %}
-{% include 'assets/_asset_user_auth_view_modal.html' %}
-{% include 'authentication/_mfa_confirm_modal.html' %}
-
-
diff --git a/apps/assets/templates/assets/_gateway_test_modal.html b/apps/assets/templates/assets/_gateway_test_modal.html
deleted file mode 100644
index 2eef52c7e..000000000
--- a/apps/assets/templates/assets/_gateway_test_modal.html
+++ /dev/null
@@ -1,18 +0,0 @@
-{% extends '_modal.html' %}
-{% load i18n %}
-{% block modal_id %}gateway_test{% endblock %}
-{% block modal_title%}{% trans "Test gateway test connection" %}{% endblock %}
-{% block modal_body %}
-{% load bootstrap3 %}
-
-{% endblock %}
-{% block modal_confirm_id %}btn_gateway_test{% endblock %}
\ No newline at end of file
diff --git a/apps/assets/templates/assets/_node_detail_modal.html b/apps/assets/templates/assets/_node_detail_modal.html
deleted file mode 100644
index f1f6f2dda..000000000
--- a/apps/assets/templates/assets/_node_detail_modal.html
+++ /dev/null
@@ -1,68 +0,0 @@
-{% extends '_modal.html' %}
-{% load i18n %}
-{% load static %}
-
-{% block modal_id %}node_detail_modal{% endblock %}
-
-{% block modal_title %}{% trans "Node detail" %}{% endblock %}
-
-
-{% block modal_body %}
-
-
-
-
-{% endblock %}
-
-{% block modal_button %}
-{% trans "Close" %}
-{% endblock %}
diff --git a/apps/assets/templates/assets/_node_tree.html b/apps/assets/templates/assets/_node_tree.html
deleted file mode 100644
index c500f55f8..000000000
--- a/apps/assets/templates/assets/_node_tree.html
+++ /dev/null
@@ -1,339 +0,0 @@
-{% load static %}
-{% load i18n %}
-
-{# #}
-
-
-
-
-
-
-
- {% trans 'Loading' %} ...
-
-
-
-
-
-
-
-
diff --git a/apps/assets/templates/assets/_system_user.html b/apps/assets/templates/assets/_system_user.html
deleted file mode 100644
index e05a9448b..000000000
--- a/apps/assets/templates/assets/_system_user.html
+++ /dev/null
@@ -1,282 +0,0 @@
-{% extends 'base.html' %}
-{% load i18n %}
-{% load static %}
-{% load bootstrap3 %}
-
-{% block content %}
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/assets/templates/assets/_user_asset_detail_modal.html b/apps/assets/templates/assets/_user_asset_detail_modal.html
deleted file mode 100644
index ca2b8f252..000000000
--- a/apps/assets/templates/assets/_user_asset_detail_modal.html
+++ /dev/null
@@ -1,24 +0,0 @@
-{% extends '_modal.html' %}
-{% load i18n %}
-{% load static %}
-
-{% block modal_id %}user_asset_detail_modal{% endblock %}
-
-{% block modal_title %}{% trans "Asset detail" %}{% endblock %}
-
-{% block modal_body %}
-
-{% endblock %}
-
-{% block modal_button %}
-{% trans "Close" %}
-{% endblock %}
diff --git a/apps/assets/templates/assets/admin_user_assets.html b/apps/assets/templates/assets/admin_user_assets.html
deleted file mode 100644
index a42c6032f..000000000
--- a/apps/assets/templates/assets/admin_user_assets.html
+++ /dev/null
@@ -1,93 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block content %}
-
-
-
-
-
-
-
-
-
-
{% trans 'Asset list of ' %} {{ admin_user.name }}
-
-
-
- {% include 'assets/_asset_user_list.html' %}
-
-
-
-
-
-
- {% trans 'Quick update' %}
-
-
-
-
-
- {% trans 'Test connective' %}:
-
-
- {% trans 'Test' %}
-
-
-
-
-
-
-
-
-
-
-
-
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/assets/templates/assets/admin_user_create_update.html b/apps/assets/templates/assets/admin_user_create_update.html
deleted file mode 100644
index 213f038d1..000000000
--- a/apps/assets/templates/assets/admin_user_create_update.html
+++ /dev/null
@@ -1,86 +0,0 @@
-{% extends 'base.html' %}
-{% load i18n %}
-{% load static %}
-{% load bootstrap3 %}
-
-{% block content %}
-
-
-
-
-
-
- {% if form.non_field_errors %}
-
- {{ form.non_field_errors }}
-
- {% endif %}
-
-
-
-
-
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/assets/templates/assets/admin_user_detail.html b/apps/assets/templates/assets/admin_user_detail.html
deleted file mode 100644
index 198b1e765..000000000
--- a/apps/assets/templates/assets/admin_user_detail.html
+++ /dev/null
@@ -1,166 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block content %}
-
-
-
-
-
-
-
-
-
-
{{ admin_user.name }}
-
-
-
-
-
-
- {% trans 'Name' %}:
- {{ admin_user.name }}
-
-
- {% trans 'Username' %}:
- {{ admin_user.username }}
-
-
- {% trans 'Date created' %}:
- {{ admin_user.date_created }}
-
-
- {% trans 'Created by' %}:
- {{ admin_user.created_by }}
-
-
- {% trans 'Comment' %}:
- {{ admin_user.comment }}
-
-
-
-
-
-
-
-
-
- {% trans 'Replace node assets admin user with this' %}
-
-
-
-
-
-
-
-
-
-
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/assets/templates/assets/admin_user_list.html b/apps/assets/templates/assets/admin_user_list.html
deleted file mode 100644
index aaee06d69..000000000
--- a/apps/assets/templates/assets/admin_user_list.html
+++ /dev/null
@@ -1,77 +0,0 @@
-{% extends '_base_list.html' %}
-{% load i18n static %}
-{% block help_message %}
- {% trans 'Admin users are asset (charged server) on the root, or have NOPASSWD: ALL sudo permissions users, '%}
- {% trans 'JumpServer users of the system using the user to `push system user`, `get assets hardware information`, etc. '%}
-{% endblock %}
-{% block table_search %}
- {% include '_csv_import_export.html' %}
-{% endblock %}
-
-{% block table_container %}
-
-
-{% endblock %}
-{% block content_bottom_left %}{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/assets/templates/assets/asset_asset_user_list.html b/apps/assets/templates/assets/asset_asset_user_list.html
deleted file mode 100644
index 4ad5a2c43..000000000
--- a/apps/assets/templates/assets/asset_asset_user_list.html
+++ /dev/null
@@ -1,97 +0,0 @@
-{% extends 'base.html' %}
-{% load common_tags %}
-{% load static %}
-{% load i18n %}
-{% block content %}
-
-
-
-
-
-
-
-
-
-
{% trans 'Asset users of' %} {{ asset.hostname }}
-
-
-
- {% include 'assets/_asset_user_list.html' %}
-
-
-
-
-
-
- {% trans 'Quick modify' %}
-
-
-
-
- {% if asset.is_support_ansible %}
-
- {% trans 'Test connective' %}:
-
-
- {% trans 'Test' %}
-
-
-
- {% endif %}
-
-
-
-
-
-
-
-
-
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/assets/templates/assets/asset_bulk_update.html b/apps/assets/templates/assets/asset_bulk_update.html
deleted file mode 100644
index 207d5eb52..000000000
--- a/apps/assets/templates/assets/asset_bulk_update.html
+++ /dev/null
@@ -1,71 +0,0 @@
-{% extends '_base_create_update.html' %}
-{% load static %}
-{% load bootstrap3 %}
-{% load i18n %}
-
-{% block form %}
-
-
-{% include 'assets/_asset_list_modal.html' %}
-{% endblock %}
-
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/assets/templates/assets/asset_create.html b/apps/assets/templates/assets/asset_create.html
deleted file mode 100644
index 0f50b2b86..000000000
--- a/apps/assets/templates/assets/asset_create.html
+++ /dev/null
@@ -1,249 +0,0 @@
-{% extends '_base_create_update.html' %}
-{% load static %}
-{% load bootstrap3 %}
-{% load i18n %}
-{% load asset_tags %}
-{% load common_tags %}
-
-{% block form %}
-
-{% endblock %}
-
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/assets/templates/assets/asset_detail.html b/apps/assets/templates/assets/asset_detail.html
deleted file mode 100644
index 53717c643..000000000
--- a/apps/assets/templates/assets/asset_detail.html
+++ /dev/null
@@ -1,362 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block custom_head_css_js %}
-
-
-{% endblock %}
-
-{% block content %}
-
-
-
-
-
-
-
-
-
-
{{ asset.hostname }}
-
-
-
-
-
-
- {% trans 'Hostname' %}:
- {{ asset.hostname }}
-
-
- {% trans 'IP' %}:
- {{ asset.ip }}
-
-
- {% trans 'Public IP' %}:
- {{ asset.public_ip|default:"" }}
-
-
- {% trans 'Protocol' %}
- {{ asset.protocols }}
-
-
- {% trans 'Admin user' %}:
- {{ asset.admin_user }}
-
-
- {% trans 'Domain' %}:
- {{ asset.domain|default:"" }}
-
-
- {% trans 'Vendor' %}:
- {{ asset.vendor|default:"" }}
-
-
- {% trans 'Model' %}:
- {{ asset.model|default:"" }}
-
-
- {% trans 'CPU' %}:
- {{ asset.cpu_info }}
-
-
- {% trans 'Memory' %}:
- {{ asset.memory|default:"" }}
-
-
- {% trans 'Disk' %}:
- {{ asset.disk_total|default:"" }}
-
-
- {% trans 'Platform' %}:
- {{ asset.platform|default:"" }}
-
-
- {% trans 'OS' %}:
- {{ asset.os|default:"" }} {{ asset.os_version|default:"" }} {{ asset.os_arch|default:"" }}
-
-
- {% trans 'Is active' %}:
- {{ asset.is_active|yesno:"Yes,No" }}
-
-
- {% trans 'Serial number' %}:
- {{ asset.sn|default:"" }}
-
-
- {% trans 'Asset number' %}:
- {{ asset.number|default:"" }}
-
-
- {% trans 'Created by' %}:
- {{ asset.created_by }}
-
-
- {% trans 'Date joined' %}:
- {{ asset.date_joined|date:"Y-m-j H:i:s" }}
-
-
- {% trans 'Comment' %}:
- {{ asset.comment }}
-
-
-
-
-
-
- {% if user.is_superuser or user.is_org_admin %}
-
-
-
- {% trans 'Quick modify' %}
-
-
-
-
-
- {% trans 'Active' %}:
-
-
-
-
-
-
- {% if asset.is_support_ansible %}
-
- {% trans 'Refresh hardware' %}:
-
-
- {% trans 'Refresh' %}
-
-
-
-
- {% trans 'Test connective' %}:
-
-
- {% trans 'Test' %}
-
-
-
- {% endif %}
-
-
-
-
-
-
-
- {% trans 'Nodes' %}
-
-
-
-
-
-
- {% for node in asset.nodes.all %}
-
- {{ node.full_value }}
-
-
-
-
- {% endfor %}
-
-
-
-
-
-
-
- {% trans 'Labels' %}
-
-
-
- {% endif %}
-
-
-
-
-
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/assets/templates/assets/asset_list.html b/apps/assets/templates/assets/asset_list.html
deleted file mode 100644
index 2eeda8f69..000000000
--- a/apps/assets/templates/assets/asset_list.html
+++ /dev/null
@@ -1,416 +0,0 @@
-{% extends '_base_asset_tree_list.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block help_message %}
- {% trans 'The left side is the asset tree, right click to create, delete, and change the tree node, authorization asset is also organized as a node, and the right side is the asset under that node' %}
-{% endblock %}
-
-{% block table_container %}
-
- {% include '_csv_import_export.html' %}
-
- {% trans 'Label' %}
-
-
-
-
-{% include 'assets/_asset_list_modal.html' %}
-{% include 'assets/_node_detail_modal.html' %}
-{% endblock %}
-
-{% block custom_foot_js %}
-
-
-{% endblock %}
diff --git a/apps/assets/templates/assets/asset_update.html b/apps/assets/templates/assets/asset_update.html
deleted file mode 100644
index 4c23f7095..000000000
--- a/apps/assets/templates/assets/asset_update.html
+++ /dev/null
@@ -1,15 +0,0 @@
-{% extends 'assets/asset_create.html' %}
-{% load bootstrap3 %}
-{% load i18n %}
-
-{% block extra %}
-
- {% trans 'Configuration' %}
- {% bootstrap_field form.number layout="horizontal" %}
-{% endblock %}
-
-{% block formUrl %}
- var the_url = '{% url 'api-assets:asset-detail' pk=object.id %}';
- var redirect_to = '{% url "assets:asset-list" %}';
- var method = 'PUT';
-{% endblock %}
\ No newline at end of file
diff --git a/apps/assets/templates/assets/cmd_filter_create_update.html b/apps/assets/templates/assets/cmd_filter_create_update.html
deleted file mode 100644
index 678e1e3eb..000000000
--- a/apps/assets/templates/assets/cmd_filter_create_update.html
+++ /dev/null
@@ -1,46 +0,0 @@
-{% extends '_base_create_update.html' %}
-{% load static %}
-{% load bootstrap3 %}
-{% load i18n %}
-
-{% block form %}
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
\ No newline at end of file
diff --git a/apps/assets/templates/assets/cmd_filter_detail.html b/apps/assets/templates/assets/cmd_filter_detail.html
deleted file mode 100644
index 24e192253..000000000
--- a/apps/assets/templates/assets/cmd_filter_detail.html
+++ /dev/null
@@ -1,173 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block content %}
-
-
-
-
-
-
-
-
-
-
-
-
-
- {% trans 'Name' %}:
- {{ object.name }}
-
-
- {% trans 'Comment' %}:
- {{ object.comment }}
-
-
- {% trans 'Date created' %}:
- {{ object.date_created }}
-
-
- {% trans 'Date updated' %}:
- {{ object.date_updated }}
-
-
- {% trans 'Created by' %}:
- {{ object.created_by }}
-
-
-
-
-
-
-
-
-
-
- {% trans 'System users' %}
-
-
-
-
-
- {% for system_user in object.system_users.all %}
-
- {{ system_user }}
-
-
-
-
- {% endfor %}
-
-
-
-
-
-
-
-
-
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/assets/templates/assets/cmd_filter_list.html b/apps/assets/templates/assets/cmd_filter_list.html
deleted file mode 100644
index 1d98d5500..000000000
--- a/apps/assets/templates/assets/cmd_filter_list.html
+++ /dev/null
@@ -1,89 +0,0 @@
-{% extends '_base_list.html' %}
-{% load i18n static %}
-{% block table_search %}{% endblock %}
-{% block help_message %}
- {% trans 'System user bound some command filter, each command filter has some rules,'%}
- {% trans 'When user login asset with this system user, then run a command,' %}
- {% trans 'The command will be filter by rules, higher priority rule run first,' %}
- {% trans 'When a rule matched, if rule action is allow, then allow command execute,' %}
- {% trans 'else if action is deny, then command with be deny,' %}
- {% trans 'else match next rule, if none matched, allowed' %}
-{% endblock %}
-{% block table_container %}
-
-
-{% endblock %}
-{% block content_bottom_left %}{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
-
-
-
diff --git a/apps/assets/templates/assets/cmd_filter_rule_create_update.html b/apps/assets/templates/assets/cmd_filter_rule_create_update.html
deleted file mode 100644
index 21279b410..000000000
--- a/apps/assets/templates/assets/cmd_filter_rule_create_update.html
+++ /dev/null
@@ -1,90 +0,0 @@
-{% extends 'base.html' %}
-{% load i18n %}
-{% load static %}
-{% load bootstrap3 %}
-
-{% block content %}
-
-{% endblock %}
-
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/assets/templates/assets/cmd_filter_rule_list.html b/apps/assets/templates/assets/cmd_filter_rule_list.html
deleted file mode 100644
index 6076cb2ac..000000000
--- a/apps/assets/templates/assets/cmd_filter_rule_list.html
+++ /dev/null
@@ -1,110 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block content %}
-
-
-
-
-
-
-
-
-
-
-
-
{% trans 'Command filter rule list' %}
-
-
-
-
-
-
-
-
-
-
-{% endblock %}
-{% block content_bottom_left %}{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/assets/templates/assets/delete_confirm.html b/apps/assets/templates/assets/delete_confirm.html
deleted file mode 100644
index 94f017ca2..000000000
--- a/apps/assets/templates/assets/delete_confirm.html
+++ /dev/null
@@ -1,15 +0,0 @@
-{% load i18n %}
-
-
-
-
- {% trans 'Confirm delete' %}
-
-
-
-
-
\ No newline at end of file
diff --git a/apps/assets/templates/assets/domain_create_update.html b/apps/assets/templates/assets/domain_create_update.html
deleted file mode 100644
index 39939c8ca..000000000
--- a/apps/assets/templates/assets/domain_create_update.html
+++ /dev/null
@@ -1,52 +0,0 @@
-{% extends '_base_create_update.html' %}
-{% load static %}
-{% load bootstrap3 %}
-{% load i18n %}
-
-{% block form %}
-
-{% include 'assets/_asset_list_modal.html' %}
-{% endblock %}
-
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/assets/templates/assets/domain_detail.html b/apps/assets/templates/assets/domain_detail.html
deleted file mode 100644
index 119b58080..000000000
--- a/apps/assets/templates/assets/domain_detail.html
+++ /dev/null
@@ -1,132 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block content %}
-
-
-
-
-
-
-
-
-
-
-
-
-
- {% trans 'Name' %}:
- {{ object.name }}
-
-
- {% trans 'Asset' %}:
- {{ object.assets.count }}
-
-
- {% trans 'Gateway' %}:
- {{ object.gateway_set.count }}
-
-
- {% trans 'Date created' %}:
- {{ object.date_created }}
-
-
- {% trans 'Comment' %}:
- {{ object.comment }}
-
-
-
-
-
-
-
-
-
-
-
-{% endblock %}
-{% block content_bottom_left %}{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/assets/templates/assets/domain_gateway_list.html b/apps/assets/templates/assets/domain_gateway_list.html
deleted file mode 100644
index 8917ef810..000000000
--- a/apps/assets/templates/assets/domain_gateway_list.html
+++ /dev/null
@@ -1,141 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block content %}
-
-
-
-
-
-
-
-
-
-
-
-
{% trans 'Gateway list' %}
-
-
-
-
-
-
-
-
-
-
-{% include 'assets/_gateway_test_modal.html' %}
-{% endblock %}
-{% block content_bottom_left %}{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/assets/templates/assets/domain_list.html b/apps/assets/templates/assets/domain_list.html
deleted file mode 100644
index 623f1bea2..000000000
--- a/apps/assets/templates/assets/domain_list.html
+++ /dev/null
@@ -1,79 +0,0 @@
-{% extends '_base_list.html' %}
-{% load i18n static %}
-{% block table_search %}{% endblock %}
-
-{% block help_message %}
- {% trans 'The domain function is added to address the fact that some environments (such as the hybrid cloud) cannot be connected directly by jumping on the gateway server.' %}
-
- {% trans 'JMS => Domain gateway => Target assets' %}
-{% endblock %}
-
-{% block table_container %}
-
-
-{% endblock %}
-{% block content_bottom_left %}{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/assets/templates/assets/gateway_create_update.html b/apps/assets/templates/assets/gateway_create_update.html
deleted file mode 100644
index 43dc07b1b..000000000
--- a/apps/assets/templates/assets/gateway_create_update.html
+++ /dev/null
@@ -1,124 +0,0 @@
-{% extends 'base.html' %}
-{% load i18n %}
-{% load static %}
-{% load bootstrap3 %}
-
-{% block content %}
-
-{% endblock %}
-
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/assets/templates/assets/label_create_update.html b/apps/assets/templates/assets/label_create_update.html
deleted file mode 100644
index 62732d6ba..000000000
--- a/apps/assets/templates/assets/label_create_update.html
+++ /dev/null
@@ -1,56 +0,0 @@
-{% extends '_base_create_update.html' %}
-{% load static %}
-{% load bootstrap3 %}
-{% load i18n %}
-
-
-
-{% block form %}
-
-{% include 'assets/_asset_list_modal.html' %}
-{% endblock %}
-
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/assets/templates/assets/label_list.html b/apps/assets/templates/assets/label_list.html
deleted file mode 100644
index 104e5820b..000000000
--- a/apps/assets/templates/assets/label_list.html
+++ /dev/null
@@ -1,72 +0,0 @@
-{% extends '_base_list.html' %}
-{% load i18n static %}
-{% block table_search %}{% endblock %}
-{% block table_container %}
-
-
-{% endblock %}
-{% block content_bottom_left %}{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
-
-
-
diff --git a/apps/assets/templates/assets/platform_create_update.html b/apps/assets/templates/assets/platform_create_update.html
deleted file mode 100644
index e130e9e97..000000000
--- a/apps/assets/templates/assets/platform_create_update.html
+++ /dev/null
@@ -1,79 +0,0 @@
-{% extends '_base_create_update.html' %} {% load static %} {% load bootstrap3 %}
-{% load i18n %}
-
-{% block form %}
-
-{% endblock %}
-
-{% block custom_foot_js %}
-
-{% endblock %}
-
diff --git a/apps/assets/templates/assets/platform_detail.html b/apps/assets/templates/assets/platform_detail.html
deleted file mode 100644
index 89d364e0f..000000000
--- a/apps/assets/templates/assets/platform_detail.html
+++ /dev/null
@@ -1,91 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block content %}
-
-
-
-
-
-
-
-
-
-
-
-
-
- {% trans 'Name' %}:
- {{ object.name }}
-
-
- {% trans 'Base platform' %}:
- {{ object.base }}
-
-
- {% trans 'Charset' %}:
- {{ object.charset }}
-
-
- {% trans 'Meta' %}:
- {{ object.meta }}
-
-
- {% trans 'Comment' %}:
- {{ object.comment }}
-
-
-
-
-
-
-
-
-
-
-
-{% endblock %}
-{% block content_bottom_left %}{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/assets/templates/assets/platform_list.html b/apps/assets/templates/assets/platform_list.html
deleted file mode 100644
index cb1eef5bc..000000000
--- a/apps/assets/templates/assets/platform_list.html
+++ /dev/null
@@ -1,75 +0,0 @@
-{% extends '_base_list.html' %}
-{% load i18n static %}
-{% block table_search %}
-{% endblock %}
-
-{% block table_container %}
-
-
-{% endblock %}
-{% block content_bottom_left %}{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/assets/templates/assets/system_user_assets.html b/apps/assets/templates/assets/system_user_assets.html
deleted file mode 100644
index d48f48201..000000000
--- a/apps/assets/templates/assets/system_user_assets.html
+++ /dev/null
@@ -1,349 +0,0 @@
-{% extends 'base.html' %}
-{% load common_tags %}
-{% load static %}
-{% load i18n %}
-
-{% block custom_head_css_js %}
-
-{% endblock %}
-
-{% block content %}
-
-
-
-
-
-
-
-
-
-
{{ system_user.name }} {{ paginator.count }}
-
-
-
- {% include 'assets/_asset_user_list.html' %}
-
-
-
-
-
-
- {% trans 'Quick update' %}
-
-
-
-
-
- {% trans 'Test assets connective' %}:
-
-
- {% trans 'Test' %}
-
-
-
- {% if system_user.auto_push %}
-
- {% trans 'Push system user now' %}:
-
-
- {% trans 'Push' %}
-
-
-
- {% endif %}
-
-
-
-
-
-
- {% trans 'Assets' %}
-
-
-
-
-
- {% trans 'Nodes' %}
-
-
-
-
-
-
-
-
-
- {% include 'assets/_asset_list_modal.html' %}
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/assets/templates/assets/system_user_create.html b/apps/assets/templates/assets/system_user_create.html
deleted file mode 100644
index 7127de993..000000000
--- a/apps/assets/templates/assets/system_user_create.html
+++ /dev/null
@@ -1,7 +0,0 @@
-{% extends 'assets/_system_user.html' %}
-{% load i18n %}
-{% load static %}
-
-{% block auth %}
- {{ block.super }}
-{% endblock %}
diff --git a/apps/assets/templates/assets/system_user_detail.html b/apps/assets/templates/assets/system_user_detail.html
deleted file mode 100644
index 01e71fc1c..000000000
--- a/apps/assets/templates/assets/system_user_detail.html
+++ /dev/null
@@ -1,260 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block content %}
-
-
-
-
-
-
-
-
-
-
{{ system_user.name }}
-
-
-
-
-
-
- {% trans 'Name' %}:
- {{ system_user.name }}
-
-
- {% trans 'Username' %}:
- {% if system_user.username_same_with_user %}
- {% trans 'Username same with user' %}
- {% else %}
- {{ system_user.username }}
- {% endif %}
-
-
- {% trans 'Login mode' %}:
- {{ system_user.get_login_mode_display }}
-
-
- {% trans 'Protocol' %}:
- {{ system_user.protocol }}
-
-
- {% trans 'Sudo' %}:
- {{ system_user.sudo }}
-
- {% if system_user.shell %}
-
- {% trans 'Shell' %}:
- {{ system_user.shell }}
-
- {% endif %}
- {% if system_user.home %}
-
- {% trans 'Home' %}:
- {{ system_user.home }}
-
- {% endif %}
- {% if system_user.uid %}
-
- {% trans 'Uid' %}:
- {{ system_user.uid }}
-
- {% endif %}
-
- {% trans 'Date created' %}:
- {{ system_user.date_created }}
-
-
- {% trans 'Created by' %}:
- {{ system_user.created_by }}
-
-
- {% trans 'Comment' %}:
- {{ system_user.comment }}
-
-
-
-
-
-
-
-
-
-
- {% trans 'Quick update' %}
-
-
-
-
-
- {% trans 'Auto push' %}:
-
-
-
-
-
-
-
-
-
-
-
-
- {% if system_user.is_need_cmd_filter %}
-
-
-
- {% trans 'Command filter' %}
-
-
-
-
-
- {% for cf in object.cmd_filters.all %}
-
- {{ cf }}
-
-
-
-
- {% endfor %}
-
-
-
-
-
- {% endif %}
-
-
-
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/assets/templates/assets/system_user_list.html b/apps/assets/templates/assets/system_user_list.html
deleted file mode 100644
index b3bd556ab..000000000
--- a/apps/assets/templates/assets/system_user_list.html
+++ /dev/null
@@ -1,90 +0,0 @@
-{% extends '_base_list.html' %}
-{% load i18n %}
-
-{% block help_message %}
- {% trans 'System user is JumpServer jump login assets used by the users, can be understood as the user login assets, such as web, sa, the dba (` ssh web@some-host `), rather than using a user the username login server jump (` ssh xiaoming@some-host `); '%}
- {% trans 'In simple terms, users log into JumpServer using their own username, and JumpServer uses system users to log into assets. '%}
- {% trans 'When system users are created, if you choose auto push JumpServer to use Ansible push system users into the asset, if the asset (Switch) does not support ansible, please manually fill in the account password.' %}
-{% endblock %}
-
-{% block table_search %}
- {% include '_csv_import_export.html' %}
-{% endblock %}
-
-{% block table_container %}
-
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
-
-
-
diff --git a/apps/assets/templates/assets/system_user_update.html b/apps/assets/templates/assets/system_user_update.html
deleted file mode 100644
index 0a60d3e70..000000000
--- a/apps/assets/templates/assets/system_user_update.html
+++ /dev/null
@@ -1,22 +0,0 @@
-{% extends 'assets/_system_user.html' %}
-{% load i18n %}
-{% load static %}
-{% load bootstrap3 %}
-
-{% block auth %}
- {% bootstrap_field form.password layout="horizontal" %}
- {% bootstrap_field form.private_key layout="horizontal" %}
-
-{% endblock %}
-
-{% block formUrl %}
- var the_url = '{% url 'api-assets:system-user-detail' pk=object.pk %}';
- var redirect_to = '{% url "assets:system-user-list" %}';
- var method = "PUT";
-{% endblock %}
-
diff --git a/apps/assets/templates/assets/system_user_users.html b/apps/assets/templates/assets/system_user_users.html
deleted file mode 100644
index 59d5e0653..000000000
--- a/apps/assets/templates/assets/system_user_users.html
+++ /dev/null
@@ -1,212 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block custom_head_css_js %}
-
-{% endblock %}
-
-{% block content %}
-
-
-
-
-
-
-
-
-
-
{{ system_user.name }} {{ paginator.count }}
-
-
-
-
-
-
-
-
- {% trans 'Users' %}
-
-
-
-
-
-
-
-
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/assets/templates/assets/user_asset_list.html b/apps/assets/templates/assets/user_asset_list.html
deleted file mode 100644
index 2a8c8cf64..000000000
--- a/apps/assets/templates/assets/user_asset_list.html
+++ /dev/null
@@ -1,132 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block custom_head_css_js %}
-
-
-
-{% endblock %}
-
-{% block content %}
-
-
- {% include 'users/_granted_assets.html' %}
-
-
-
-{% include 'assets/_user_asset_detail_modal.html' %}
-{% endblock %}
-
-
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/assets/templatetags/__init__.py b/apps/assets/templatetags/__init__.py
deleted file mode 100644
index ec51c5a2b..000000000
--- a/apps/assets/templatetags/__init__.py
+++ /dev/null
@@ -1,2 +0,0 @@
-# -*- coding: utf-8 -*-
-#
diff --git a/apps/assets/templatetags/asset_tags.py b/apps/assets/templatetags/asset_tags.py
deleted file mode 100644
index 15605f835..000000000
--- a/apps/assets/templatetags/asset_tags.py
+++ /dev/null
@@ -1,12 +0,0 @@
-from collections import defaultdict
-
-from django import template
-register = template.Library()
-
-
-@register.filter
-def group_labels(queryset):
- grouped = defaultdict(list)
- for label in queryset:
- grouped[label.name].append(label)
- return [(name, labels) for name, labels in grouped.items()]
diff --git a/apps/assets/urls/views_urls.py b/apps/assets/urls/views_urls.py
index 25b6deefd..d9832e041 100644
--- a/apps/assets/urls/views_urls.py
+++ b/apps/assets/urls/views_urls.py
@@ -1,66 +1,6 @@
# coding:utf-8
-from django.urls import path
-from .. import views
app_name = 'assets'
urlpatterns = [
- # Resource asset url
- path('', views.AssetListView.as_view(), name='asset-index'),
- path('asset/', views.AssetListView.as_view(), name='asset-list'),
- path('asset/create/', views.AssetCreateView.as_view(), name='asset-create'),
- path('asset//', views.AssetDetailView.as_view(), name='asset-detail'),
- path('asset//update/', views.AssetUpdateView.as_view(), name='asset-update'),
- path('asset//delete/', views.AssetDeleteView.as_view(), name='asset-delete'),
- path('asset/update/', views.AssetBulkUpdateView.as_view(), name='asset-bulk-update'),
- # Asset user view
- path('asset//asset-user/', views.AssetUserListView.as_view(), name='asset-user-list'),
-
- path('platform/', views.PlatformListView.as_view(), name='platform-list'),
- path('platform/create/', views.PlatformCreateView.as_view(), name='platform-create'),
- path('platform//', views.PlatformDetailView.as_view(), name='platform-detail'),
- path('platform//update/', views.PlatformUpdateView.as_view(), name='platform-update'),
-
- # User asset view
- path('user-asset/', views.UserAssetListView.as_view(), name='user-asset-list'),
-
- # Resource admin user url
- path('admin-user/', views.AdminUserListView.as_view(), name='admin-user-list'),
- path('admin-user/create/', views.AdminUserCreateView.as_view(), name='admin-user-create'),
- path('admin-user//', views.AdminUserDetailView.as_view(), name='admin-user-detail'),
- path('admin-user//update/', views.AdminUserUpdateView.as_view(), name='admin-user-update'),
- path('admin-user//delete/', views.AdminUserDeleteView.as_view(), name='admin-user-delete'),
- path('admin-user//assets/', views.AdminUserAssetsView.as_view(), name='admin-user-assets'),
-
- # Resource system user url
- path('system-user/', views.SystemUserListView.as_view(), name='system-user-list'),
- path('system-user/create/', views.SystemUserCreateView.as_view(), name='system-user-create'),
- path('system-user//', views.SystemUserDetailView.as_view(), name='system-user-detail'),
- path('system-user//update/', views.SystemUserUpdateView.as_view(), name='system-user-update'),
- path('system-user//delete/', views.SystemUserDeleteView.as_view(), name='system-user-delete'),
- path('system-user//asset/', views.SystemUserAssetView.as_view(), name='system-user-asset'),
- path('system-user//user/', views.SystemUserUserView.as_view(), name='system-user-user'),
-
- path('label/', views.LabelListView.as_view(), name='label-list'),
- path('label/create/', views.LabelCreateView.as_view(), name='label-create'),
- path('label//update/', views.LabelUpdateView.as_view(), name='label-update'),
- path('label//delete/', views.LabelDeleteView.as_view(), name='label-delete'),
-
- path('domain/', views.DomainListView.as_view(), name='domain-list'),
- path('domain/create/', views.DomainCreateView.as_view(), name='domain-create'),
- path('domain//', views.DomainDetailView.as_view(), name='domain-detail'),
- path('domain//update/', views.DomainUpdateView.as_view(), name='domain-update'),
- path('domain//delete/', views.DomainDeleteView.as_view(), name='domain-delete'),
- path('domain//gateway/', views.DomainGatewayListView.as_view(), name='domain-gateway-list'),
-
- path('domain//gateway/create/', views.DomainGatewayCreateView.as_view(), name='domain-gateway-create'),
- path('domain/gateway//update/', views.DomainGatewayUpdateView.as_view(), name='domain-gateway-update'),
-
- path('cmd-filter/', views.CommandFilterListView.as_view(), name='cmd-filter-list'),
- path('cmd-filter/create/', views.CommandFilterCreateView.as_view(), name='cmd-filter-create'),
- path('cmd-filter//update/', views.CommandFilterUpdateView.as_view(), name='cmd-filter-update'),
- path('cmd-filter//', views.CommandFilterDetailView.as_view(), name='cmd-filter-detail'),
- path('cmd-filter//rule/', views.CommandFilterRuleListView.as_view(), name='cmd-filter-rule-list'),
- path('cmd-filter//rule/create/', views.CommandFilterRuleCreateView.as_view(), name='cmd-filter-rule-create'),
- path('cmd-filter//rule//update/', views.CommandFilterRuleUpdateView.as_view(), name='cmd-filter-rule-update'),
]
diff --git a/apps/assets/views/__init__.py b/apps/assets/views/__init__.py
deleted file mode 100644
index 74055a76c..000000000
--- a/apps/assets/views/__init__.py
+++ /dev/null
@@ -1,8 +0,0 @@
-# coding:utf-8
-from .asset import *
-from .platform import *
-from .system_user import *
-from .admin_user import *
-from .label import *
-from .domain import *
-from .cmd_filter import *
diff --git a/apps/assets/views/admin_user.py b/apps/assets/views/admin_user.py
deleted file mode 100644
index 611b03d7d..000000000
--- a/apps/assets/views/admin_user.py
+++ /dev/null
@@ -1,121 +0,0 @@
-# coding:utf-8
-from __future__ import absolute_import, unicode_literals
-from django.utils.translation import ugettext as _
-from django.conf import settings
-from django.urls import reverse_lazy
-from django.views.generic import TemplateView, ListView
-from django.views.generic.edit import CreateView, DeleteView, UpdateView
-from django.contrib.messages.views import SuccessMessageMixin
-from django.views.generic.detail import DetailView, SingleObjectMixin
-
-from common.const import create_success_msg, update_success_msg
-from .. import forms
-from ..models import AdminUser, Node
-from common.permissions import PermissionsMixin, IsOrgAdmin
-
-__all__ = [
- 'AdminUserCreateView', 'AdminUserDetailView',
- 'AdminUserDeleteView', 'AdminUserListView',
- 'AdminUserUpdateView', 'AdminUserAssetsView',
-]
-
-
-class AdminUserListView(PermissionsMixin, TemplateView):
- model = AdminUser
- template_name = 'assets/admin_user_list.html'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Assets'),
- 'action': _('Admin user list'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class AdminUserCreateView(PermissionsMixin,
- SuccessMessageMixin,
- CreateView):
- model = AdminUser
- form_class = forms.AdminUserForm
- template_name = 'assets/admin_user_create_update.html'
- success_url = reverse_lazy('assets:admin-user-list')
- success_message = create_success_msg
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Assets'),
- 'action': _('Create admin user'),
- "type": "create"
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class AdminUserUpdateView(PermissionsMixin, SuccessMessageMixin, UpdateView):
- model = AdminUser
- form_class = forms.AdminUserForm
- template_name = 'assets/admin_user_create_update.html'
- success_url = reverse_lazy('assets:admin-user-list')
- success_message = update_success_msg
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Assets'),
- 'action': _('Update admin user'),
- "type": "update"
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class AdminUserDetailView(PermissionsMixin, DetailView):
- model = AdminUser
- template_name = 'assets/admin_user_detail.html'
- context_object_name = 'admin_user'
- object = None
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Assets'),
- 'action': _('Admin user detail'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class AdminUserAssetsView(PermissionsMixin, SingleObjectMixin, ListView):
- paginate_by = settings.DISPLAY_PER_PAGE
- template_name = 'assets/admin_user_assets.html'
- context_object_name = 'admin_user'
- object = None
- permission_classes = [IsOrgAdmin]
-
- def get(self, request, *args, **kwargs):
- self.object = self.get_object(queryset=AdminUser.objects.all())
- return super().get(request, *args, **kwargs)
-
- def get_queryset(self):
- self.queryset = self.object.assets.all()
- return self.queryset
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Assets'),
- 'action': _('Admin user assets'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class AdminUserDeleteView(PermissionsMixin, DeleteView):
- model = AdminUser
- template_name = 'delete_confirm.html'
- success_url = reverse_lazy('assets:admin-user-list')
- permission_classes = [IsOrgAdmin]
-
-
diff --git a/apps/assets/views/asset.py b/apps/assets/views/asset.py
deleted file mode 100644
index 63179f4f8..000000000
--- a/apps/assets/views/asset.py
+++ /dev/null
@@ -1,203 +0,0 @@
-# coding:utf-8
-from __future__ import absolute_import, unicode_literals
-
-from django.contrib import messages
-from django.utils.translation import ugettext_lazy as _
-from django.views.generic import TemplateView, ListView
-from django.views.generic.edit import FormMixin
-from django.views.generic.edit import DeleteView, UpdateView
-from django.urls import reverse_lazy
-from django.views.generic.detail import DetailView
-from django.core.cache import cache
-from django.shortcuts import redirect
-from django.forms.formsets import formset_factory
-
-from common.utils import get_object_or_none, get_logger
-from common.permissions import PermissionsMixin, IsOrgAdmin, IsValidUser
-from common.const import KEY_CACHE_RESOURCES_ID
-from .. import forms
-from ..models import Asset, Label, Node
-
-
-__all__ = [
- 'AssetListView', 'AssetCreateView', 'AssetUpdateView', 'AssetUserListView',
- 'UserAssetListView', 'AssetBulkUpdateView', 'AssetDetailView',
- 'AssetDeleteView',
-]
-logger = get_logger(__file__)
-
-
-class AssetListView(PermissionsMixin, TemplateView):
- template_name = 'assets/asset_list.html'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- Node.org_root()
- context = {
- 'app': _('Assets'),
- 'action': _('Asset list'),
- 'labels': Label.objects.all().order_by('name'),
- 'nodes': Node.objects.all().order_by('-key'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class AssetUserListView(PermissionsMixin, DetailView):
- model = Asset
- context_object_name = 'asset'
- template_name = 'assets/asset_asset_user_list.html'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Assets'),
- 'action': _('Asset user list'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class UserAssetListView(PermissionsMixin, TemplateView):
- template_name = 'assets/user_asset_list.html'
- permission_classes = [IsValidUser]
-
- def get_context_data(self, **kwargs):
- context = {
- 'action': _('My assets'),
- 'labels': Label.objects.all().order_by('name'),
- 'show_actions': True
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class AssetCreateView(PermissionsMixin, FormMixin, TemplateView):
- model = Asset
- form_class = forms.AssetCreateUpdateForm
- template_name = 'assets/asset_create.html'
- success_url = reverse_lazy('assets:asset-list')
- permission_classes = [IsOrgAdmin]
-
- def get_form(self, form_class=None):
- form = super().get_form(form_class=form_class)
- node_id = self.request.GET.get("node_id")
- if node_id:
- node = get_object_or_none(Node, id=node_id)
- else:
- node = Node.org_root()
- form.add_nodes_initial(node)
- return form
-
- def get_protocol_formset(self):
- ProtocolFormset = formset_factory(forms.ProtocolForm, extra=0, min_num=1, max_num=5)
- if self.request.method == "POST":
- formset = ProtocolFormset(self.request.POST)
- else:
- formset = ProtocolFormset()
- return formset
-
- def get_context_data(self, **kwargs):
- formset = self.get_protocol_formset()
- context = {
- 'app': _('Assets'),
- 'action': _('Create asset'),
- 'formset': formset,
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class AssetUpdateView(PermissionsMixin, UpdateView):
- model = Asset
- form_class = forms.AssetCreateUpdateForm
- template_name = 'assets/asset_update.html'
- success_url = reverse_lazy('assets:asset-list')
- permission_classes = [IsOrgAdmin]
-
- def get_protocol_formset(self):
- ProtocolFormset = formset_factory(forms.ProtocolForm, extra=0, min_num=1, max_num=5)
- if self.request.method == "POST":
- formset = ProtocolFormset(self.request.POST)
- else:
- initial_data = self.object.protocols_as_json
- formset = ProtocolFormset(initial=initial_data)
- return formset
-
- def get_context_data(self, **kwargs):
- formset = self.get_protocol_formset()
- context = {
- 'app': _('Assets'),
- 'action': _('Update asset'),
- 'formset': formset,
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class AssetBulkUpdateView(PermissionsMixin, ListView):
- model = Asset
- form_class = forms.AssetBulkUpdateForm
- template_name = 'assets/asset_bulk_update.html'
- success_url = reverse_lazy('assets:asset-list')
- success_message = _("Bulk update asset success")
- id_list = None
- form = None
- permission_classes = [IsOrgAdmin]
-
- def get(self, request, *args, **kwargs):
- spm = request.GET.get('spm', '')
- assets_id = cache.get(KEY_CACHE_RESOURCES_ID.format(spm))
- if kwargs.get('form'):
- self.form = kwargs['form']
- elif assets_id:
- self.form = self.form_class(initial={'assets': assets_id})
- else:
- self.form = self.form_class()
- return super().get(request, *args, **kwargs)
-
- def post(self, request, *args, **kwargs):
- form = self.form_class(request.POST)
- if form.is_valid():
- form.save()
- messages.success(request, self.success_message)
- return redirect(self.success_url)
- else:
- return self.get(request, form=form, *args, **kwargs)
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Assets'),
- 'action': _('Bulk update asset'),
- 'form': self.form,
- 'assets_selected': self.id_list,
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class AssetDeleteView(PermissionsMixin, DeleteView):
- model = Asset
- template_name = 'delete_confirm.html'
- success_url = reverse_lazy('assets:asset-list')
- permission_classes = [IsOrgAdmin]
-
-
-class AssetDetailView(PermissionsMixin, DetailView):
- model = Asset
- context_object_name = 'asset'
- template_name = 'assets/asset_detail.html'
- permission_classes = [IsValidUser]
-
- def get_queryset(self):
- return super().get_queryset().prefetch_related(
- "nodes", "labels",
- ).select_related('admin_user', 'domain')
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Assets'),
- 'action': _('Asset detail'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
diff --git a/apps/assets/views/cmd_filter.py b/apps/assets/views/cmd_filter.py
deleted file mode 100644
index 530f4193b..000000000
--- a/apps/assets/views/cmd_filter.py
+++ /dev/null
@@ -1,180 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-
-from django.views.generic import TemplateView, CreateView, \
- UpdateView, DeleteView, DetailView
-from django.views.generic.detail import SingleObjectMixin
-from django.utils.translation import ugettext_lazy as _
-from django.urls import reverse_lazy
-from django.shortcuts import get_object_or_404, reverse
-
-from common.permissions import PermissionsMixin, IsOrgAdmin
-from common.const import create_success_msg, update_success_msg
-from ..models import CommandFilter, CommandFilterRule, SystemUser
-from ..forms import CommandFilterForm, CommandFilterRuleForm
-
-
-__all__ = (
- "CommandFilterListView", "CommandFilterCreateView",
- "CommandFilterUpdateView",
- "CommandFilterRuleListView", "CommandFilterRuleCreateView",
- "CommandFilterRuleUpdateView", "CommandFilterDetailView",
-)
-
-
-class CommandFilterListView(PermissionsMixin, TemplateView):
- template_name = 'assets/cmd_filter_list.html'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Assets'),
- 'action': _('Command filter list'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class CommandFilterCreateView(PermissionsMixin, CreateView):
- model = CommandFilter
- template_name = 'assets/cmd_filter_create_update.html'
- form_class = CommandFilterForm
- success_url = reverse_lazy('assets:cmd-filter-list')
- success_message = create_success_msg
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Assets'),
- 'action': _('Create command filter'),
- 'type': 'create'
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class CommandFilterUpdateView(PermissionsMixin, UpdateView):
- model = CommandFilter
- template_name = 'assets/cmd_filter_create_update.html'
- form_class = CommandFilterForm
- success_url = reverse_lazy('assets:cmd-filter-list')
- success_message = update_success_msg
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Assets'),
- 'action': _('Update command filter'),
- 'type': 'update'
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class CommandFilterDetailView(PermissionsMixin, DetailView):
- model = CommandFilter
- template_name = 'assets/cmd_filter_detail.html'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- system_users_remain = SystemUser.objects\
- .exclude(cmd_filters=self.object)\
- .exclude(protocol='rdp')
- context = {
- 'app': _('Assets'),
- 'action': _('Command filter detail'),
- 'system_users_remain': system_users_remain
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class CommandFilterRuleListView(PermissionsMixin, SingleObjectMixin, TemplateView):
- template_name = 'assets/cmd_filter_rule_list.html'
- model = CommandFilter
- object = None
- permission_classes = [IsOrgAdmin]
-
- def get(self, request, *args, **kwargs):
- self.object = self.get_object(queryset=self.model.objects.all())
- return super().get(request, *args, **kwargs)
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Assets'),
- 'action': _('Command filter rule list'),
- 'object': self.get_object()
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class CommandFilterRuleCreateView(PermissionsMixin, CreateView):
- template_name = 'assets/cmd_filter_rule_create_update.html'
- model = CommandFilterRule
- form_class = CommandFilterRuleForm
- success_message = create_success_msg
- cmd_filter = None
- permission_classes = [IsOrgAdmin]
-
- def get_success_url(self):
- return reverse('assets:cmd-filter-rule-list', kwargs={
- 'pk': self.cmd_filter.id
- })
-
- def get_form(self, form_class=None):
- form = super().get_form(form_class=form_class)
- form['filter'].initial = self.cmd_filter
- form['filter'].field.widget.attrs['readonly'] = 1
- return form
-
- def dispatch(self, request, *args, **kwargs):
- filter_pk = self.kwargs.get('filter_pk')
- self.cmd_filter = get_object_or_404(CommandFilter, pk=filter_pk)
- return super().dispatch(request, *args, **kwargs)
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Assets'),
- 'action': _('Create command filter rule'),
- 'object': self.cmd_filter,
- 'request_type': 'create'
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class CommandFilterRuleUpdateView(PermissionsMixin, UpdateView):
- template_name = 'assets/cmd_filter_rule_create_update.html'
- model = CommandFilterRule
- form_class = CommandFilterRuleForm
- success_message = create_success_msg
- cmd_filter = None
- permission_classes = [IsOrgAdmin]
-
- def get_success_url(self):
- return reverse('assets:cmd-filter-rule-list', kwargs={
- 'pk': self.cmd_filter.id
- })
-
- def get_form(self, form_class=None):
- form = super().get_form(form_class=form_class)
- form['filter'].initial = self.cmd_filter
- form['filter'].field.widget.attrs['readonly'] = 1
- return form
-
- def dispatch(self, request, *args, **kwargs):
- filter_pk = self.kwargs.get('filter_pk')
- self.cmd_filter = get_object_or_404(CommandFilter, pk=filter_pk)
- return super().dispatch(request, *args, **kwargs)
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Assets'),
- 'action': _('Update command filter rule'),
- 'object': self.cmd_filter,
- 'rule': self.get_object(),
- 'request_type': 'update'
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
\ No newline at end of file
diff --git a/apps/assets/views/domain.py b/apps/assets/views/domain.py
deleted file mode 100644
index ad7fad1b6..000000000
--- a/apps/assets/views/domain.py
+++ /dev/null
@@ -1,162 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-
-from django.views.generic import (
- TemplateView, CreateView, UpdateView, DeleteView, DetailView
-)
-from django.views.generic.detail import SingleObjectMixin
-from django.utils.translation import ugettext_lazy as _
-from django.urls import reverse_lazy, reverse
-
-from common.permissions import PermissionsMixin, IsOrgAdmin
-from common.const import create_success_msg, update_success_msg
-from common.utils import get_object_or_none
-from ..models import Domain, Gateway
-from ..forms import DomainForm, GatewayForm
-
-
-__all__ = (
- "DomainListView", "DomainCreateView", "DomainUpdateView",
- "DomainDetailView", "DomainDeleteView", "DomainGatewayListView",
- "DomainGatewayCreateView", 'DomainGatewayUpdateView',
-)
-
-
-class DomainListView(PermissionsMixin, TemplateView):
- template_name = 'assets/domain_list.html'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Assets'),
- 'action': _('Domain list'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class DomainCreateView(PermissionsMixin, CreateView):
- model = Domain
- template_name = 'assets/domain_create_update.html'
- form_class = DomainForm
- success_url = reverse_lazy('assets:domain-list')
- success_message = create_success_msg
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Assets'),
- 'action': _('Create domain'),
- 'type': 'create'
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class DomainUpdateView(PermissionsMixin, UpdateView):
- model = Domain
- template_name = 'assets/domain_create_update.html'
- form_class = DomainForm
- success_url = reverse_lazy('assets:domain-list')
- success_message = update_success_msg
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Assets'),
- 'action': _('Update domain'),
- 'type': 'update'
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class DomainDetailView(PermissionsMixin, DetailView):
- model = Domain
- template_name = 'assets/domain_detail.html'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Assets'),
- 'action': _('Domain detail'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class DomainDeleteView(PermissionsMixin, DeleteView):
- model = Domain
- template_name = 'delete_confirm.html'
- success_url = reverse_lazy('assets:domain-list')
- permission_classes = [IsOrgAdmin]
-
-
-class DomainGatewayListView(PermissionsMixin, SingleObjectMixin, TemplateView):
- template_name = 'assets/domain_gateway_list.html'
- model = Domain
- object = None
- permission_classes = [IsOrgAdmin]
-
- def get(self, request, *args, **kwargs):
- self.object = self.get_object(queryset=self.model.objects.all())
- return super().get(request, *args, **kwargs)
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Assets'),
- 'action': _('Domain gateway list'),
- 'object': self.get_object()
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class DomainGatewayCreateView(PermissionsMixin, CreateView):
- model = Gateway
- template_name = 'assets/gateway_create_update.html'
- form_class = GatewayForm
- success_message = create_success_msg
- permission_classes = [IsOrgAdmin]
-
- def get_success_url(self):
- domain = self.object.domain
- return reverse('assets:domain-gateway-list', kwargs={"pk": domain.id})
-
- def get_form(self, form_class=None):
- form = super().get_form(form_class=form_class)
- domain_id = self.kwargs.get("pk")
- domain = get_object_or_none(Domain, id=domain_id)
- if domain:
- form['domain'].initial = domain
- return form
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Assets'),
- 'action': _('Create gateway'),
- 'type': 'create'
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class DomainGatewayUpdateView(PermissionsMixin, UpdateView):
- model = Gateway
- template_name = 'assets/gateway_create_update.html'
- form_class = GatewayForm
- success_message = update_success_msg
- permission_classes = [IsOrgAdmin]
-
- def get_success_url(self):
- domain = self.object.domain
- return reverse('assets:domain-gateway-list', kwargs={"pk": domain.id})
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Assets'),
- 'action': _('Update gateway'),
- "type": "update"
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
diff --git a/apps/assets/views/label.py b/apps/assets/views/label.py
deleted file mode 100644
index 522962ce3..000000000
--- a/apps/assets/views/label.py
+++ /dev/null
@@ -1,89 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-
-from django.views.generic import TemplateView, CreateView, \
- UpdateView, DeleteView, DetailView
-from django.utils.translation import ugettext_lazy as _
-from django.urls import reverse_lazy
-
-from common.permissions import PermissionsMixin, IsOrgAdmin
-from common.const import create_success_msg, update_success_msg
-from ..models import Label
-from ..forms import LabelForm
-
-
-__all__ = (
- "LabelListView", "LabelCreateView", "LabelUpdateView",
- "LabelDetailView", "LabelDeleteView",
-)
-
-
-class LabelListView(PermissionsMixin, TemplateView):
- template_name = 'assets/label_list.html'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Assets'),
- 'action': _('Label list'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class LabelCreateView(PermissionsMixin, CreateView):
- model = Label
- template_name = 'assets/label_create_update.html'
- form_class = LabelForm
- success_url = reverse_lazy('assets:label-list')
- success_message = create_success_msg
- disable_name = ['draw', 'search', 'limit', 'offset', '_']
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Assets'),
- 'action': _('Create label'),
- 'type': 'create'
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
- def form_valid(self, form):
- name = form.cleaned_data.get('name')
- if name in self.disable_name:
- msg = _(
- 'Tips: Avoid using label names reserved internally: {}'
- ).format(', '.join(self.disable_name))
- form.add_error("name", msg)
- return self.form_invalid(form)
- return super().form_valid(form)
-
-
-class LabelUpdateView(PermissionsMixin, UpdateView):
- model = Label
- template_name = 'assets/label_create_update.html'
- form_class = LabelForm
- success_url = reverse_lazy('assets:label-list')
- success_message = update_success_msg
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Assets'),
- 'action': _('Update label'),
- 'type': 'update'
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class LabelDetailView(PermissionsMixin, DetailView):
- pass
-
-
-class LabelDeleteView(PermissionsMixin, DeleteView):
- model = Label
- template_name = 'delete_confirm.html'
- success_url = reverse_lazy('assets:label-list')
- permission_classes = [IsOrgAdmin]
diff --git a/apps/assets/views/platform.py b/apps/assets/views/platform.py
deleted file mode 100644
index 8c74da138..000000000
--- a/apps/assets/views/platform.py
+++ /dev/null
@@ -1,77 +0,0 @@
-# -*- coding: utf-8 -*-
-from django.views import generic
-from django.utils.translation import ugettext as _
-
-from common.permissions import PermissionsMixin, IsSuperUser
-from ..models import Platform
-from ..forms import PlatformForm, PlatformMetaForm
-
-__all__ = [
- 'PlatformListView', 'PlatformUpdateView', 'PlatformCreateView',
- 'PlatformDetailView',
-]
-
-
-class PlatformListView(PermissionsMixin, generic.TemplateView):
- template_name = 'assets/platform_list.html'
- permission_classes = (IsSuperUser,)
-
- def get_context_data(self, **kwargs):
- context = super().get_context_data(**kwargs)
- context.update({
- 'app': _('Assets'),
- 'action': _("Platform list"),
- })
- return context
-
-
-class PlatformCreateView(PermissionsMixin, generic.CreateView):
- form_class = PlatformForm
- permission_classes = (IsSuperUser,)
- template_name = 'assets/platform_create_update.html'
- model = Platform
-
- def get_context_data(self, **kwargs):
- context = super().get_context_data(**kwargs)
- meta_form = PlatformMetaForm()
- context.update({
- 'app': _('Assets'),
- 'action': _("Create platform"),
- 'meta_form': meta_form,
- })
- return context
-
-
-class PlatformUpdateView(generic.UpdateView):
- form_class = PlatformForm
- permission_classes = (IsSuperUser,)
- model = Platform
- template_name = 'assets/platform_create_update.html'
-
- def post(self, *args, **kwargs):
- pass
-
- def get_context_data(self, **kwargs):
- context = super().get_context_data(**kwargs)
- meta_form = PlatformMetaForm(initial=self.object.meta)
- context.update({
- 'app': _('Assets'),
- 'action': _("Update platform"),
- 'type': 'update',
- 'meta_form': meta_form,
- })
- return context
-
-
-class PlatformDetailView(generic.DetailView):
- permission_classes = (IsSuperUser,)
- model = Platform
- template_name = 'assets/platform_detail.html'
-
- def get_context_data(self, **kwargs):
- context = super().get_context_data(**kwargs)
- context.update({
- 'app': _('Assets'),
- 'action': _("Platform detail"),
- })
- return context
diff --git a/apps/assets/views/system_user.py b/apps/assets/views/system_user.py
deleted file mode 100644
index 5aa1e8431..000000000
--- a/apps/assets/views/system_user.py
+++ /dev/null
@@ -1,122 +0,0 @@
-# ~*~ coding: utf-8 ~*~
-
-from django.utils.translation import ugettext as _
-from django.views.generic import TemplateView
-from django.views.generic.edit import CreateView, DeleteView, UpdateView
-from django.urls import reverse_lazy
-from django.contrib.messages.views import SuccessMessageMixin
-from django.views.generic.detail import DetailView
-
-from common.const import create_success_msg, update_success_msg
-from ..forms import SystemUserForm
-from ..models import SystemUser, Node, CommandFilter
-from common.permissions import PermissionsMixin, IsOrgAdmin
-
-
-__all__ = [
- 'SystemUserCreateView', 'SystemUserUpdateView',
- 'SystemUserDetailView', 'SystemUserDeleteView',
- 'SystemUserAssetView', 'SystemUserListView',
- 'SystemUserUserView',
-]
-
-
-class SystemUserListView(PermissionsMixin, TemplateView):
- template_name = 'assets/system_user_list.html'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Assets'),
- 'action': _('System user list'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class SystemUserCreateView(PermissionsMixin, SuccessMessageMixin, CreateView):
- model = SystemUser
- form_class = SystemUserForm
- template_name = 'assets/system_user_create.html'
- success_url = reverse_lazy('assets:system-user-list')
- success_message = create_success_msg
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Assets'),
- 'action': _('Create system user'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class SystemUserUpdateView(PermissionsMixin, SuccessMessageMixin, UpdateView):
- model = SystemUser
- form_class = SystemUserForm
- template_name = 'assets/system_user_update.html'
- success_url = reverse_lazy('assets:system-user-list')
- success_message = update_success_msg
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Assets'),
- 'action': _('Update system user')
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class SystemUserDetailView(PermissionsMixin, DetailView):
- template_name = 'assets/system_user_detail.html'
- context_object_name = 'system_user'
- model = SystemUser
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- cmd_filters_remain = CommandFilter.objects.exclude(system_users=self.object)
- context = {
- 'app': _('Assets'),
- 'action': _('System user detail'),
- 'cmd_filters_remain': cmd_filters_remain,
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class SystemUserDeleteView(PermissionsMixin, DeleteView):
- model = SystemUser
- template_name = 'delete_confirm.html'
- success_url = reverse_lazy('assets:system-user-list')
- permission_classes = [IsOrgAdmin]
-
-
-class SystemUserAssetView(PermissionsMixin, DetailView):
- model = SystemUser
- template_name = 'assets/system_user_assets.html'
- context_object_name = 'system_user'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('assets'),
- 'action': _('System user assets'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class SystemUserUserView(PermissionsMixin, DetailView):
- model = SystemUser
- template_name = 'assets/system_user_users.html'
- context_object_name = 'system_user'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('assets'),
- 'action': _('System user users'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
diff --git a/apps/audits/templates/audits/ftp_log_list.html b/apps/audits/templates/audits/ftp_log_list.html
deleted file mode 100644
index e0399ca73..000000000
--- a/apps/audits/templates/audits/ftp_log_list.html
+++ /dev/null
@@ -1,138 +0,0 @@
-{% extends '_base_list.html' %}
-{% load i18n %}
-{% load static %}
-{% load terminal_tags %}
-{% load common_tags %}
-{% block custom_head_css_js %}
-
-
-{% endblock %}
-
-{% block content_left_head %}
-{% endblock %}
-
-
-{% block table_search %}
-
-{% endblock %}
-
-{% block table_head %}
-{# {% trans 'ID' %} #}
- {% trans 'User' %}
- {% trans 'Asset' %}
- {% trans 'System user' %}
- {% trans 'Remote addr' %}
- {% trans 'Operate' %}
- {% trans 'Filename' %}
- {% trans 'Success' %}
- {% trans 'Date start' %}
-{# {% trans 'Action' %} #}
-{% endblock %}
-
-{% block table_body %}
- {% for object in object_list %}
-
-{# #}
-{# {{ forloop.counter }} #}
-{# #}
- {{ object.user }}
- {{ object.asset }}
- {{ object.system_user }}
- {{ object.remote_addr|default:"" }}
- {{ object.operate }}
- {{ object.filename }}
-
- {% if object.is_success %}
-
- {% else %}
-
- {% endif %}
-
- {{ object.date_start }}
-
- {% endfor %}
-{% endblock %}
-
-{% block content_bottom_left %}
-{% endblock %}
-
-{% block custom_foot_js %}
-
-
-{% endblock %}
-
diff --git a/apps/audits/templates/audits/login_log_list.html b/apps/audits/templates/audits/login_log_list.html
deleted file mode 100644
index 1ac74d311..000000000
--- a/apps/audits/templates/audits/login_log_list.html
+++ /dev/null
@@ -1,148 +0,0 @@
-{% extends '_base_list.html' %}
-{% load i18n %}
-{% load static %}
-{% load common_tags %}
-{% block content_left_head %}
-
-
-{% endblock %}
-
-
-{% block table_search %}
-
-{% endblock %}
-{% block table_container %}
-
-
-
- {% trans 'ID' %}
- {% trans 'Username' %}
- {% trans 'Type' %}
- {% trans 'UA' %}
- {% trans 'IP' %}
- {% trans 'City' %}
- {% trans 'MFA' %}
- {% trans 'Reason' %}
- {% trans 'Status' %}
- {% trans 'Date' %}
-
-
-
-
- {% for login_log in object_list %}
-
- {{ forloop.counter }}
- {{ login_log.username }}
- {{ login_log.get_type_display }}
-
- {{ login_log.user_agent | truncatechars:20 }}
-
- {{ login_log.ip }}
- {{ login_log.city }}
- {{ login_log.get_mfa_display }}
- {{ login_log.reason_display }}
- {{ login_log.get_status_display }}
- {{ login_log.datetime }}
-
- {% endfor %}
-
-
-
-
-{% endblock %}
-
-
-{% block custom_foot_js %}
-
-
-{% endblock %}
-
diff --git a/apps/audits/templates/audits/operate_log_list.html b/apps/audits/templates/audits/operate_log_list.html
deleted file mode 100644
index 0dd8c8ff4..000000000
--- a/apps/audits/templates/audits/operate_log_list.html
+++ /dev/null
@@ -1,123 +0,0 @@
-{% extends '_base_list.html' %}
-{% load i18n %}
-{% load static %}
-{% load terminal_tags %}
-{% load common_tags %}
-{% block custom_head_css_js %}
-
-
-{% endblock %}
-
-{% block content_left_head %}
-{% endblock %}
-
-
-{% block table_search %}
-
-{% endblock %}
-
-{% block table_head %}
- {% trans 'Handlers' %}
- {% trans 'Action' %}
- {% trans 'Resource Type' %}
- {% trans 'Resource' %}
- {% trans 'Remote addr' %}
- {% trans 'Datetime' %}
-{% endblock %}
-
-{% block table_body %}
- {% for object in object_list %}
-
-{# #}
-{# {{ forloop.counter }} #}
-{# #}
- {{ object.user }}
- {{ object.get_action_display }}
- {{ object.resource_type }}
- {{ object.resource }}
- {{ object.remote_addr }}
- {{ object.datetime }}
-
- {% endfor %}
-{% endblock %}
-
-{% block content_bottom_left %}
-{% endblock %}
-
-{% block custom_foot_js %}
-
-
-{% endblock %}
-
diff --git a/apps/audits/templates/audits/password_change_log_list.html b/apps/audits/templates/audits/password_change_log_list.html
deleted file mode 100644
index 506366cbf..000000000
--- a/apps/audits/templates/audits/password_change_log_list.html
+++ /dev/null
@@ -1,100 +0,0 @@
-{% extends '_base_list.html' %}
-{% load i18n %}
-{% load static %}
-{% load terminal_tags %}
-{% load common_tags %}
-{% block custom_head_css_js %}
-
-
-{% endblock %}
-
-{% block content_left_head %}
-{% endblock %}
-
-
-{% block table_search %}
-
-{% endblock %}
-
-{% block table_head %}
- {% trans 'User' %}
- {% trans 'Change by' %}
- {% trans 'Remote addr' %}
- {% trans 'Datetime' %}
-{% endblock %}
-
-{% block table_body %}
- {% for object in object_list %}
-
- {{ object.user }}
- {{ object.change_by }}
- {{ object.remote_addr }}
- {{ object.datetime }}
-
- {% endfor %}
-{% endblock %}
-
-{% block content_bottom_left %}
-{% endblock %}
-
-{% block custom_foot_js %}
-
-
-{% endblock %}
-
diff --git a/apps/audits/urls/view_urls.py b/apps/audits/urls/view_urls.py
index ef400cb99..2066db771 100644
--- a/apps/audits/urls/view_urls.py
+++ b/apps/audits/urls/view_urls.py
@@ -2,17 +2,10 @@
from __future__ import unicode_literals
from django.urls import path
-from .. import views
__all__ = ["urlpatterns"]
app_name = "audits"
urlpatterns = [
- path('login-log/', views.LoginLogListView.as_view(), name='login-log-list'),
- path('ftp-log/', views.FTPLogListView.as_view(), name='ftp-log-list'),
- path('operate-log/', views.OperateLogListView.as_view(), name='operate-log-list'),
- path('password-change-log/', views.PasswordChangeLogList.as_view(), name='password-change-log-list'),
- path('command-execution-log/', views.CommandExecutionListView.as_view(), name='command-execution-log-list'),
- path('login-log/export/', views.LoginLogExportView.as_view(), name='login-log-export'),
]
diff --git a/apps/audits/views.py b/apps/audits/views.py
deleted file mode 100644
index 6ac0b1b99..000000000
--- a/apps/audits/views.py
+++ /dev/null
@@ -1,292 +0,0 @@
-import csv
-import json
-import uuid
-import codecs
-
-
-from django.conf import settings
-from django.urls import reverse
-from django.utils import timezone
-from django.core.cache import cache
-from django.http import HttpResponse, JsonResponse
-from django.utils.decorators import method_decorator
-from django.views import View
-from django.views.decorators.csrf import csrf_exempt
-from django.views.generic import ListView
-from django.utils.translation import ugettext as _
-from django.db.models import Q
-
-from audits.utils import get_excel_response, write_content_to_excel
-from common.mixins import DatetimeSearchMixin
-from common.permissions import (
- PermissionsMixin, IsOrgAdmin, IsValidUser, IsOrgAuditor
-)
-from orgs.utils import current_org
-from ops.views import CommandExecutionListView as UserCommandExecutionListView
-from .models import FTPLog, OperateLog, PasswordChangeLog, UserLoginLog
-
-
-def get_resource_type_list():
- from users.models import User, UserGroup
- from assets.models import (
- Asset, Node, AdminUser, SystemUser, Domain, Gateway, CommandFilter,
- CommandFilterRule,
- )
- from orgs.models import Organization
- from perms.models import AssetPermission
-
- models = [
- User, UserGroup, Asset, Node, AdminUser, SystemUser, Domain,
- Gateway, Organization, AssetPermission, CommandFilter, CommandFilterRule
- ]
- return [model._meta.verbose_name for model in models]
-
-
-class FTPLogListView(PermissionsMixin, DatetimeSearchMixin, ListView):
- model = FTPLog
- template_name = 'audits/ftp_log_list.html'
- paginate_by = settings.DISPLAY_PER_PAGE
- user = asset = system_user = filename = ''
- date_from = date_to = None
- permission_classes = [IsOrgAdmin | IsOrgAuditor]
-
- def get_queryset(self):
- self.queryset = super().get_queryset()
- self.user = self.request.GET.get('user')
- self.asset = self.request.GET.get('asset')
- self.system_user = self.request.GET.get('system_user')
- self.filename = self.request.GET.get('filename', '')
-
- filter_kwargs = dict()
- filter_kwargs['date_start__gt'] = self.date_from
- filter_kwargs['date_start__lt'] = self.date_to
- if self.user:
- filter_kwargs['user'] = self.user
- if self.asset:
- filter_kwargs['asset'] = self.asset
- if self.system_user:
- filter_kwargs['system_user'] = self.system_user
- if self.filename:
- filter_kwargs['filename__contains'] = self.filename
- if filter_kwargs:
- self.queryset = self.queryset.filter(**filter_kwargs).order_by('-date_start')
- return self.queryset
-
- def get_context_data(self, **kwargs):
- context = {
- 'user_list': FTPLog.objects.values_list('user', flat=True).distinct(),
- 'asset_list': FTPLog.objects.values_list('asset', flat=True).distinct(),
- 'system_user_list': FTPLog.objects.values_list('system_user', flat=True).distinct(),
- 'date_from': self.date_from,
- 'date_to': self.date_to,
- 'user': self.user,
- 'asset': self.asset,
- 'system_user': self.system_user,
- 'filename': self.filename,
- "app": _("Audits"),
- "action": _("FTP log"),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class OperateLogListView(PermissionsMixin, DatetimeSearchMixin, ListView):
- model = OperateLog
- template_name = 'audits/operate_log_list.html'
- paginate_by = settings.DISPLAY_PER_PAGE
- user = action = resource_type = ''
- date_from = date_to = None
- actions_dict = dict(OperateLog.ACTION_CHOICES)
- permission_classes = [IsOrgAdmin | IsOrgAuditor]
-
- def get_queryset(self):
- self.queryset = super().get_queryset()
- self.user = self.request.GET.get('user')
- self.action = self.request.GET.get('action')
- self.resource_type = self.request.GET.get('resource_type')
-
- filter_kwargs = dict()
- filter_kwargs['datetime__gt'] = self.date_from
- filter_kwargs['datetime__lt'] = self.date_to
- if self.user:
- filter_kwargs['user'] = self.user
- if self.action:
- filter_kwargs['action'] = self.action
- if self.resource_type:
- filter_kwargs['resource_type'] = self.resource_type
- if filter_kwargs:
- self.queryset = self.queryset.filter(**filter_kwargs).order_by('-datetime')
- return self.queryset
-
- def get_context_data(self, **kwargs):
- context = {
- 'user_list': [str(user) for user in current_org.get_org_members()],
- 'actions': self.actions_dict,
- 'search_action': self.action,
- 'resource_type_list': get_resource_type_list(),
- 'date_from': self.date_from,
- 'date_to': self.date_to,
- 'user': self.user,
- 'resource_type': self.resource_type,
- "app": _("Audits"),
- "action": _("Operate log"),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class PasswordChangeLogList(PermissionsMixin, DatetimeSearchMixin, ListView):
- model = PasswordChangeLog
- template_name = 'audits/password_change_log_list.html'
- paginate_by = settings.DISPLAY_PER_PAGE
- user = ''
- date_from = date_to = None
- permission_classes = [IsOrgAdmin | IsOrgAuditor]
-
- def get_queryset(self):
- users = current_org.get_org_members()
- self.queryset = super().get_queryset().filter(
- user__in=[user.__str__() for user in users]
- )
- self.user = self.request.GET.get('user')
-
- filter_kwargs = dict()
- filter_kwargs['datetime__gt'] = self.date_from
- filter_kwargs['datetime__lt'] = self.date_to
- if self.user:
- filter_kwargs['user'] = self.user
- if filter_kwargs:
- self.queryset = self.queryset.filter(**filter_kwargs).order_by('-datetime')
- return self.queryset
-
- def get_context_data(self, **kwargs):
- context = {
- 'user_list': [str(user) for user in current_org.get_org_members()],
- 'date_from': self.date_from,
- 'date_to': self.date_to,
- 'user': self.user,
- "app": _("Audits"),
- "action": _("Password change log"),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class LoginLogListView(PermissionsMixin, DatetimeSearchMixin, ListView):
- template_name = 'audits/login_log_list.html'
- model = UserLoginLog
- paginate_by = settings.DISPLAY_PER_PAGE
- user = keyword = ""
- date_to = date_from = None
- permission_classes = [IsOrgAdmin | IsOrgAuditor]
-
- @staticmethod
- def get_org_members():
- users = current_org.get_org_members().values_list('username', flat=True)
- return users
-
- def get_queryset(self):
- if current_org.is_default():
- queryset = super().get_queryset()
- else:
- users = self.get_org_members()
- queryset = super().get_queryset().filter(username__in=users)
-
- self.user = self.request.GET.get('user', '')
- self.keyword = self.request.GET.get("keyword", '')
-
- queryset = queryset.filter(
- datetime__gt=self.date_from, datetime__lt=self.date_to
- )
- if self.user:
- queryset = queryset.filter(username=self.user)
- if self.keyword:
- queryset = queryset.filter(
- Q(ip__contains=self.keyword) |
- Q(city__contains=self.keyword) |
- Q(username__contains=self.keyword)
- )
- return queryset
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Audits'),
- 'action': _('Login log'),
- 'date_from': self.date_from,
- 'date_to': self.date_to,
- 'user': self.user,
- 'keyword': self.keyword,
- 'user_list': self.get_org_members(),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class CommandExecutionListView(UserCommandExecutionListView):
- user_id = None
-
- def get_user_list(self):
- users = current_org.get_org_members(exclude=('Auditor',))
- return users
-
- def get_queryset(self):
- queryset = self._get_queryset()
- self.user_id = self.request.GET.get('user')
- org_users = self.get_user_list()
- if self.user_id:
- queryset = queryset.filter(user=self.user_id)
- else:
- queryset = queryset.filter(user__in=org_users)
- return queryset
-
- def get_context_data(self, **kwargs):
- context = super().get_context_data(**kwargs)
- context.update({
- 'app': _('Audits'),
- 'action': _('Command execution log'),
- 'date_from': self.date_from,
- 'date_to': self.date_to,
- 'user_list': [(str(user.id), user) for user in self.get_user_list()],
- 'keyword': self.keyword,
- 'user_id': self.user_id,
- })
- return context
-
-
-@method_decorator(csrf_exempt, name='dispatch')
-class LoginLogExportView(PermissionsMixin, View):
- permission_classes = [IsValidUser]
-
- def get(self, request):
- fields = [
- field for field in UserLoginLog._meta.fields
- ]
- filename = 'login-logs-{}.csv'.format(
- timezone.localtime(timezone.now()).strftime('%Y-%m-%d_%H-%M-%S')
- )
- excel_response = get_excel_response(filename)
- header = [field.verbose_name for field in fields]
- login_logs = cache.get(request.GET.get('spm', ''), [])
-
- response = write_content_to_excel(
- excel_response, login_logs=login_logs, header=header, fields=fields
- )
- return response
-
- def post(self, request):
- try:
- date_from = json.loads(request.body).get('date_from', [])
- date_to = json.loads(request.body).get('date_to', [])
- user = json.loads(request.body).get('user', [])
- keyword = json.loads(request.body).get('keyword', [])
-
- login_logs = UserLoginLog.get_login_logs(
- date_from=date_from, date_to=date_to, user=user,
- keyword=keyword,
- )
- except ValueError:
- return HttpResponse('Json object not valid', status=400)
- spm = uuid.uuid4().hex
- cache.set(spm, login_logs, 300)
- url = reverse('audits:login-log-export') + '?spm=%s' % spm
- return JsonResponse({'redirect': url})
\ No newline at end of file
diff --git a/apps/jumpserver/urls.py b/apps/jumpserver/urls.py
index bfe7aed83..d5c28bc93 100644
--- a/apps/jumpserver/urls.py
+++ b/apps/jumpserver/urls.py
@@ -31,32 +31,11 @@ api_v2 = [
path('users/', include('users.urls.api_urls_v2', namespace='api-users-v2')),
]
-disabled_view_pattern = [
- path('users/', include('users.urls.views_urls', namespace='users')),
- path('assets/', include('assets.urls.views_urls', namespace='assets')),
- path('perms/', include('perms.urls.views_urls', namespace='perms')),
- path('terminal/', include('terminal.urls.views_urls', namespace='terminal')),
- path('ops/', include('ops.urls.view_urls', namespace='ops')),
- path('audits/', include('audits.urls.view_urls', namespace='audits')),
- path('orgs/', include('orgs.urls.views_urls', namespace='orgs')),
- path('applications/', include('applications.urls.views_urls', namespace='applications')),
- path('tickets/', include('tickets.urls.views_urls', namespace='tickets')),
- re_path(r'flower/(?P.*)', views.celery_flower_view, name='flower-view'),
- re_path('luna/.*', views.LunaView.as_view(), name='luna-view'),
- re_path('koko/.*', views.KokoView.as_view(), name='koko-view'),
- re_path('ws/.*', views.WsView.as_view(), name='ws-view'),
- path('i18n//', views.I18NView.as_view(), name='i18n-switch'),
- path('settings/', include('settings.urls.view_urls', namespace='settings')),
-]
-
app_view_patterns = [
path('auth/', include('authentication.urls.view_urls'), name='auth'),
]
-if os.environ.get('ENABLE_OLD_VIEW'):
- app_view_patterns += disabled_view_pattern
-
if settings.XPACK_ENABLED:
app_view_patterns.append(
diff --git a/apps/ops/forms.py b/apps/ops/forms.py
deleted file mode 100644
index 6658980f8..000000000
--- a/apps/ops/forms.py
+++ /dev/null
@@ -1,17 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-from django import forms
-
-from assets.models import SystemUser
-from .models import CommandExecution
-
-
-class CommandExecutionForm(forms.ModelForm):
- class Meta:
- model = CommandExecution
- fields = ['run_as', 'command']
-
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
- run_as_field = self.fields.get('run_as')
- run_as_field.queryset = SystemUser.objects.all()
diff --git a/apps/ops/templates/ops/adhoc_detail.html b/apps/ops/templates/ops/adhoc_detail.html
deleted file mode 100644
index 1a28ee0e8..000000000
--- a/apps/ops/templates/ops/adhoc_detail.html
+++ /dev/null
@@ -1,201 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block custom_head_css_js %}
-
-
-{% endblock %}
-{% block content %}
-
-
-
-
-
-
-
-
-
-
{{ object.task.name }}: {{ object.short_id }}
-
-
-
-
-
-
- {% trans 'ID' %}:
- {{ object.id }}
-
-
- {% trans 'Hosts' %}:
- {{ object.hosts | length }}
-
-
- {% trans 'Pattern' %}:
- {{ object.pattern }}
-
-
- {% trans 'Options' %}
-
-
- {% for k, v in object.options.items %}
- {{ k }} = {{ v }}
- {% endfor %}
-
-
-
- {% if object.run_as_admin %}
-
- {% trans 'Run as' %}
- Admin
-
- {% else %}
-
- {% trans 'Run as' %}:
- {{ object.get_latest_execution.date_start }}
-
- {% endif %}
-
- {% trans 'Become' %}
- {{ object.become_display }}
-
-
- {% trans 'Created by' %}
- {{ object.created_by }}
-
-
- {% trans 'Date created' %}:
- {{ object.date_created }}
-
-
- {% trans 'Run times' %}:
- {{ object.execution.all | length }}
-
-
- {% trans 'Last run' %}:
- {{ object.latest_execution.short_id }}
-
-
- {% trans 'Time delta' %}:
- {{ object.latest_execution.timedelta|floatformat}} s
-
-
- {% trans 'Is finished' %}:
- {{ object.latest_execution.is_finished|yesno:"Yes,No,Unkown" }}
-
-
- {% trans 'Is success ' %}:
- {{ object.latest_execution.is_success|yesno:"Yes,No,Unkown" }}
-
-
- {% trans 'Tasks' %}:
-
-
- {% for task in object.tasks %}
- {{ forloop.counter }}. {{ task.name }} ::: {{ task.action.module }}
- {% endfor %}
-
-
-
-
-
-
-
-
-
-
-
- {% trans 'Last run failed hosts' %}
-
-
-
-
- {% for host, task in object.latest_execution.failed_hosts.items %}
- {% if forloop.first %}
-
- {% else %}
-
- {% endif %}
- {{ host }}:
-
- {% for name, result in task.items %}
- {{ name }} => {{ result.msg }}
- {% endfor %}
-
-
- {% empty %}
-
- {% trans 'No hosts' %}
-
- {% endfor %}
-
-
-
-
-
-
-
- {% trans 'Last run success hosts' %}
-
-
-
-
- {% for host in object.latest_execution.success_hosts %}
- {% if forloop.first %}
-
- {% else %}
-
- {% endif %}
- {{ host }}
-
- {% empty %}
-
- {% trans 'No hosts' %}
-
- {% endfor %}
-
-
-
-
-
-
-
-
-
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
-
diff --git a/apps/ops/templates/ops/adhoc_history.html b/apps/ops/templates/ops/adhoc_history.html
deleted file mode 100644
index e9662cb45..000000000
--- a/apps/ops/templates/ops/adhoc_history.html
+++ /dev/null
@@ -1,146 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block custom_head_css_js %}
-
-
-{% endblock %}
-{% block content %}
-
-
-
-
-
-
-
-
-
-
{% trans 'Executions of ' %} {{ object.task.name }}:{{ object.short_id }}
-
-
-
-
-
-
-
-
-
-
-{% endblock %}
-
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/ops/templates/ops/adhoc_history_detail.html b/apps/ops/templates/ops/adhoc_history_detail.html
deleted file mode 100644
index 52e5e03f0..000000000
--- a/apps/ops/templates/ops/adhoc_history_detail.html
+++ /dev/null
@@ -1,152 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block custom_head_css_js %}
-
-
-{% endblock %}
-{% block content %}
-
-
-
-
-
-
-
-
-
-
{% trans 'Execution detail of' %} {{ object.task.name }}: {{ object.adhoc.short_id }}
-
-
-
-
-
-
- {% trans 'ID' %}:
- {{ object.id }}
-
-
- {% trans 'Task name' %}:
- {{ object.task.name }}
-
-
- {% trans 'Version' %}:
- {{ object.adhoc.short_id }}
-
-
- {% trans 'Date start' %}:
- {{ object.date_start }}
-
-
- {% trans 'Time delta' %}:
- {{ object.timedelta|floatformat}} s
-
-
- {% trans 'Is finished' %}:
- {{ object.is_finished|yesno:"Yes,No,Unkown" }}
-
-
- {% trans 'Is success ' %}:
- {{ object.is_success|yesno:"Yes,No,Unkown" }}
-
-
-
-
-
-
-
-
-
- {% trans 'Failed assets' %}
-
-
-
-
- {% for host, task in object.failed_hosts.items %}
- {% if forloop.first %}
-
- {% else %}
-
- {% endif %}
- {{ host }}:
-
- {% for name, result in task.items %}
- {{ name }} => {{ result.msg }}
- {% endfor %}
-
-
- {% empty %}
-
- {% trans 'No assets' %}
-
- {% endfor %}
-
-
-
-
-
-
-
- {% trans 'Success assets' %}
-
-
-
-
- {% for host in object.success_hosts %}
- {% if forloop.first %}
-
- {% else %}
-
- {% endif %}
- {{ host }}
-
- {% empty %}
-
- {% trans 'No assets' %}
-
- {% endfor %}
-
-
-
-
-
-
-
-
-
-
- {% include 'users/_user_update_pk_modal.html' %}
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
-
diff --git a/apps/ops/templates/ops/celery_task_log.html b/apps/ops/templates/ops/celery_task_log.html
deleted file mode 100644
index 455fc28d6..000000000
--- a/apps/ops/templates/ops/celery_task_log.html
+++ /dev/null
@@ -1,91 +0,0 @@
-{% load static %}
-{% load i18n %}
-
- {% trans 'Task log' %}
-
-
-
-
-
-
-
-
-
-
-
diff --git a/apps/ops/templates/ops/command_execution_create.html b/apps/ops/templates/ops/command_execution_create.html
deleted file mode 100644
index 8912cbe71..000000000
--- a/apps/ops/templates/ops/command_execution_create.html
+++ /dev/null
@@ -1,335 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-{% load bootstrap3 %}
-
-{% block custom_head_css_js %}
-
-
-
-
-
-
-
-
-
-
-
-
-{% endblock %}
-
-{% block content %}
-
-
-
-
-
-
-
- {% trans 'Loading' %} ..
-
-
-
-
-
-
-
-
-
-{% endblock %}
-
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/ops/templates/ops/command_execution_list.html b/apps/ops/templates/ops/command_execution_list.html
deleted file mode 100644
index a21a1b108..000000000
--- a/apps/ops/templates/ops/command_execution_list.html
+++ /dev/null
@@ -1,129 +0,0 @@
-{% extends '_base_list.html' %}
-{% load i18n %}
-{% load static %}
-{% load common_tags %}
-
-{% block custom_head_css_js %}
-
-
-
-{% endblock %}
-
-{% block content_left_head %}
-{% endblock %}
-
-{% block table_search %}
-
-{% endblock %}
-
-{% block table_container %}
-
-{% endblock %}
-
-{% block custom_foot_js %}
-
-
-
-{% endblock %}
-
diff --git a/apps/ops/templates/ops/task_adhoc.html b/apps/ops/templates/ops/task_adhoc.html
deleted file mode 100644
index bddd2388e..000000000
--- a/apps/ops/templates/ops/task_adhoc.html
+++ /dev/null
@@ -1,138 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block custom_head_css_js %}
-
-
-{% endblock %}
-{% block content %}
-
-
-
-
-
-
-
-
-
-
{% trans 'Versions of ' %} {{ object.name }}
-
-
-
-
-
-
-
-
-
-
-{% endblock %}
-
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/ops/templates/ops/task_detail.html b/apps/ops/templates/ops/task_detail.html
deleted file mode 100644
index 39696b3d9..000000000
--- a/apps/ops/templates/ops/task_detail.html
+++ /dev/null
@@ -1,192 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block custom_head_css_js %}
-
-
-{% endblock %}
-
-{% block content %}
-
-
-
-
-
-
-
-
-
-
-
-
-
- {% trans 'ID' %}:
- {{ object.id }}
-
-
- {% trans 'Name' %}:
- {{ object.name }}
-
-
- {% trans 'Date created' %}:
- {{ object.date_created }}
-
-
- {% trans 'Total versions' %}
- {{ object.adhoc.all |length }}
-
-
- {% trans 'Latest version' %}
- {{ object.latest_adhoc.short_id }}
-
-
- {% trans 'Last run' %}:
- {{ object.latest_execution.date_start }}
-
-
- {% trans 'Time delta' %}:
- {{ object.latest_execution.timedelta|floatformat}} s
-
-
- {% trans 'Is finished' %}:
-
- {% if object.latest_execution.is_finished %}
- {% trans 'Yes' %}
- {% else %}
- {% trans 'No' %}
- {% endif %}
-
-
-
- {% trans 'Is success ' %}:
-
- {% if object.latest_execution.is_success %}
- {% trans 'Yes' %}
- {% else %}
- {% trans 'No' %}
- {% endif %}
-
-
-
- {% trans 'Contents' %}:
-
-
- {% for task in object.latest_adhoc.tasks %}
- {{ forloop.counter }}. {{ task.name }} ::: {{ task.action.module }}
- {% endfor %}
-
-
-
-
-
-
-
-
-
-
-
- {% trans 'Last run failed hosts' %}
-
-
-
-
- {% for host, task in object.latest_execution.failed_hosts.items %}
- {% if forloop.first %}
-
- {% else %}
-
- {% endif %}
- {{ host }}:
-
- {% for name, result in task.items %}
- {{ name }} => {{ result.msg }}
- {% endfor %}
-
-
- {% empty %}
-
- {% trans 'No hosts' %}
-
- {% endfor %}
-
-
-
-
-
-
-
- {% trans 'Last run success hosts' %}
-
-
-
-
- {% for host in object.latest_execution.success_hosts %}
- {% if forloop.first %}
-
- {% else %}
-
- {% endif %}
- {{ host }}
-
- {% empty %}
-
- {% trans 'No hosts' %}
-
- {% endfor %}
-
-
-
-
-
-
-
-
-
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
-
diff --git a/apps/ops/templates/ops/task_history.html b/apps/ops/templates/ops/task_history.html
deleted file mode 100644
index 06dc3416c..000000000
--- a/apps/ops/templates/ops/task_history.html
+++ /dev/null
@@ -1,160 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block custom_head_css_js %}
-
-
-{% endblock %}
-{% block content %}
-
-
-
-
-
-
-
-
-
-
{% trans 'Executions of ' %} {{ object.name }}:{{ object.short_id }}
-
-
-
-
-
-
-
-
-
-
-{% endblock %}
-
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/ops/templates/ops/task_list.html b/apps/ops/templates/ops/task_list.html
deleted file mode 100644
index a004138df..000000000
--- a/apps/ops/templates/ops/task_list.html
+++ /dev/null
@@ -1,119 +0,0 @@
-{% extends '_base_list.html' %}
-{% load i18n static %}
-{% block table_search %}{% endblock %}
-{% block table_container %}
-
-{% endblock %}
-
-{% block content_bottom_left %}{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
-
diff --git a/apps/ops/urls/view_urls.py b/apps/ops/urls/view_urls.py
index f17fb8662..fb52a3e07 100644
--- a/apps/ops/urls/view_urls.py
+++ b/apps/ops/urls/view_urls.py
@@ -1,24 +1,9 @@
# ~*~ coding: utf-8 ~*~
from __future__ import unicode_literals
-from django.urls import path
-
-from .. import views
__all__ = ["urlpatterns"]
app_name = "ops"
urlpatterns = [
- # Resource Task url
- path('task/', views.TaskListView.as_view(), name='task-list'),
- path('task//', views.TaskDetailView.as_view(), name='task-detail'),
- path('task//adhoc/', views.TaskAdhocView.as_view(), name='task-adhoc'),
- path('task//executions/', views.TaskExecutionView.as_view(), name='task-execution'),
- path('adhoc//', views.AdHocDetailView.as_view(), name='adhoc-detail'),
- path('adhoc//executions/', views.AdHocExecutionView.as_view(), name='adhoc-execution'),
- path('adhoc/executions//', views.AdHocExecutionDetailView.as_view(), name='adhoc-execution-detail'),
- path('celery/task//log/', views.CeleryTaskLogView.as_view(), name='celery-task-log'),
-
- path('command-executions/', views.CommandExecutionListView.as_view(), name='command-execution-list'),
- path('command-executions/create/', views.CommandExecutionCreateView.as_view(), name='command-execution-create'),
]
diff --git a/apps/ops/views/__init__.py b/apps/ops/views/__init__.py
deleted file mode 100644
index 58bb835a6..000000000
--- a/apps/ops/views/__init__.py
+++ /dev/null
@@ -1,3 +0,0 @@
-from .adhoc import *
-from .celery import *
-from .command import *
\ No newline at end of file
diff --git a/apps/ops/views/adhoc.py b/apps/ops/views/adhoc.py
deleted file mode 100644
index e21c7b575..000000000
--- a/apps/ops/views/adhoc.py
+++ /dev/null
@@ -1,127 +0,0 @@
-# ~*~ coding: utf-8 ~*~
-
-from django.utils.translation import ugettext as _
-from django.conf import settings
-from django.views.generic import ListView, DetailView, TemplateView
-
-from common.mixins import DatetimeSearchMixin
-from common.permissions import PermissionsMixin, IsOrgAdmin
-from orgs.utils import current_org
-from ..models import Task, AdHoc, AdHocExecution
-
-
-__all__ = [
- 'TaskListView', 'TaskDetailView', 'TaskExecutionView',
- 'TaskAdhocView', 'AdHocDetailView', 'AdHocExecutionDetailView',
- 'AdHocExecutionView'
-]
-
-
-class TaskListView(PermissionsMixin, TemplateView):
- paginate_by = settings.DISPLAY_PER_PAGE
- model = Task
- ordering = ('-date_created',)
- context_object_name = 'task_list'
- template_name = 'ops/task_list.html'
- keyword = ''
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Ops'),
- 'action': _('Task list'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class TaskDetailView(PermissionsMixin, DetailView):
- model = Task
- template_name = 'ops/task_detail.html'
- permission_classes = [IsOrgAdmin]
-
- def get_queryset(self):
- queryset = super().get_queryset()
- return queryset
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Ops'),
- 'action': _('Task detail'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class TaskAdhocView(PermissionsMixin, DetailView):
- model = Task
- template_name = 'ops/task_adhoc.html'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Ops'),
- 'action': _('Task versions'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class TaskExecutionView(PermissionsMixin, DetailView):
- model = Task
- template_name = 'ops/task_history.html'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Ops'),
- 'action': _('Task execution list'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class AdHocDetailView(PermissionsMixin, DetailView):
- model = AdHoc
- template_name = 'ops/adhoc_detail.html'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Ops'),
- 'action': _('Task detail'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class AdHocExecutionView(PermissionsMixin, DetailView):
- model = AdHoc
- template_name = 'ops/adhoc_history.html'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Ops'),
- 'action': _('Version run execution'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class AdHocExecutionDetailView(PermissionsMixin, DetailView):
- model = AdHocExecution
- template_name = 'ops/adhoc_history_detail.html'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Ops'),
- 'action': _('Execution detail'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-
-
diff --git a/apps/ops/views/celery.py b/apps/ops/views/celery.py
deleted file mode 100644
index 9ae2d9755..000000000
--- a/apps/ops/views/celery.py
+++ /dev/null
@@ -1,22 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-from django.views.generic import TemplateView
-from django.conf import settings
-
-from common.permissions import PermissionsMixin, IsOrgAdmin, IsOrgAuditor
-
-
-__all__ = ['CeleryTaskLogView']
-
-
-class CeleryTaskLogView(PermissionsMixin, TemplateView):
- template_name = 'ops/celery_task_log.html'
- permission_classes = [IsOrgAdmin | IsOrgAuditor]
-
- def get_context_data(self, **kwargs):
- context = super().get_context_data(**kwargs)
- context.update({
- 'task_id': self.kwargs.get('pk'),
- 'ws_port': settings.WS_LISTEN_PORT
- })
- return context
diff --git a/apps/ops/views/command.py b/apps/ops/views/command.py
deleted file mode 100644
index 4dfc3d2e7..000000000
--- a/apps/ops/views/command.py
+++ /dev/null
@@ -1,89 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-
-from django.utils.translation import ugettext as _
-from django.conf import settings
-from django.views.generic import ListView, TemplateView
-
-from common.permissions import (
- PermissionsMixin, IsOrgAdmin, IsValidUser, IsOrgAuditor
-)
-from common.mixins import DatetimeSearchMixin
-from orgs.utils import tmp_to_root_org
-from ..models import CommandExecution
-from ..forms import CommandExecutionForm
-
-
-__all__ = [
- 'CommandExecutionListView', 'CommandExecutionCreateView'
-]
-
-
-class CommandExecutionListView(PermissionsMixin, DatetimeSearchMixin, ListView):
- template_name = 'ops/command_execution_list.html'
- model = CommandExecution
- paginate_by = settings.DISPLAY_PER_PAGE
- ordering = ('-date_created',)
- context_object_name = 'task_list'
- keyword = ''
- permission_classes = [IsOrgAdmin | IsOrgAuditor]
-
- def _get_queryset(self):
- self.keyword = self.request.GET.get('keyword', '')
- queryset = super().get_queryset()
- if self.date_from:
- queryset = queryset.filter(date_start__gte=self.date_from)
- if self.date_to:
- queryset = queryset.filter(date_start__lte=self.date_to)
- if self.keyword:
- queryset = queryset.filter(command__icontains=self.keyword)
- return queryset
-
- def get_queryset(self):
- queryset = self._get_queryset().filter(user=self.request.user)
- return queryset
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Ops'),
- 'action': _('Command execution list'),
- 'date_from': self.date_from,
- 'date_to': self.date_to,
- 'keyword': self.keyword,
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class CommandExecutionCreateView(PermissionsMixin, TemplateView):
- template_name = 'ops/command_execution_create.html'
- form_class = CommandExecutionForm
- permission_classes = [IsValidUser]
-
- def get_permissions(self):
- if not settings.SECURITY_COMMAND_EXECUTION:
- return [IsOrgAdmin]
- return super().get_permissions()
-
- def get_user_system_users(self):
- from perms.utils import AssetPermissionUtil
- user = self.request.user
- with tmp_to_root_org():
- util = AssetPermissionUtil(user)
- system_users = util.get_system_users()
- return system_users
-
- def get_context_data(self, **kwargs):
- system_users = self.get_user_system_users()
- context = {
- 'app': _('Ops'),
- 'action': _('Command execution'),
- 'form': self.get_form(),
- 'system_users': system_users,
- 'ws_port': settings.WS_LISTEN_PORT
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
- def get_form(self):
- return self.form_class()
diff --git a/apps/orgs/urls/views_urls.py b/apps/orgs/urls/views_urls.py
index 225457827..581eed2b0 100644
--- a/apps/orgs/urls/views_urls.py
+++ b/apps/orgs/urls/views_urls.py
@@ -1,14 +1,7 @@
# -*- coding: utf-8 -*-
#
-
-from django.urls import path
-
-from .. import views
-
app_name = 'orgs'
urlpatterns = [
- path('/switch/', views.SwitchOrgView.as_view(), name='org-switch'),
- path('switch-a-org/', views.SwitchToAOrgView.as_view(), name='switch-a-org')
]
diff --git a/apps/orgs/views.py b/apps/orgs/views.py
deleted file mode 100644
index 0cbcd00e0..000000000
--- a/apps/orgs/views.py
+++ /dev/null
@@ -1,53 +0,0 @@
-from django.shortcuts import redirect, reverse
-from django.conf import settings
-from django.http import HttpResponseForbidden
-
-from django.views.generic import DetailView, View
-
-from .models import Organization
-from common.utils import UUID_PATTERN
-
-
-class SwitchOrgView(DetailView):
- model = Organization
- object = None
-
- def get(self, request, *args, **kwargs):
- pk = kwargs.get('pk')
- self.object = Organization.get_instance(pk)
- oid = str(self.object.id)
- request.session['oid'] = oid
- org_change_to_url = settings.ORG_CHANGE_TO_URL
- if org_change_to_url:
- return redirect(org_change_to_url)
- host = request.get_host()
- referer = request.META.get('HTTP_REFERER', '')
- if referer.find(host) == -1:
- return redirect(reverse('index'))
- if UUID_PATTERN.search(referer):
- return redirect(reverse('index'))
- # 组织管理员切换到组织审计员时(403)
- if not self.object.get_org_admins().filter(id=request.user.id):
- return redirect(reverse('index'))
- return redirect(referer)
-
-
-class SwitchToAOrgView(View):
- def get(self, request, *args, **kwargs):
- if request.user.is_common_user:
- return HttpResponseForbidden()
- admin_orgs = request.user.admin_orgs
- audit_orgs = request.user.audit_orgs
- default_org = Organization.default()
- if admin_orgs:
- if default_org in admin_orgs:
- redirect_org = default_org
- else:
- redirect_org = admin_orgs[0]
- return redirect(reverse('orgs:org-switch', kwargs={'pk': redirect_org.id}))
- if audit_orgs:
- if default_org in audit_orgs:
- redirect_org = default_org
- else:
- redirect_org = audit_orgs[0]
- return redirect(reverse('orgs:org-switch', kwargs={'pk': redirect_org.id}))
diff --git a/apps/perms/templates/perms/asset_permission_asset.html b/apps/perms/templates/perms/asset_permission_asset.html
deleted file mode 100644
index b6079cdaa..000000000
--- a/apps/perms/templates/perms/asset_permission_asset.html
+++ /dev/null
@@ -1,282 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block content %}
-
-
-
-
-
-
-
-
-
-
{% trans 'Asset list of ' %} {{ asset_permission.name }}
-
-
-
-
-
-
-
-
- {% trans 'Add asset to this permission' %}
-
-
-
-
-
-
- {% trans 'Add node to this permission' %}
-
-
-
-
-
-
- {% for node in asset_permission.nodes.all %}
-
- {{ node.full_value }}
-
-
-
-
- {% endfor %}
-
-
-
-
-
-
- {% trans 'System user' %}
-
-
-
-
-
-
- {% for system_user in object.system_users.all %}
-
- {{ system_user|truncatechars:21}}
-
-
-
-
- {% endfor %}
-
-
-
-
-
-
-
-
-
-
-{% include 'assets/_asset_list_modal.html' %}
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/perms/templates/perms/asset_permission_create_update.html b/apps/perms/templates/perms/asset_permission_create_update.html
deleted file mode 100644
index 937e7273e..000000000
--- a/apps/perms/templates/perms/asset_permission_create_update.html
+++ /dev/null
@@ -1,220 +0,0 @@
-{% extends 'base.html' %}
-{% load i18n %}
-{% load static %}
-{% load bootstrap3 %}
-{% block custom_head_css_js %}
-
-
-{% endblock %}
-
-{% block content %}
-
- {% include 'assets/_asset_list_modal.html' %}
-{% endblock %}
-{% block custom_foot_js %}
-
-
-
-
-
-
-{% endblock %}
diff --git a/apps/perms/templates/perms/asset_permission_detail.html b/apps/perms/templates/perms/asset_permission_detail.html
deleted file mode 100644
index 6930cfc5a..000000000
--- a/apps/perms/templates/perms/asset_permission_detail.html
+++ /dev/null
@@ -1,178 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block content %}
-
-
-
-
-
-
-
-
-
-
-
-
-
- {% trans 'Name' %}:
- {{ object.name }}
-
-
- {% trans 'User count' %}:
- {{ object.users.count }}
-
-
- {% trans 'User group count' %}:
- {{ object.user_groups.count }}
-
-
- {% trans 'Asset count' %}:
- {{ object.assets.count }}
-
-
- {% trans 'Node count' %}:
- {{ object.nodes.count }}
-
-
- {% trans 'System user count' %}:
- {{ object.system_users.count }}
-
-
- {% trans 'Date start' %}:
- {{ object.date_start }}
-
-
- {% trans 'Date expired' %}:
- {{ object.date_expired }}
-
-
- {% trans 'Date created' %}:
- {{ object.date_created }}
-
-
- {% trans 'Created by' %}:
- {{ object.created_by }}
-
-
- {% trans 'Comment' %}:
- {{ object.comment }}
-
-
-
-
-
-
-
-
-
-
- {% trans 'Quick update' %}
-
-
-
-
-
- {% trans 'Active' %} :
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/perms/templates/perms/asset_permission_list.html b/apps/perms/templates/perms/asset_permission_list.html
deleted file mode 100644
index 1f44f7de1..000000000
--- a/apps/perms/templates/perms/asset_permission_list.html
+++ /dev/null
@@ -1,260 +0,0 @@
-{% extends '_base_asset_tree_list.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block custom_head_css_js %}
-
-
-
-
-
-
-{% endblock %}
-
-{% block table_container %}
-
-
- {% trans "Create permission" %}
-
-
-
-
-
-
-
-
- {% trans 'Name' %}
- {% trans 'User' %}
- {% trans 'User group' %}
- {% trans 'Asset' %}
- {% trans 'Node'%}
- {% trans 'System user' %}
- {% trans 'Validity' %}
- {% trans 'Action' %}
-
-
-
-
-
-{% include '_filter_dropdown.html' %}
-{% endblock %}
-
-{% block custom_foot_js %}
-
-
-
-{% endblock %}
diff --git a/apps/perms/templates/perms/asset_permission_user.html b/apps/perms/templates/perms/asset_permission_user.html
deleted file mode 100644
index 088d80c75..000000000
--- a/apps/perms/templates/perms/asset_permission_user.html
+++ /dev/null
@@ -1,251 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block content %}
-
-
-
-
-
-
-
-
-
-
{% trans 'User list of ' %} {{ asset_permission.name }}
-
-
-
-
-
-
-
-
- {% trans 'Add user to asset permission' %}
-
-
-
-
-
-
- {% trans 'Add user group to asset permission' %}
-
-
-
-
-
-
- {% for user_group in asset_permission.user_groups.all %}
-
- {{ user_group }}
-
-
-
-
- {% endfor %}
-
-
-
-
-
-
-
-
-
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/perms/templates/perms/database_app_permission_create_update.html b/apps/perms/templates/perms/database_app_permission_create_update.html
deleted file mode 100644
index a779e5826..000000000
--- a/apps/perms/templates/perms/database_app_permission_create_update.html
+++ /dev/null
@@ -1,143 +0,0 @@
-{% extends 'base.html' %}
-{% load i18n %}
-{% load static %}
-{% load bootstrap3 %}
-{% block custom_head_css_js %}
-
-{% endblock %}
-
-{% block content %}
-
-{% endblock %}
-{% block custom_foot_js %}
-
-
-
-
-
-
-{% endblock %}
diff --git a/apps/perms/templates/perms/database_app_permission_database_app.html b/apps/perms/templates/perms/database_app_permission_database_app.html
deleted file mode 100644
index 0a23618d0..000000000
--- a/apps/perms/templates/perms/database_app_permission_database_app.html
+++ /dev/null
@@ -1,237 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block content %}
-
-
-
-
-
-
-
-
-
-
{% trans 'DatabaseApp list of ' %} {{ database_app_permission.name }}
-
-
-
-
-
-
-
-
- {% trans 'Add DatabaseApp to this permission' %}
-
-
-
-
-
-
- {% trans 'System user' %}
-
-
-
-
-
-
- {% for system_user in object.system_users.all %}
-
- {{ system_user|truncatechars:21}}
-
-
-
-
- {% endfor %}
-
-
-
-
-
-
-
-
-
-
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/perms/templates/perms/database_app_permission_detail.html b/apps/perms/templates/perms/database_app_permission_detail.html
deleted file mode 100644
index feae4db24..000000000
--- a/apps/perms/templates/perms/database_app_permission_detail.html
+++ /dev/null
@@ -1,157 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block content %}
-
-
-
-
-
-
-
-
-
-
-
-
-
- {% trans 'Name' %}:
- {{ object.name }}
-
-
- {% trans 'User count' %}:
- {{ object.users.count }}
-
-
- {% trans 'User group count' %}:
- {{ object.user_groups.count }}
-
-
- {% trans 'DatabaseApp count' %}:
- {{ object.database_apps.count }}
-
-
- {% trans 'System user count' %}:
- {{ object.system_users.count }}
-
-
- {% trans 'Date start' %}:
- {{ object.date_start }}
-
-
- {% trans 'Date expired' %}:
- {{ object.date_expired }}
-
-
- {% trans 'Date created' %}:
- {{ object.date_created }}
-
-
- {% trans 'Created by' %}:
- {{ object.created_by }}
-
-
- {% trans 'Comment' %}:
- {{ object.comment }}
-
-
-
-
-
-
-
-
-
-
- {% trans 'Quick update' %}
-
-
-
-
-
- {% trans 'Active' %} :
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/perms/templates/perms/database_app_permission_list.html b/apps/perms/templates/perms/database_app_permission_list.html
deleted file mode 100644
index b85454cb8..000000000
--- a/apps/perms/templates/perms/database_app_permission_list.html
+++ /dev/null
@@ -1,99 +0,0 @@
-{% extends '_base_list.html' %}
-{% load i18n static %}
-{% block table_search %}{% endblock %}
-{% block table_container %}
-
-
-{% endblock %}
-{% block content_bottom_left %}{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/perms/templates/perms/database_app_permission_user.html b/apps/perms/templates/perms/database_app_permission_user.html
deleted file mode 100644
index 8b109fa1a..000000000
--- a/apps/perms/templates/perms/database_app_permission_user.html
+++ /dev/null
@@ -1,251 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block content %}
-
-
-
-
-
-
-
-
-
-
{% trans 'User list of ' %} {{ database_app_permission.name }}
-
-
-
-
-
-
-
-
- {% trans 'Add user to permission' %}
-
-
-
-
-
-
- {% trans 'Add user group to permission' %}
-
-
-
-
-
-
- {% for user_group in database_app_permission.user_groups.all %}
-
- {{ user_group }}
-
-
-
-
- {% endfor %}
-
-
-
-
-
-
-
-
-
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/perms/templates/perms/delete_confirm.html b/apps/perms/templates/perms/delete_confirm.html
deleted file mode 100644
index 777d1dbf9..000000000
--- a/apps/perms/templates/perms/delete_confirm.html
+++ /dev/null
@@ -1,15 +0,0 @@
-{% load i18n %}
-
-
-
-
- {% trans 'Confirm delete' %}
-
-
-
-
-
\ No newline at end of file
diff --git a/apps/perms/templates/perms/remote_app_permission_create_update.html b/apps/perms/templates/perms/remote_app_permission_create_update.html
deleted file mode 100644
index f6e0cda7d..000000000
--- a/apps/perms/templates/perms/remote_app_permission_create_update.html
+++ /dev/null
@@ -1,143 +0,0 @@
-{% extends 'base.html' %}
-{% load i18n %}
-{% load static %}
-{% load bootstrap3 %}
-{% block custom_head_css_js %}
-
-{% endblock %}
-
-{% block content %}
-
-{% endblock %}
-{% block custom_foot_js %}
-
-
-
-
-
-
-{% endblock %}
diff --git a/apps/perms/templates/perms/remote_app_permission_detail.html b/apps/perms/templates/perms/remote_app_permission_detail.html
deleted file mode 100644
index aedef832e..000000000
--- a/apps/perms/templates/perms/remote_app_permission_detail.html
+++ /dev/null
@@ -1,242 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block content %}
-
-
-
-
-
-
-
-
-
-
-
-
-
- {% trans 'Name' %}:
- {{ object.name }}
-
-
- {% trans 'User count' %}:
- {{ object.users.count }}
-
-
- {% trans 'User group count' %}:
- {{ object.user_groups.count }}
-
-
- {% trans 'RemoteApp count' %}:
- {{ object.remote_apps.count }}
-
-
- {% trans 'Date start' %}:
- {{ object.date_start }}
-
-
- {% trans 'Date expired' %}:
- {{ object.date_expired }}
-
-
- {% trans 'Date created' %}:
- {{ object.date_created }}
-
-
- {% trans 'Created by' %}:
- {{ object.created_by }}
-
-
- {% trans 'Comment' %}:
- {{ object.comment }}
-
-
-
-
-
-
-
-
-
-
- {% trans 'Quick update' %}
-
-
-
-
-
- {% trans 'Active' %} :
-
-
-
-
-
-
-
-
-
-
- {% trans 'System user' %}
-
-
-
-
-
-
- {% for system_user in object.system_users.all %}
-
- {{ system_user }}
-
-
-
-
- {% endfor %}
-
-
-
-
-
-
-
-
-
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/perms/templates/perms/remote_app_permission_list.html b/apps/perms/templates/perms/remote_app_permission_list.html
deleted file mode 100644
index f6071430a..000000000
--- a/apps/perms/templates/perms/remote_app_permission_list.html
+++ /dev/null
@@ -1,99 +0,0 @@
-{% extends '_base_list.html' %}
-{% load i18n static %}
-{% block table_search %}{% endblock %}
-{% block table_container %}
-
-
-{% endblock %}
-{% block content_bottom_left %}{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/perms/templates/perms/remote_app_permission_remote_app.html b/apps/perms/templates/perms/remote_app_permission_remote_app.html
deleted file mode 100644
index 991489033..000000000
--- a/apps/perms/templates/perms/remote_app_permission_remote_app.html
+++ /dev/null
@@ -1,160 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block content %}
-
-
-
-
-
-
-
-
-
-
{% trans 'RemoteApp list of ' %} {{ remote_app_permission.name }}
-
-
-
-
-
-
- {% trans 'Name' %}
- {% trans 'Type' %}
-
-
-
-
- {% for remote_app in object_list %}
-
- {{ remote_app.name }}
- {{ remote_app.get_type_display }}
-
-
-
-
- {% endfor %}
-
-
-
- {% include '_pagination.html' %}
-
-
-
-
-
-
-
- {% trans 'Add RemoteApp to this permission' %}
-
-
-
-
-
-
-
-
-
-
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/perms/templates/perms/remote_app_permission_user.html b/apps/perms/templates/perms/remote_app_permission_user.html
deleted file mode 100644
index 9fa623585..000000000
--- a/apps/perms/templates/perms/remote_app_permission_user.html
+++ /dev/null
@@ -1,256 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block content %}
-
-
-
-
-
-
-
-
-
-
{% trans 'User list of ' %} {{ remote_app_permission.name }}
-
-
-
-
-
-
- {% trans 'Name' %}
- {% trans 'Username' %}
-
-
-
-
- {% for user in object_list %}
-
- {{ user.name }}
- {{ user.username }}
-
-
-
-
- {% endfor %}
-
-
-
- {% include '_pagination.html' %}
-
-
-
-
-
-
-
- {% trans 'Add user to this permission' %}
-
-
-
-
-
-
- {% trans 'Add user group to this permission' %}
-
-
-
-
-
-
- {% for user_group in remote_app_permission.user_groups.all %}
-
- {{ user_group }}
-
-
-
-
- {% endfor %}
-
-
-
-
-
-
-
-
-
-
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/perms/templatetags/perms/example_tags.py b/apps/perms/templatetags/perms/example_tags.py
deleted file mode 100644
index e69de29bb..000000000
diff --git a/apps/perms/urls/views_urls.py b/apps/perms/urls/views_urls.py
index f4deba8c8..89d8c241a 100644
--- a/apps/perms/urls/views_urls.py
+++ b/apps/perms/urls/views_urls.py
@@ -1,34 +1,5 @@
# coding:utf-8
-
-from django.conf.urls import url
-from django.urls import path
-from .. import views
-
app_name = 'perms'
urlpatterns = [
- # asset-permission
- path('asset-permission/', views.AssetPermissionListView.as_view(), name='asset-permission-list'),
- path('asset-permission/create/', views.AssetPermissionCreateView.as_view(), name='asset-permission-create'),
- path('asset-permission//update/', views.AssetPermissionUpdateView.as_view(), name='asset-permission-update'),
- path('asset-permission//', views.AssetPermissionDetailView.as_view(),name='asset-permission-detail'),
- path('asset-permission//delete/', views.AssetPermissionDeleteView.as_view(), name='asset-permission-delete'),
- path('asset-permission//user/', views.AssetPermissionUserView.as_view(), name='asset-permission-user-list'),
- path('asset-permission//asset/', views.AssetPermissionAssetView.as_view(), name='asset-permission-asset-list'),
-
- # remote-app-permission
- path('remote-app-permission/', views.RemoteAppPermissionListView.as_view(), name='remote-app-permission-list'),
- path('remote-app-permission/create/', views.RemoteAppPermissionCreateView.as_view(), name='remote-app-permission-create'),
- path('remote-app-permission//update/', views.RemoteAppPermissionUpdateView.as_view(), name='remote-app-permission-update'),
- path('remote-app-permission//', views.RemoteAppPermissionDetailView.as_view(), name='remote-app-permission-detail'),
- path('remote-app-permission//user/', views.RemoteAppPermissionUserView.as_view(), name='remote-app-permission-user-list'),
- path('remote-app-permission//remote-app/', views.RemoteAppPermissionRemoteAppView.as_view(), name='remote-app-permission-remote-app-list'),
-
- # database-app-permission
- path('database-app-permission/', views.DatabaseAppPermissionListView.as_view(), name='database-app-permission-list'),
- path('database-app-permission/create/', views.DatabaseAppPermissionCreateView.as_view(), name='database-app-permission-create'),
- path('database-app-permission//update/', views.DatabaseAppPermissionUpdateView.as_view(), name='database-app-permission-update'),
- path('database-app-permission//', views.DatabaseAppPermissionDetailView.as_view(), name='database-app-permission-detail'),
- path('database-app-permission//user/', views.DatabaseAppPermissionUserView.as_view(), name='database-app-permission-user-list'),
- path('database-app-permission//database-app/', views.DatabaseAppPermissionDatabaseAppView.as_view(), name='database-app-permission-database-app-list'),
]
diff --git a/apps/perms/views/__init__.py b/apps/perms/views/__init__.py
deleted file mode 100644
index c6581b858..000000000
--- a/apps/perms/views/__init__.py
+++ /dev/null
@@ -1,6 +0,0 @@
-# coding: utf-8
-#
-
-from .asset_permission import *
-from .remote_app_permission import *
-from .database_app_permission import *
diff --git a/apps/perms/views/asset_permission.py b/apps/perms/views/asset_permission.py
deleted file mode 100644
index 71b4d5604..000000000
--- a/apps/perms/views/asset_permission.py
+++ /dev/null
@@ -1,175 +0,0 @@
-# ~*~ coding: utf-8 ~*~
-
-from __future__ import unicode_literals, absolute_import
-
-from django.utils.translation import ugettext as _
-from django.views.generic import ListView, CreateView, UpdateView, DetailView, TemplateView
-from django.views.generic.edit import DeleteView, SingleObjectMixin
-from django.urls import reverse_lazy
-from django.conf import settings
-
-from common.permissions import PermissionsMixin, IsOrgAdmin
-from orgs.utils import current_org
-from perms.hands import Node, Asset, SystemUser, UserGroup
-from perms.models import AssetPermission
-from perms.forms import AssetPermissionForm
-
-
-__all__ = [
- 'AssetPermissionListView', 'AssetPermissionCreateView',
- 'AssetPermissionUpdateView', 'AssetPermissionDetailView',
- 'AssetPermissionDeleteView', 'AssetPermissionUserView',
- 'AssetPermissionAssetView',
-
-]
-
-
-class AssetPermissionListView(PermissionsMixin, TemplateView):
- template_name = 'perms/asset_permission_list.html'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Perms'),
- 'action': _('Asset permission list'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class AssetPermissionCreateView(PermissionsMixin, CreateView):
- model = AssetPermission
- form_class = AssetPermissionForm
- template_name = 'perms/asset_permission_create_update.html'
- success_url = reverse_lazy('perms:asset-permission-list')
- permission_classes = [IsOrgAdmin]
-
- def get_form(self, form_class=None):
- form = super().get_form(form_class=form_class)
- nodes_id = self.request.GET.get("nodes")
- assets_id = self.request.GET.get("assets")
-
- if nodes_id:
- nodes_id = nodes_id.split(",")
- nodes = Node.objects.filter(id__in=nodes_id)\
- .exclude(id=Node.org_root().id)
- form.set_nodes_initial(nodes)
- if assets_id:
- assets_id = assets_id.split(",")
- assets = Asset.objects.filter(id__in=assets_id)
- form.set_assets_initial(assets)
- return form
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Perms'),
- 'action': _('Create asset permission'),
- 'api_action': "create",
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class AssetPermissionUpdateView(PermissionsMixin, UpdateView):
- model = AssetPermission
- form_class = AssetPermissionForm
- template_name = 'perms/asset_permission_create_update.html'
- success_url = reverse_lazy("perms:asset-permission-list")
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Perms'),
- 'action': _('Update asset permission'),
- 'api_action': "update",
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class AssetPermissionDetailView(PermissionsMixin, DetailView):
- model = AssetPermission
- form_class = AssetPermissionForm
- template_name = 'perms/asset_permission_detail.html'
- success_url = reverse_lazy("perms:asset-permission-list")
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Perms'),
- 'action': _('Asset permission detail'),
-
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class AssetPermissionDeleteView(PermissionsMixin, DeleteView):
- model = AssetPermission
- template_name = 'delete_confirm.html'
- success_url = reverse_lazy('perms:asset-permission-list')
- permission_classes = [IsOrgAdmin]
-
-
-class AssetPermissionUserView(PermissionsMixin,
- SingleObjectMixin,
- ListView):
- template_name = 'perms/asset_permission_user.html'
- context_object_name = 'asset_permission'
- paginate_by = settings.DISPLAY_PER_PAGE
- object = None
- permission_classes = [IsOrgAdmin]
-
- def get(self, request, *args, **kwargs):
- self.object = self.get_object(queryset=AssetPermission.objects.all())
- return super().get(request, *args, **kwargs)
-
- def get_queryset(self):
- queryset = list(self.object.get_all_users())
- return queryset
-
- def get_context_data(self, **kwargs):
- users = [str(i) for i in self.object.users.all().values_list('id', flat=True)]
- user_groups_remain = UserGroup.objects.exclude(
- assetpermission=self.object)
- context = {
- 'app': _('Perms'),
- 'action': _('Asset permission user list'),
- 'users': users,
- 'user_groups_remain': user_groups_remain,
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class AssetPermissionAssetView(PermissionsMixin,
- SingleObjectMixin,
- ListView):
- template_name = 'perms/asset_permission_asset.html'
- context_object_name = 'asset_permission'
- paginate_by = settings.DISPLAY_PER_PAGE
- object = None
- permission_classes = [IsOrgAdmin]
-
- def get(self, request, *args, **kwargs):
- self.object = self.get_object(queryset=AssetPermission.objects.all())
- return super().get(request, *args, **kwargs)
-
- def get_queryset(self):
- queryset = list(self.object.get_all_assets())
- return queryset
-
- def get_context_data(self, **kwargs):
- assets = self.object.assets.all().values_list('id', flat=True)
- assets = [str(i) for i in assets]
- system_users_remain = SystemUser.objects\
- .exclude(granted_by_permissions=self.object)\
- .exclude(protocol=SystemUser.PROTOCOL_MYSQL)
- context = {
- 'app': _('Perms'),
- 'assets': assets,
- 'action': _('Asset permission asset list'),
- 'system_users_remain': system_users_remain,
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
diff --git a/apps/perms/views/database_app_permission.py b/apps/perms/views/database_app_permission.py
deleted file mode 100644
index 50627defe..000000000
--- a/apps/perms/views/database_app_permission.py
+++ /dev/null
@@ -1,152 +0,0 @@
-# coding: utf-8
-#
-
-from django.utils.translation import ugettext as _
-
-from django.views.generic import (
- TemplateView, CreateView, UpdateView, DetailView, ListView
-)
-from django.views.generic.edit import SingleObjectMixin
-from django.conf import settings
-
-from common.permissions import PermissionsMixin, IsOrgAdmin
-from users.models import UserGroup
-from applications.models import DatabaseApp
-from assets.models import SystemUser
-
-from .. import models, forms
-
-
-__all__ = [
- 'DatabaseAppPermissionListView', 'DatabaseAppPermissionCreateView',
- 'DatabaseAppPermissionUpdateView', 'DatabaseAppPermissionDetailView',
- 'DatabaseAppPermissionUserView', 'DatabaseAppPermissionDatabaseAppView',
-]
-
-
-class DatabaseAppPermissionListView(PermissionsMixin, TemplateView):
- template_name = 'perms/database_app_permission_list.html'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Perms'),
- 'action': _('DatabaseApp permission list')
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class DatabaseAppPermissionCreateView(PermissionsMixin, CreateView):
- template_name = 'perms/database_app_permission_create_update.html'
- model = models.DatabaseAppPermission
- form_class = forms.DatabaseAppPermissionCreateUpdateForm
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Perms'),
- 'action': _('Create DatabaseApp permission'),
- 'api_action': 'create',
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class DatabaseAppPermissionUpdateView(PermissionsMixin, UpdateView):
- template_name = 'perms/database_app_permission_create_update.html'
- model = models.DatabaseAppPermission
- form_class = forms.DatabaseAppPermissionCreateUpdateForm
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Perms'),
- 'action': _('Update DatabaseApp permission'),
- 'api_action': 'update'
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class DatabaseAppPermissionDetailView(PermissionsMixin, DetailView):
- template_name = 'perms/database_app_permission_detail.html'
- model = models.DatabaseAppPermission
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Perms'),
- 'action': _('DatabaseApp permission detail')
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class DatabaseAppPermissionUserView(PermissionsMixin,
- SingleObjectMixin,
- ListView):
- template_name = 'perms/database_app_permission_user.html'
- context_object_name = 'database_app_permission'
- paginate_by = settings.DISPLAY_PER_PAGE
- object = None
- permission_classes = [IsOrgAdmin]
-
- def get(self, request, *args, **kwargs):
- self.object = self.get_object(queryset=models.DatabaseAppPermission.objects.all())
- return super().get(request, *args, **kwargs)
-
- def get_queryset(self):
- queryset = list(self.object.get_all_users())
- return queryset
-
- def get_context_data(self, **kwargs):
- users = [str(i) for i in self.object.users.all().values_list('id', flat=True)]
- user_groups_remain = UserGroup.objects.exclude(
- databaseapppermission=self.object)
- context = {
- 'app': _('Perms'),
- 'action': _('DatabaseApp permission user list'),
- 'users': users,
- 'user_groups_remain': user_groups_remain,
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class DatabaseAppPermissionDatabaseAppView(PermissionsMixin,
- SingleObjectMixin,
- ListView):
- template_name = 'perms/database_app_permission_database_app.html'
- context_object_name = 'database_app_permission'
- paginate_by = settings.DISPLAY_PER_PAGE
- object = None
- permission_classes = [IsOrgAdmin]
-
- def get(self, request, *args, **kwargs):
- self.object = self.get_object(
- queryset=models.DatabaseAppPermission.objects.all()
- )
- return super().get(request, *args, **kwargs)
-
- def get_queryset(self):
- queryset = list(self.object.get_all_database_apps())
- return queryset
-
- def get_context_data(self, **kwargs):
- database_apps = self.object.get_all_database_apps().values_list('id', flat=True)
- database_apps = [str(i) for i in database_apps]
- system_users_remain = SystemUser.objects\
- .exclude(granted_by_database_app_permissions=self.object)\
- .filter(protocol=SystemUser.PROTOCOL_MYSQL)
- context = {
- 'app': _('Perms'),
- 'database_apps': database_apps,
- 'database_apps_remain': DatabaseApp.objects.exclude(
- granted_by_permissions=self.object
- ),
- 'system_users_remain': system_users_remain,
- 'action': _('DatabaseApp permission DatabaseApp list'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
diff --git a/apps/perms/views/remote_app_permission.py b/apps/perms/views/remote_app_permission.py
deleted file mode 100644
index 875600c68..000000000
--- a/apps/perms/views/remote_app_permission.py
+++ /dev/null
@@ -1,155 +0,0 @@
-# coding: utf-8
-#
-
-from django.utils.translation import ugettext as _
-from django.urls import reverse_lazy
-from django.views.generic import (
- TemplateView, CreateView, UpdateView, DetailView, ListView
-)
-from django.views.generic.edit import SingleObjectMixin
-from django.conf import settings
-
-from common.permissions import PermissionsMixin, IsOrgAdmin
-from orgs.utils import current_org
-
-from ..hands import RemoteApp, UserGroup, SystemUser
-from ..models import RemoteAppPermission
-from ..forms import RemoteAppPermissionCreateUpdateForm
-
-
-__all__ = [
- 'RemoteAppPermissionListView', 'RemoteAppPermissionCreateView',
- 'RemoteAppPermissionUpdateView', 'RemoteAppPermissionDetailView',
- 'RemoteAppPermissionUserView', 'RemoteAppPermissionRemoteAppView'
-]
-
-
-class RemoteAppPermissionListView(PermissionsMixin, TemplateView):
- template_name = 'perms/remote_app_permission_list.html'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Perms'),
- 'action': _('RemoteApp permission list'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class RemoteAppPermissionCreateView(PermissionsMixin, CreateView):
- template_name = 'perms/remote_app_permission_create_update.html'
- model = RemoteAppPermission
- form_class = RemoteAppPermissionCreateUpdateForm
- success_url = reverse_lazy('perms:remote-app-permission-list')
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Perms'),
- 'action': _('Create RemoteApp permission'),
- 'api_action': 'create'
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class RemoteAppPermissionUpdateView(PermissionsMixin, UpdateView):
- template_name = 'perms/remote_app_permission_create_update.html'
- model = RemoteAppPermission
- form_class = RemoteAppPermissionCreateUpdateForm
- success_url = reverse_lazy('perms:remote-app-permission-list')
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Perms'),
- 'action': _('Update RemoteApp permission'),
- 'api_action': 'update'
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class RemoteAppPermissionDetailView(PermissionsMixin, DetailView):
- template_name = 'perms/remote_app_permission_detail.html'
- model = RemoteAppPermission
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- system_users_remain = SystemUser.objects\
- .exclude(granted_by_remote_app_permissions=self.object)\
- .filter(protocol=SystemUser.PROTOCOL_RDP)
- context = {
- 'app': _('Perms'),
- 'action': _('RemoteApp permission detail'),
- 'system_users_remain': system_users_remain,
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class RemoteAppPermissionUserView(PermissionsMixin,
- SingleObjectMixin,
- ListView):
- template_name = 'perms/remote_app_permission_user.html'
- context_object_name = 'remote_app_permission'
- paginate_by = settings.DISPLAY_PER_PAGE
- object = None
- permission_classes = [IsOrgAdmin]
-
- def get(self, request, *args, **kwargs):
- self.object = self.get_object(
- queryset=RemoteAppPermission.objects.all())
- return super().get(request, *args, **kwargs)
-
- def get_queryset(self):
- queryset = list(self.object.get_all_users())
- return queryset
-
- def get_context_data(self, **kwargs):
- user_remain = current_org.get_org_members(exclude=('Auditor',))\
- .exclude(remoteapppermission=self.object)
- user_groups_remain = UserGroup.objects\
- .exclude(remoteapppermission=self.object)
- context = {
- 'app': _('Perms'),
- 'action': _('RemoteApp permission user list'),
- 'users_remain': user_remain,
- 'user_groups_remain': user_groups_remain,
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class RemoteAppPermissionRemoteAppView(PermissionsMixin,
- SingleObjectMixin,
- ListView):
- template_name = 'perms/remote_app_permission_remote_app.html'
- context_object_name = 'remote_app_permission'
- paginate_by = settings.DISPLAY_PER_PAGE
- object = None
- permission_classes = [IsOrgAdmin]
-
- def get(self, request, *args, **kwargs):
- self.object = self.get_object(
- queryset=RemoteAppPermission.objects.all()
- )
- return super().get(request, *args, **kwargs)
-
- def get_queryset(self):
- queryset = list(self.object.get_all_remote_apps())
- return queryset
-
- def get_context_data(self, **kwargs):
- remote_app_granted = self.get_queryset()
- remote_app_remain = RemoteApp.objects.exclude(
- id__in=[a.id for a in remote_app_granted])
- context = {
- 'app': _('Perms'),
- 'action': _('RemoteApp permission RemoteApp list'),
- 'remote_app_remain': remote_app_remain
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
diff --git a/apps/settings/forms/__init__.py b/apps/settings/forms/__init__.py
deleted file mode 100644
index 4c5a69e8c..000000000
--- a/apps/settings/forms/__init__.py
+++ /dev/null
@@ -1,9 +0,0 @@
-# coding: utf-8
-#
-
-from .base import *
-from .basic import *
-from .email import *
-from .ldap import *
-from .security import *
-from .terminal import *
diff --git a/apps/settings/forms/base.py b/apps/settings/forms/base.py
deleted file mode 100644
index b7b32dea6..000000000
--- a/apps/settings/forms/base.py
+++ /dev/null
@@ -1,57 +0,0 @@
-# coding: utf-8
-#
-
-import json
-from django import forms
-from django.db import transaction
-from django.conf import settings
-
-from ..models import Setting
-from common.fields import FormEncryptMixin
-
-__all__ = ['BaseForm']
-
-
-class BaseForm(forms.Form):
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
- for name, field in self.fields.items():
- value = getattr(settings, name, None)
- if value is None: # and django_value is None:
- continue
-
- if value is not None:
- if isinstance(value, dict):
- value = json.dumps(value)
- initial_value = value
- else:
- initial_value = ''
- field.initial = initial_value
-
- def save(self, category="default"):
- if not self.is_bound:
- raise ValueError("Form is not bound")
-
- # db_settings = Setting.objects.all()
- if not self.is_valid():
- raise ValueError(self.errors)
-
- with transaction.atomic():
- for name, value in self.cleaned_data.items():
- field = self.fields[name]
- if isinstance(field.widget, forms.PasswordInput) and not value:
- continue
- # if value == getattr(settings, name):
- # continue
-
- encrypted = True if isinstance(field, FormEncryptMixin) else False
- try:
- setting = Setting.objects.get(name=name)
- except Setting.DoesNotExist:
- setting = Setting()
- setting.name = name
- setting.category = category
- setting.encrypted = encrypted
- setting.cleaned_value = value
- setting.save()
-
diff --git a/apps/settings/forms/basic.py b/apps/settings/forms/basic.py
deleted file mode 100644
index dd93c9537..000000000
--- a/apps/settings/forms/basic.py
+++ /dev/null
@@ -1,24 +0,0 @@
-# coding: utf-8
-#
-
-from django import forms
-from django.utils.translation import ugettext_lazy as _
-from .base import BaseForm
-
-__all__ = ['BasicSettingForm']
-
-
-class BasicSettingForm(BaseForm):
- SITE_URL = forms.URLField(
- label=_("Current SITE URL"),
- help_text="eg: http://jumpserver.abc.com:8080"
- )
- USER_GUIDE_URL = forms.URLField(
- label=_("User Guide URL"), required=False,
- help_text=_("User first login update profile done redirect to it")
- )
- EMAIL_SUBJECT_PREFIX = forms.CharField(
- max_length=1024, label=_("Email Subject Prefix"),
- help_text=_("Tips: Some word will be intercept by mail provider")
- )
-
diff --git a/apps/settings/forms/email.py b/apps/settings/forms/email.py
deleted file mode 100644
index 6fa61148a..000000000
--- a/apps/settings/forms/email.py
+++ /dev/null
@@ -1,65 +0,0 @@
-# coding: utf-8
-#
-
-from django import forms
-from django.utils.translation import ugettext_lazy as _
-
-from common.fields import FormEncryptCharField
-from .base import BaseForm
-
-__all__ = ['EmailSettingForm', 'EmailContentSettingForm']
-
-
-class EmailSettingForm(BaseForm):
- EMAIL_HOST = forms.CharField(
- max_length=1024, label=_("SMTP host"), initial='smtp.jumpserver.org'
- )
- EMAIL_PORT = forms.CharField(max_length=5, label=_("SMTP port"), initial=25)
- EMAIL_HOST_USER = forms.CharField(
- max_length=128, label=_("SMTP user"), initial='noreply@jumpserver.org'
- )
- EMAIL_HOST_PASSWORD = FormEncryptCharField(
- max_length=1024, label=_("SMTP password"), widget=forms.PasswordInput,
- required=False,
- help_text=_("Tips: Some provider use token except password")
- )
- EMAIL_FROM = forms.CharField(
- max_length=128, label=_("Send user"), initial='', required=False,
- help_text=_(
- "Tips: Send mail account, default SMTP account as the send account"
- )
- )
- EMAIL_RECIPIENT = forms.CharField(
- max_length=128, label=_("Test recipient"), initial='', required=False,
- help_text=_("Tips: Used only as a test mail recipient")
- )
- EMAIL_USE_SSL = forms.BooleanField(
- label=_("Use SSL"), initial=False, required=False,
- help_text=_("If SMTP port is 465, may be select")
- )
- EMAIL_USE_TLS = forms.BooleanField(
- label=_("Use TLS"), initial=False, required=False,
- help_text=_("If SMTP port is 587, may be select")
- )
-
-
-class EmailContentSettingForm(BaseForm):
- EMAIL_CUSTOM_USER_CREATED_SUBJECT = forms.CharField(
- max_length=1024, required=False, label=_("Create user email subject"),
- help_text=_("Tips: When creating a user, send the subject of the email"
- " (eg:Create account successfully)")
- )
- EMAIL_CUSTOM_USER_CREATED_HONORIFIC = forms.CharField(
- max_length=1024, required=False, label=_("Create user honorific"),
- help_text=_("Tips: When creating a user, send the honorific of the "
- "email (eg:Hello)")
- )
- EMAIL_CUSTOM_USER_CREATED_BODY = forms.CharField(
- max_length=4096, required=False, widget=forms.Textarea(),
- label=_('Create user email content'),
- help_text=_('Tips:When creating a user, send the content of the email')
- )
- EMAIL_CUSTOM_USER_CREATED_SIGNATURE = forms.CharField(
- max_length=512, required=False, label=_("Signature"),
- help_text=_("Tips: Email signature (eg:jumpserver)")
- )
diff --git a/apps/settings/forms/ldap.py b/apps/settings/forms/ldap.py
deleted file mode 100644
index c44d1c3e4..000000000
--- a/apps/settings/forms/ldap.py
+++ /dev/null
@@ -1,46 +0,0 @@
-# coding: utf-8
-#
-
-from django import forms
-from django.utils.translation import ugettext_lazy as _
-
-from common.fields import FormDictField, FormEncryptCharField
-from .base import BaseForm
-
-
-__all__ = ['LDAPSettingForm']
-
-
-class LDAPSettingForm(BaseForm):
- AUTH_LDAP_SERVER_URI = forms.CharField(
- label=_("LDAP server"),
- )
- AUTH_LDAP_BIND_DN = forms.CharField(
- required=False, label=_("Bind DN"),
- )
- AUTH_LDAP_BIND_PASSWORD = FormEncryptCharField(
- label=_("Password"),
- widget=forms.PasswordInput, required=False
- )
- AUTH_LDAP_SEARCH_OU = forms.CharField(
- label=_("User OU"),
- help_text=_("Use | split User OUs"),
- required=False,
- )
- AUTH_LDAP_SEARCH_FILTER = forms.CharField(
- label=_("User search filter"),
- help_text=_("Choice may be (cn|uid|sAMAccountName)=%(user)s)")
- )
- AUTH_LDAP_USER_ATTR_MAP = FormDictField(
- label=_("User attr map"),
- help_text=_(
- "User attr map present how to map LDAP user attr to jumpserver, "
- "username,name,email is jumpserver attr"
- ),
- )
- # AUTH_LDAP_GROUP_SEARCH_OU = CONFIG.AUTH_LDAP_GROUP_SEARCH_OU
- # AUTH_LDAP_GROUP_SEARCH_FILTER = CONFIG.AUTH_LDAP_GROUP_SEARCH_FILTER
- # AUTH_LDAP_START_TLS = forms.BooleanField(
- # label=_("Use SSL"), required=False
- # )
- AUTH_LDAP = forms.BooleanField(label=_("Enable LDAP auth"), required=False)
diff --git a/apps/settings/forms/security.py b/apps/settings/forms/security.py
deleted file mode 100644
index 6d30d8b73..000000000
--- a/apps/settings/forms/security.py
+++ /dev/null
@@ -1,93 +0,0 @@
-# coding: utf-8
-#
-
-from django import forms
-from django.utils.translation import ugettext_lazy as _
-
-from .base import BaseForm
-
-
-__all__ = ['SecuritySettingForm']
-
-
-class SecuritySettingForm(BaseForm):
- # MFA global setting
- SECURITY_MFA_AUTH = forms.BooleanField(
- required=False, label=_("MFA"),
- help_text=_(
- 'After opening, all user login must use MFA'
- '(valid for all users, including administrators)'
- )
- )
- # Execute commands for user
- SECURITY_COMMAND_EXECUTION = forms.BooleanField(
- required=False, label=_("Batch execute commands"),
- help_text=_("Allow user batch execute commands")
- )
- SECURITY_SERVICE_ACCOUNT_REGISTRATION = forms.BooleanField(
- required=False, label=_("Service account registration"),
- help_text=_("Allow using bootstrap token register service account, "
- "when terminal setup, can disable it")
- )
- # limit login count
- SECURITY_LOGIN_LIMIT_COUNT = forms.IntegerField(
- min_value=3, max_value=99999,
- label=_("Limit the number of login failures")
- )
- # limit login time
- SECURITY_LOGIN_LIMIT_TIME = forms.IntegerField(
- min_value=5, max_value=99999, label=_("No logon interval"),
- help_text=_(
- "Tip: (unit/minute) if the user has failed to log in for a limited "
- "number of times, no login is allowed during this time interval."
- )
- )
- # ssh max idle time
- SECURITY_MAX_IDLE_TIME = forms.IntegerField(
- min_value=1, max_value=99999, required=False,
- label=_("Connection max idle time"),
- help_text=_(
- 'If idle time more than it, disconnect connection '
- 'Unit: minute'
- ),
- )
- # password expiration time
- SECURITY_PASSWORD_EXPIRATION_TIME = forms.IntegerField(
- min_value=1, max_value=99999, label=_("Password expiration time"),
- help_text=_(
- "Tip: (unit: day) "
- "If the user does not update the password during the time, "
- "the user password will expire failure;"
- "The password expiration reminder mail will be automatic sent to the user "
- "by system within 5 days (daily) before the password expires"
- )
- )
- # min length
- SECURITY_PASSWORD_MIN_LENGTH = forms.IntegerField(
- min_value=6, max_value=30, label=_("Password minimum length"),
- )
- # upper case
- SECURITY_PASSWORD_UPPER_CASE = forms.BooleanField(
- required=False, label=_("Must contain capital letters"),
- help_text=_(
- 'After opening, the user password changes '
- 'and resets must contain uppercase letters')
- )
- # lower case
- SECURITY_PASSWORD_LOWER_CASE = forms.BooleanField(
- required=False, label=_("Must contain lowercase letters"),
- help_text=_('After opening, the user password changes '
- 'and resets must contain lowercase letters')
- )
- # number
- SECURITY_PASSWORD_NUMBER = forms.BooleanField(
- required=False, label=_("Must contain numeric characters"),
- help_text=_('After opening, the user password changes '
- 'and resets must contain numeric characters')
- )
- # special char
- SECURITY_PASSWORD_SPECIAL_CHAR = forms.BooleanField(
- required=False, label=_("Must contain special characters"),
- help_text=_('After opening, the user password changes '
- 'and resets must contain special characters')
- )
diff --git a/apps/settings/forms/terminal.py b/apps/settings/forms/terminal.py
deleted file mode 100644
index d879e88d2..000000000
--- a/apps/settings/forms/terminal.py
+++ /dev/null
@@ -1,50 +0,0 @@
-# coding: utf-8
-#
-
-
-from django import forms
-from django.utils.translation import ugettext_lazy as _
-
-from .base import BaseForm
-
-__all__ = ['TerminalSettingForm']
-
-
-class TerminalSettingForm(BaseForm):
- SORT_BY_CHOICES = (
- ('hostname', _('Hostname')),
- ('ip', _('IP')),
- )
- PAGE_SIZE_CHOICES = (
- ('all', _('All')),
- ('auto', _('Auto')),
- (10, 10),
- (15, 15),
- (25, 25),
- (50, 50),
- )
- TERMINAL_PASSWORD_AUTH = forms.BooleanField(
- required=False, label=_("Password auth")
- )
- TERMINAL_PUBLIC_KEY_AUTH = forms.BooleanField(
- required=False, label=_("Public key auth")
- )
- TERMINAL_HEARTBEAT_INTERVAL = forms.IntegerField(
- min_value=5, max_value=99999, label=_("Heartbeat interval"),
- help_text=_("Units: seconds")
- )
- TERMINAL_ASSET_LIST_SORT_BY = forms.ChoiceField(
- choices=SORT_BY_CHOICES, label=_("List sort by")
- )
- TERMINAL_ASSET_LIST_PAGE_SIZE = forms.ChoiceField(
- choices=PAGE_SIZE_CHOICES, label=_("List page size"),
- )
- TERMINAL_SESSION_KEEP_DURATION = forms.IntegerField(
- min_value=1, max_value=99999, label=_("Session keep duration"),
- help_text=_("Units: days, Session, record, command will be delete "
- "if more than duration, only in database")
- )
- TERMINAL_TELNET_REGEX = forms.CharField(
- required=False, label=_("Telnet login regex"),
- help_text=_("ex: Last\s*login|success|成功")
- )
diff --git a/apps/settings/templates/settings/_ldap_list_users_modal.html b/apps/settings/templates/settings/_ldap_list_users_modal.html
deleted file mode 100644
index 8589b0066..000000000
--- a/apps/settings/templates/settings/_ldap_list_users_modal.html
+++ /dev/null
@@ -1,176 +0,0 @@
-{% extends '_modal.html' %}
-{% load i18n %}
-{% load static %}
-
-{% block modal_class %}modal-lg{% endblock %}
-{% block modal_id %}ldap_list_users_modal{% endblock %}
-{% block modal_title%}{% trans "LDAP user list" %}{% endblock %}
-
-{% block modal_help_message%} {% trans 'Please submit the LDAP configuration before import' %}
{% endblock %}
-
-{% block modal_body %}
-
-
-
-
-
-
-
-
-{% endblock %}
-
-{% block modal_button %}
- {% trans "Close" %}
- {% trans 'Import' %}
-{% endblock %}
-
-
-
diff --git a/apps/settings/templates/settings/_ldap_test_user_login_modal.html b/apps/settings/templates/settings/_ldap_test_user_login_modal.html
deleted file mode 100644
index 3359d2468..000000000
--- a/apps/settings/templates/settings/_ldap_test_user_login_modal.html
+++ /dev/null
@@ -1,58 +0,0 @@
-{% extends '_modal.html' %}
-{% load i18n %}
-{% block modal_id %}test_user_login_modal{% endblock %}
-{% block modal_title%}{% trans "Test LDAP user login" %}{% endblock %}
-{% block modal_comment %}{% trans "Save the configuration before testing the login" %}{% endblock %}
-{% block modal_body %}
-
-
-{% endblock %}
-{% block modal_confirm_id %}btn_test_user_login_modal_confirm{% endblock %}
diff --git a/apps/settings/templates/settings/_setting_tabs.html b/apps/settings/templates/settings/_setting_tabs.html
deleted file mode 100644
index b012a6669..000000000
--- a/apps/settings/templates/settings/_setting_tabs.html
+++ /dev/null
@@ -1,37 +0,0 @@
-{% load i18n %}
-
-
-
diff --git a/apps/settings/templates/settings/basic_setting.html b/apps/settings/templates/settings/basic_setting.html
deleted file mode 100644
index ac8cabb8b..000000000
--- a/apps/settings/templates/settings/basic_setting.html
+++ /dev/null
@@ -1,64 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load bootstrap3 %}
-{% load i18n %}
-{% load common_tags %}
-
-{% block content %}
-
-
-
-
-
- {% include 'settings/_setting_tabs.html' %}
-
-
-
-
-
-
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/settings/templates/settings/email_content_setting.html b/apps/settings/templates/settings/email_content_setting.html
deleted file mode 100644
index c2c5b2720..000000000
--- a/apps/settings/templates/settings/email_content_setting.html
+++ /dev/null
@@ -1,52 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load bootstrap3 %}
-{% load i18n %}
-{% load common_tags %}
-
-{% block content %}
-
-
-
-
-
- {% include 'settings/_setting_tabs.html' %}
-
-
-
-
-
-
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/settings/templates/settings/email_setting.html b/apps/settings/templates/settings/email_setting.html
deleted file mode 100644
index d62a921cd..000000000
--- a/apps/settings/templates/settings/email_setting.html
+++ /dev/null
@@ -1,91 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load bootstrap3 %}
-{% load i18n %}
-{% load common_tags %}
-
-{% block content %}
-
-
-
-
-
- {% include 'settings/_setting_tabs.html' %}
-
-
-
-
-
-
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/settings/templates/settings/ldap_setting.html b/apps/settings/templates/settings/ldap_setting.html
deleted file mode 100644
index 42902391b..000000000
--- a/apps/settings/templates/settings/ldap_setting.html
+++ /dev/null
@@ -1,99 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load bootstrap3 %}
-{% load i18n %}
-{% load common_tags %}
-
-{% block content %}
-
-
-
-
-
- {% include 'settings/_setting_tabs.html' %}
-
-
-
-
-
-
-
- {% include 'settings/_ldap_list_users_modal.html' %}
- {% include 'settings/_ldap_test_user_login_modal.html' %}
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/settings/templates/settings/security_setting.html b/apps/settings/templates/settings/security_setting.html
deleted file mode 100644
index 663632a72..000000000
--- a/apps/settings/templates/settings/security_setting.html
+++ /dev/null
@@ -1,71 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load bootstrap3 %}
-{% load i18n %}
-{% load common_tags %}
-
-{% block content %}
-
-
-
-
-
- {% include 'settings/_setting_tabs.html' %}
-
-
-
-
-
-
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/settings/templates/settings/terminal_setting.html b/apps/settings/templates/settings/terminal_setting.html
deleted file mode 100644
index a0b35aabb..000000000
--- a/apps/settings/templates/settings/terminal_setting.html
+++ /dev/null
@@ -1,72 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load bootstrap3 %}
-{% load i18n %}
-{% load common_tags %}
-{% block help_message %}
- {% trans "Command and Replay storage configuration migrated to" %}
- {% trans "Sessions -> Terminal -> Storage configuration" %}
- {% trans 'Here' %}
-{% endblock %}
-
-{% block content %}
-
-
-
-
-
- {% include 'settings/_setting_tabs.html' %}
-
-
-
-
-
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/settings/urls/view_urls.py b/apps/settings/urls/view_urls.py
deleted file mode 100644
index 6a1c5baaf..000000000
--- a/apps/settings/urls/view_urls.py
+++ /dev/null
@@ -1,16 +0,0 @@
-from __future__ import absolute_import
-
-from django.conf.urls import url
-
-from .. import views
-
-app_name = 'common'
-
-urlpatterns = [
- url(r'^$', views.BasicSettingView.as_view(), name='basic-setting'),
- url(r'^email/$', views.EmailSettingView.as_view(), name='email-setting'),
- url(r'^email-content/$', views.EmailContentSettingView.as_view(), name='email-content-setting'),
- url(r'^ldap/$', views.LDAPSettingView.as_view(), name='ldap-setting'),
- url(r'^terminal/$', views.TerminalSettingView.as_view(), name='terminal-setting'),
- url(r'^security/$', views.SecuritySettingView.as_view(), name='security-setting'),
-]
diff --git a/apps/settings/views.py b/apps/settings/views.py
deleted file mode 100644
index 6ebbeef97..000000000
--- a/apps/settings/views.py
+++ /dev/null
@@ -1,178 +0,0 @@
-from django.views.generic import TemplateView
-from django.shortcuts import render, redirect
-from django.contrib import messages
-from django.utils.translation import ugettext as _
-
-from common.permissions import PermissionsMixin, IsSuperUser
-from .utils import LDAPSyncUtil
-from .forms import EmailSettingForm, LDAPSettingForm, BasicSettingForm, \
- TerminalSettingForm, SecuritySettingForm, EmailContentSettingForm
-
-
-class BasicSettingView(PermissionsMixin, TemplateView):
- form_class = BasicSettingForm
- template_name = "settings/basic_setting.html"
- permission_classes = [IsSuperUser]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Settings'),
- 'action': _('Basic setting'),
- 'form': self.form_class(),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
- def post(self, request):
- form = self.form_class(request.POST)
- if form.is_valid():
- form.save()
- msg = _("Update setting successfully")
- messages.success(request, msg)
- return redirect('settings:basic-setting')
- else:
- context = self.get_context_data()
- context.update({"form": form})
- return render(request, self.template_name, context)
-
-
-class EmailSettingView(PermissionsMixin, TemplateView):
- form_class = EmailSettingForm
- template_name = "settings/email_setting.html"
- permission_classes = [IsSuperUser]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Settings'),
- 'action': _('Email setting'),
- 'form': self.form_class(),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
- def post(self, request):
- form = self.form_class(request.POST)
- if form.is_valid():
- form.save()
- msg = _("Update setting successfully")
- messages.success(request, msg)
- return redirect('settings:email-setting')
- else:
- context = self.get_context_data()
- context.update({"form": form})
- return render(request, self.template_name, context)
-
-
-class LDAPSettingView(PermissionsMixin, TemplateView):
- form_class = LDAPSettingForm
- template_name = "settings/ldap_setting.html"
- permission_classes = [IsSuperUser]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Settings'),
- 'action': _('LDAP setting'),
- 'form': self.form_class(),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
- def post(self, request):
- form = self.form_class(request.POST)
- if form.is_valid():
- form.save()
- msg = _("Update setting successfully")
- messages.success(request, msg)
- LDAPSyncUtil().clear_cache()
- return redirect('settings:ldap-setting')
- else:
- context = self.get_context_data()
- context.update({"form": form})
- return render(request, self.template_name, context)
-
-
-class TerminalSettingView(PermissionsMixin, TemplateView):
- form_class = TerminalSettingForm
- template_name = "settings/terminal_setting.html"
- permission_classes = [IsSuperUser]
-
- def get_context_data(self, **kwargs):
- from terminal.models import CommandStorage, ReplayStorage
- command_storage = CommandStorage.objects.all()
- replay_storage = ReplayStorage.objects.all()
-
- context = {
- 'app': _('Settings'),
- 'action': _('Terminal setting'),
- 'form': self.form_class(),
- 'replay_storage': replay_storage,
- 'command_storage': command_storage
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
- def post(self, request):
- form = self.form_class(request.POST)
- if form.is_valid():
- form.save()
- msg = _("Update setting successfully")
- messages.success(request, msg)
- return redirect('settings:terminal-setting')
- else:
- context = self.get_context_data()
- context.update({"form": form})
- return render(request, self.template_name, context)
-
-
-class SecuritySettingView(PermissionsMixin, TemplateView):
- form_class = SecuritySettingForm
- template_name = "settings/security_setting.html"
- permission_classes = [IsSuperUser]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Settings'),
- 'action': _('Security setting'),
- 'form': self.form_class(),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
- def post(self, request):
- form = self.form_class(request.POST)
- if form.is_valid():
- form.save()
- msg = _("Update setting successfully")
- messages.success(request, msg)
- return redirect('settings:security-setting')
- else:
- context = self.get_context_data()
- context.update({"form": form})
- return render(request, self.template_name, context)
-
-
-class EmailContentSettingView(PermissionsMixin, TemplateView):
- template_name = "settings/email_content_setting.html"
- form_class = EmailContentSettingForm
- permission_classes = [IsSuperUser]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Settings'),
- 'action': _('Email content setting'),
- 'form': self.form_class(),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
- def post(self, request):
- form = self.form_class(request.POST)
- if form.is_valid():
- form.save()
- msg = _("Update setting successfully")
- messages.success(request, msg)
- return redirect('settings:email-content-setting')
- else:
- context = self.get_context_data()
- context.update({"form": form})
- return render(request, self.template_name, context)
diff --git a/apps/terminal/forms/__init__.py b/apps/terminal/forms/__init__.py
deleted file mode 100644
index 23c06a94c..000000000
--- a/apps/terminal/forms/__init__.py
+++ /dev/null
@@ -1,5 +0,0 @@
-# coding: utf-8
-#
-
-from .terminal import *
-from .storage import *
diff --git a/apps/terminal/forms/storage.py b/apps/terminal/forms/storage.py
deleted file mode 100644
index 3b586560c..000000000
--- a/apps/terminal/forms/storage.py
+++ /dev/null
@@ -1,165 +0,0 @@
-# coding: utf-8
-#
-
-from django import forms
-from django.utils.translation import ugettext_lazy as _
-
-from terminal.models import ReplayStorage, CommandStorage
-
-
-__all__ = [
- 'ReplayStorageAzureForm', 'ReplayStorageOSSForm', 'ReplayStorageS3Form',
- 'ReplayStorageCephForm', 'ReplayStorageSwiftForm',
- 'CommandStorageTypeESForm',
-]
-
-
-class BaseStorageForm(forms.Form):
-
- def __init__(self, *args, **kwargs):
- super(BaseStorageForm, self).__init__(*args, **kwargs)
- self.fields['type'].widget.attrs['disabled'] = True
- self.fields.move_to_end('comment')
-
-
-class BaseReplayStorageForm(BaseStorageForm, forms.ModelForm):
-
- class Meta:
- model = ReplayStorage
- fields = ['name', 'type', 'comment']
-
-
-class BaseCommandStorageForm(BaseStorageForm, forms.ModelForm):
-
- class Meta:
- model = CommandStorage
- fields = ['name', 'type', 'comment']
-
-
-class ReplayStorageAzureForm(BaseReplayStorageForm):
- azure_container_name = forms.CharField(
- max_length=128, label=_('Container name'), required=False
- )
- azure_account_name = forms.CharField(
- max_length=128, label=_('Account name'), required=False
- )
- azure_account_key = forms.CharField(
- max_length=128, label=_('Account key'), required=False,
- widget=forms.PasswordInput
- )
- azure_endpoint_suffix = forms.ChoiceField(
- choices=(
- ('core.chinacloudapi.cn', 'core.chinacloudapi.cn'),
- ('core.windows.net', 'core.windows.net')
- ),
- label=_('Endpoint suffix'), required=False,
- )
-
-
-class ReplayStorageOSSForm(BaseReplayStorageForm):
- oss_bucket = forms.CharField(
- max_length=128, label=_('Bucket'), required=False
- )
- oss_access_key = forms.CharField(
- max_length=128, label=_('Access key'), required=False,
- widget=forms.PasswordInput
- )
- oss_secret_key = forms.CharField(
- max_length=128, label=_('Secret key'), required=False,
- widget=forms.PasswordInput
- )
- oss_endpoint = forms.CharField(
- max_length=128, label=_('Endpoint'), required=False,
- help_text=_(
- """
- OSS: http://{REGION_NAME}.aliyuncs.com
- Example: http://oss-cn-hangzhou.aliyuncs.com
- """
- )
- )
-
-
-class ReplayStorageS3Form(BaseReplayStorageForm):
- s3_bucket = forms.CharField(
- max_length=128, label=_('Bucket'), required=False
- )
- s3_access_key = forms.CharField(
- max_length=128, label=_('Access key'), required=False,
- widget=forms.PasswordInput
- )
- s3_secret_key = forms.CharField(
- max_length=128, label=_('Secret key'), required=False,
- widget=forms.PasswordInput
- )
- s3_endpoint = forms.CharField(
- max_length=128, label=_('Endpoint'), required=False,
- help_text=_(
- """
- S3: http://s3.{REGION_NAME}.amazonaws.com
- S3(China): http://s3.{REGION_NAME}.amazonaws.com.cn
- Example: http://s3.cn-north-1.amazonaws.com.cn
- """
- )
- )
-
-
-class ReplayStorageCephForm(BaseReplayStorageForm):
- ceph_bucket = forms.CharField(
- max_length=128, label=_('Bucket'), required=False
- )
- ceph_access_key = forms.CharField(
- max_length=128, label=_('Access key'), required=False,
- widget=forms.PasswordInput
- )
- ceph_secret_key = forms.CharField(
- max_length=128, label=_('Secret key'), required=False,
- widget=forms.PasswordInput
- )
- ceph_endpoint = forms.CharField(
- max_length=128, label=_('Endpoint'), required=False,
- )
-
-
-class ReplayStorageSwiftForm(BaseReplayStorageForm):
- swift_bucket = forms.CharField(
- max_length=128, label=_('Bucket'), required=False
- )
- swift_access_key = forms.CharField(
- max_length=128, label=_('Access key'), required=False,
- widget=forms.PasswordInput
- )
- swift_secret_key = forms.CharField(
- max_length=128, label=_('Secret key'), required=False,
- widget=forms.PasswordInput
- )
- swift_region = forms.CharField(
- max_length=128, label=_('Region'), required=False,
- )
- swift_endpoint = forms.CharField(
- max_length=128, label=_('Endpoint'), required=False,
- )
- swift_protocol = forms.ChoiceField(
- choices=(
- ('HTTP', 'http'),
- ('HTTPS', 'https')
- ), initial='http', label=_('Protocol'), required=True,
- )
-
-
-class CommandStorageTypeESForm(BaseCommandStorageForm):
- es_hosts = forms.CharField(
- max_length=128, label=_('Hosts'), required=True,
- help_text=_(
- """
- Tips: If there are multiple hosts, separate them with a comma (,)
-
- eg: http://www.jumpserver.a.com,http://www.jumpserver.b.com
- """
- )
- )
- es_index = forms.CharField(
- max_length=128, label=_('Index'), required=True
- )
- es_doc_type = forms.CharField(
- max_length=128, label=_('Doc type'), required=True
- )
diff --git a/apps/terminal/forms/terminal.py b/apps/terminal/forms/terminal.py
deleted file mode 100644
index 6051532d9..000000000
--- a/apps/terminal/forms/terminal.py
+++ /dev/null
@@ -1,39 +0,0 @@
-# coding: utf-8
-#
-
-__all__ = ['TerminalForm']
-
-from django import forms
-from django.utils.translation import ugettext_lazy as _
-
-from ..models import Terminal, ReplayStorage, CommandStorage
-
-
-def get_all_command_storage():
- for c in CommandStorage.objects.all():
- yield (c.name, c.name)
-
-
-def get_all_replay_storage():
- for r in ReplayStorage.objects.all():
- yield (r.name, r.name)
-
-
-class TerminalForm(forms.ModelForm):
- command_storage = forms.ChoiceField(
- choices=get_all_command_storage,
- label=_("Command storage"),
- help_text=_("Command can store in server db or ES, default to server, more see docs"),
- )
- replay_storage = forms.ChoiceField(
- choices=get_all_replay_storage,
- label=_("Replay storage"),
- help_text=_("Replay file can store in server disk, AWS S3, Aliyun OSS, default to server, more see docs"),
- )
-
- class Meta:
- model = Terminal
- fields = [
- 'name', 'remote_addr', 'comment',
- 'command_storage', 'replay_storage',
- ]
diff --git a/apps/terminal/templates/terminal/base_storage_create_update.html b/apps/terminal/templates/terminal/base_storage_create_update.html
deleted file mode 100644
index e432ecfda..000000000
--- a/apps/terminal/templates/terminal/base_storage_create_update.html
+++ /dev/null
@@ -1,59 +0,0 @@
-{% extends '_base_create_update.html' %}
-{% load static %}
-{% load bootstrap3 %}
-{% load i18n %}
-
-{% block form %}
-
-{% endblock %}
-
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/terminal/templates/terminal/base_storage_list.html b/apps/terminal/templates/terminal/base_storage_list.html
deleted file mode 100644
index d38fd88cc..000000000
--- a/apps/terminal/templates/terminal/base_storage_list.html
+++ /dev/null
@@ -1,129 +0,0 @@
-{% extends 'base.html' %}
-{% load i18n static %}
-
-{% block content %}
-
-
-
-
-
-
-
-
-
- {% block create_storage_info %}{% endblock %}
-
-
-
-
-
-
-
-
-
-
-{% endblock %}
-{% block content_bottom_left %}{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
-
diff --git a/apps/terminal/templates/terminal/command_list.html b/apps/terminal/templates/terminal/command_list.html
deleted file mode 100644
index 5fc7e36cf..000000000
--- a/apps/terminal/templates/terminal/command_list.html
+++ /dev/null
@@ -1,237 +0,0 @@
-{% extends '_base_list.html' %}
-{% load i18n %}
-{% load static %}
-{% load common_tags %}
-{% block custom_head_css_js %}
-
-
-{% endblock %}
-
-{% block table_pagination %}
-{% endblock %}
-
-{% block table_search %}
-{% endblock %}
-
-{% block table_container %}
-
-
-
-
- {% trans 'Command' %}
- {% trans 'Risk level' %}
- {% trans 'User' %}
- {% trans 'Asset' %}
- {% trans 'System user'%}
- {% trans 'Session' %}
- {% trans 'Datetime' %}
-
-
-
-
-
-
-
-
-
-{% include '_filter_dropdown.html' %}
-{% endblock %}
-{% block content_bottom_left %}{% endblock %}
-{% block custom_foot_js %}
-
-
-
-{% endblock %}
-
-
diff --git a/apps/terminal/templates/terminal/command_report.html b/apps/terminal/templates/terminal/command_report.html
deleted file mode 100644
index 3542c1423..000000000
--- a/apps/terminal/templates/terminal/command_report.html
+++ /dev/null
@@ -1,103 +0,0 @@
-{% load common_tags %}
-{% load static %}
-
-
-
-
- Command Report
-
-
-
-
-
-
-
Command Report
-
-
total: {{ total_count }}
-
date: {{ now | ts_to_date }}
-
-
-
-
-
- {% for command in queryset %}
-
-
- [{{ command.user}} {{ command.system_user }}@{{ command.asset }} {{ command.timestamp | ts_to_date }}]
- {{ forloop.counter }}
-
-
-
$ {{ command.input }}
-
-
{{ command.output }}
-
-
-
- {% endfor %}
-
-
-
-
-
\ No newline at end of file
diff --git a/apps/terminal/templates/terminal/command_storage_create_update.html b/apps/terminal/templates/terminal/command_storage_create_update.html
deleted file mode 100644
index 8abb976ae..000000000
--- a/apps/terminal/templates/terminal/command_storage_create_update.html
+++ /dev/null
@@ -1,30 +0,0 @@
-{% extends 'terminal/base_storage_create_update.html' %}
-{% load i18n static %}
-
-{% block custom_foot_js %}
-{{ block.super }}
-
-
-{% endblock %}
diff --git a/apps/terminal/templates/terminal/command_storage_list.html b/apps/terminal/templates/terminal/command_storage_list.html
deleted file mode 100644
index 724425cca..000000000
--- a/apps/terminal/templates/terminal/command_storage_list.html
+++ /dev/null
@@ -1,15 +0,0 @@
-{% extends 'terminal/base_storage_list.html' %}
-{% load i18n static %}
-
-{% block create_storage_url %}{% url "terminal:command-storage-create" %}{% endblock%}
-{% block create_storage_info %}{% trans 'Create command storage' %}{% endblock %}
-{% block custom_foot_js %}
-{{ block.super }}
-
-{% endblock %}
-
diff --git a/apps/terminal/templates/terminal/replay_storage_create_update.html b/apps/terminal/templates/terminal/replay_storage_create_update.html
deleted file mode 100644
index 878301d93..000000000
--- a/apps/terminal/templates/terminal/replay_storage_create_update.html
+++ /dev/null
@@ -1,25 +0,0 @@
-{% extends 'terminal/base_storage_create_update.html' %}
-{% load i18n static %}
-
-{% block custom_foot_js %}
-{{ block.super }}
-
-
-{% endblock %}
diff --git a/apps/terminal/templates/terminal/replay_storage_list.html b/apps/terminal/templates/terminal/replay_storage_list.html
deleted file mode 100644
index 786f4c844..000000000
--- a/apps/terminal/templates/terminal/replay_storage_list.html
+++ /dev/null
@@ -1,14 +0,0 @@
-{% extends 'terminal/base_storage_list.html' %}
-{% load i18n static %}
-
-{% block create_storage_url %}{% url "terminal:replay-storage-create" %}{% endblock%}
-{% block create_storage_info %}{% trans 'Create replay storage' %}{% endblock %}
-{% block custom_foot_js %}
-{{ block.super }}
-
-{% endblock %}
diff --git a/apps/terminal/templates/terminal/session_commands.html b/apps/terminal/templates/terminal/session_commands.html
deleted file mode 100644
index 3aeb2989f..000000000
--- a/apps/terminal/templates/terminal/session_commands.html
+++ /dev/null
@@ -1,96 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-{% load common_tags %}
-
-{% block custom_head_css_js %}
-
-
-{% endblock %}
-{% block content %}
-
-
-
-
-
-
-
-
-
-
{% trans 'Command list' %}
-
-
-
-
-
-
-
-
-
-
-{% endblock %}
-{% block custom_foot_js %}
-
-
-{% endblock %}
diff --git a/apps/terminal/templates/terminal/session_detail.html b/apps/terminal/templates/terminal/session_detail.html
deleted file mode 100644
index 1863ad75f..000000000
--- a/apps/terminal/templates/terminal/session_detail.html
+++ /dev/null
@@ -1,211 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-{% load common_tags %}
-
-{% block custom_head_css_js %}
-
-
-{% endblock %}
-{% block content %}
-
-
-
-
-
-
-
-
-
-
-
-
-
- {% trans 'User' %}:
- {{ object.user }}
-
-
- {% trans 'Asset' %}:
- {{ object.asset }}
-
-
- {% trans 'System user' %}:
- {{ object.system_user }}
-
-
- {% trans 'Protocol' %}:
- {{ object.protocol }}
-
-
- {% trans 'Login from' %}:
- {{ object.login_from_display }}
-
-
- {% trans 'Remote addr' %}:
- {{ object.remote_addr }}
-
-
- {% trans 'Date start' %}:
- {{ object.date_start }}
-
-
- {% trans 'Date end' %}:
- {{ object.date_end }}
-
-
-
-
-
-
-
-
-
- {% trans 'Quick modify' %}
-
-
-
-
- {% if object.is_finished %}
-
- {% trans 'Replay session' %}:
-
-
- {% trans 'Go' %}
-
-
-
-
- {% trans 'Download replay' %}:
-
-
- {% trans 'Download' %}
-
-
-
- {% else %}
-
-
-
-
-
-
-
-
-
- {% trans 'Terminate session' %}:
-
-
- {% trans 'Confirm' %}
-
-
-
- {% endif %}
-
-
-
-
-
-
-
-
-
-
-
-{% endblock %}
-{% block custom_foot_js %}
-
-
-
-
-{% endblock %}
diff --git a/apps/terminal/templates/terminal/session_list.html b/apps/terminal/templates/terminal/session_list.html
deleted file mode 100644
index c7e7dce6c..000000000
--- a/apps/terminal/templates/terminal/session_list.html
+++ /dev/null
@@ -1,322 +0,0 @@
-{% extends '_base_list.html' %}
-{% load i18n %}
-{% load static %}
-{% load terminal_tags %}
-{% load common_tags %}
-{% block custom_head_css_js %}
-
-{% endblock %}
-
-{% block content_left_head %}
-{% endblock %}
-
-{% block table_pagination %}
-{% endblock %}
-
-{% block table_search %}
-{% endblock %}
-
-{% block table_container %}
-
-
-
-
- {% trans 'ID' %}
- {% trans 'User' %}
- {% trans 'Asset' %}
- {% trans 'System user' %}
- {% trans 'Remote addr' %}
- {% trans 'Protocol' %}
- {% trans 'Login from' %}
- {% trans 'Command' %}
- {% trans 'Date start' %}
- {% trans 'Duration' %}
- {% trans 'Action' %}
-
-
-
-
-
-
-
- {% if type == "online" and request.user.can_admin_current_org %}
-
- {% endif %}
-
-
-
-
-
-{% endblock %}
-
-
-{% block custom_foot_js %}
-
-
-
-{% endblock %}
-
diff --git a/apps/terminal/templates/terminal/terminal_detail.html b/apps/terminal/templates/terminal/terminal_detail.html
deleted file mode 100644
index 14aff902c..000000000
--- a/apps/terminal/templates/terminal/terminal_detail.html
+++ /dev/null
@@ -1,77 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block content %}
-
-
-
-
-
-
-
-
-
-
{{ terminal.name }}
-
-
-
-
-
-
- {% trans 'Name' %}:
- {{ terminal.name }}
-
-
- {% trans 'Remote addr' %}:
- {{ terminal.remote_addr }}
-
-
- {% trans 'SSH port' %}:
- {{ terminal.ssh_port }}
-
-
- {% trans 'Http port' %}:
- {{ terminal.http_port }}
-
-
- {% trans 'Date created' %}:
- {{ terminal.date_created }}
-
-
- {% trans 'Comment' %}:
- {{ asset.comment }}
-
-
-
-
-
-
-
-
-
-
-
-{% endblock %}
-
diff --git a/apps/terminal/templates/terminal/terminal_list.html b/apps/terminal/templates/terminal/terminal_list.html
deleted file mode 100644
index f77949bfa..000000000
--- a/apps/terminal/templates/terminal/terminal_list.html
+++ /dev/null
@@ -1,144 +0,0 @@
-{% extends '_base_list.html' %}
-{% load i18n static %}
-{% block custom_head_css_js %}
-{{ block.super }}
-
-{% endblock %}
-
-{% block table_search %}{% endblock %}
-
-{% block table_container %}
-
-
-{% include 'terminal/terminal_modal_accept.html' %}
-{% endblock %}
-{% block custom_foot_js %}
-
-
-{% endblock %}
diff --git a/apps/terminal/templates/terminal/terminal_modal_accept.html b/apps/terminal/templates/terminal/terminal_modal_accept.html
deleted file mode 100644
index ae81ff95e..000000000
--- a/apps/terminal/templates/terminal/terminal_modal_accept.html
+++ /dev/null
@@ -1,21 +0,0 @@
-{% extends '_modal.html' %}
-{% load i18n %}
-{% block modal_id %}modal_terminal_accept{% endblock %}
-{% block modal_class %}modal-lg{% endblock %}
-{% block modal_title%}{% trans "Accept terminal registration" %}{% endblock %}
-{% block modal_body %}
-{% load bootstrap3 %}
-
-
-{% endblock %}
-{% block modal_confirm_id %}btn-confirm{% endblock %}
\ No newline at end of file
diff --git a/apps/terminal/templates/terminal/terminal_modal_test.html b/apps/terminal/templates/terminal/terminal_modal_test.html
deleted file mode 100644
index 862e39f62..000000000
--- a/apps/terminal/templates/terminal/terminal_modal_test.html
+++ /dev/null
@@ -1,5 +0,0 @@
-
\ No newline at end of file
diff --git a/apps/terminal/templates/terminal/terminal_update.html b/apps/terminal/templates/terminal/terminal_update.html
deleted file mode 100644
index e140cd678..000000000
--- a/apps/terminal/templates/terminal/terminal_update.html
+++ /dev/null
@@ -1,70 +0,0 @@
-{% extends 'base.html' %}
-{% load i18n %}
-{% load static %}
-{% load bootstrap3 %}
-{% block custom_head_css_js %}
-
-{% endblock %}
-
-{% block content %}
-
-{% endblock %}
-{% block custom_foot_js %}
-
-
-{% endblock %}
diff --git a/apps/terminal/templatetags/__init__.py b/apps/terminal/templatetags/__init__.py
deleted file mode 100644
index ec51c5a2b..000000000
--- a/apps/terminal/templatetags/__init__.py
+++ /dev/null
@@ -1,2 +0,0 @@
-# -*- coding: utf-8 -*-
-#
diff --git a/apps/terminal/templatetags/terminal_tags.py b/apps/terminal/templatetags/terminal_tags.py
deleted file mode 100644
index c0844eb31..000000000
--- a/apps/terminal/templatetags/terminal_tags.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# ~*~ coding: utf-8 ~*~
-
-from django import template
-
-from ..backends import get_multi_command_storage
-
-register = template.Library()
-
-
-@register.filter
-def get_session_command_amount(session_id):
- command_store = get_multi_command_storage()
- return command_store.count(session=session_id)
-
diff --git a/apps/terminal/urls/views_urls.py b/apps/terminal/urls/views_urls.py
deleted file mode 100644
index 048a79d71..000000000
--- a/apps/terminal/urls/views_urls.py
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-#
-
-from django.urls import path
-
-from .. import views
-
-app_name = 'terminal'
-
-urlpatterns = [
- # Terminal view
- path('terminal/', views.TerminalListView.as_view(), name='terminal-list'),
- path('terminal//', views.TerminalDetailView.as_view(), name='terminal-detail'),
- path('terminal//connect/', views.TerminalConnectView.as_view(), name='terminal-connect'),
- path('terminal//update/', views.TerminalUpdateView.as_view(), name='terminal-update'),
- path('/accept/', views.TerminalAcceptView.as_view(), name='terminal-accept'),
- path('web-terminal/', views.WebTerminalView.as_view(), name='web-terminal'),
- path('web-sftp/', views.WebSFTPView.as_view(), name='web-sftp'),
-
- # Session view
- path('session-online/', views.SessionOnlineListView.as_view(), name='session-online-list'),
- path('session-offline/', views.SessionOfflineListView.as_view(), name='session-offline-list'),
- path('session//', views.SessionDetailView.as_view(), name='session-detail'),
- path('session//commands/', views.SessionCommandsView.as_view(), name='session-commands'),
- path('session//replay/download/', views.SessionReplayDownloadView.as_view(), name='session-replay-download'),
-
- # Command view
- path('command/', views.CommandListView.as_view(), name='command-list'),
-
- # replay-storage
- path('terminal/replay-storage/', views.ReplayStorageListView.as_view(), name='replay-storage-list'),
- path('terminal/replay-storage/create/', views.ReplayStorageCreateView.as_view(), name='replay-storage-create'),
- path('terminal/replay-storage//update/', views.ReplayStorageUpdateView.as_view(), name='replay-storage-update'),
-
- # command-storage
- path('terminal/command-storage/', views.CommandStorageListView.as_view(), name='command-storage-list'),
- path('terminal/command-storage/create/', views.CommandStorageCreateView.as_view(), name='command-storage-create'),
- path('terminal/command-storage//update/', views.CommandStorageUpdateView.as_view(), name='command-storage-update'),
-
-]
diff --git a/apps/terminal/views/__init__.py b/apps/terminal/views/__init__.py
deleted file mode 100644
index a63c3cf9a..000000000
--- a/apps/terminal/views/__init__.py
+++ /dev/null
@@ -1,9 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-from .terminal import *
-from .session import *
-from .command import *
-from .storage import *
-
-# from .replay_storage import *
-# from .command_storage import *
diff --git a/apps/terminal/views/command.py b/apps/terminal/views/command.py
deleted file mode 100644
index 3ac31eed5..000000000
--- a/apps/terminal/views/command.py
+++ /dev/null
@@ -1,28 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-
-from django.views.generic import TemplateView
-from django.utils.translation import ugettext as _
-from django.utils import timezone
-
-from common.permissions import PermissionsMixin, IsOrgAdmin, IsOrgAuditor
-
-__all__ = ['CommandListView']
-
-
-class CommandListView(PermissionsMixin, TemplateView):
- template_name = "terminal/command_list.html"
- permission_classes = [IsOrgAdmin | IsOrgAuditor]
- default_days_ago = 5
-
- def get_context_data(self, **kwargs):
- now = timezone.now()
- context = {
- 'app': _('Sessions'),
- 'action': _('Command list'),
- 'date_from': now - timezone.timedelta(days=self.default_days_ago),
- 'date_to': now,
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
diff --git a/apps/terminal/views/session.py b/apps/terminal/views/session.py
deleted file mode 100644
index a7e56cd57..000000000
--- a/apps/terminal/views/session.py
+++ /dev/null
@@ -1,142 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-import os
-import tarfile
-
-from django.views.generic import ListView, TemplateView, DetailView
-from django.views.generic.edit import SingleObjectMixin
-from django.utils.translation import ugettext as _
-from django.utils import timezone
-from django.utils.encoding import escape_uri_path
-from django.http import FileResponse, HttpResponse
-from django.core.files.storage import default_storage
-
-from common.permissions import PermissionsMixin, IsOrgAdmin, IsOrgAuditor
-from common.utils import model_to_json
-from ..models import Session
-from ..backends import get_multi_command_storage
-from .. import utils
-
-
-__all__ = [
- 'SessionOnlineListView', 'SessionOfflineListView',
- 'SessionDetailView', 'SessionReplayDownloadView',
- 'SessionCommandsView',
-]
-
-
-class SessionListView(PermissionsMixin, TemplateView):
- model = Session
- template_name = 'terminal/session_list.html'
- date_from = date_to = None
- permission_classes = [IsOrgAdmin | IsOrgAuditor]
- default_days_ago = 5
-
- def get_context_data(self, **kwargs):
- now = timezone.now()
- context = {
- 'date_from': now - timezone.timedelta(days=self.default_days_ago),
- 'date_to': now,
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class SessionOnlineListView(SessionListView):
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Sessions'),
- 'action': _('Session online list'),
- 'type': 'online',
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class SessionOfflineListView(SessionListView):
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Sessions'),
- 'action': _('Session offline'),
- 'type': 'offline',
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class SessionDetailView(PermissionsMixin, DetailView):
- template_name = 'terminal/session_detail.html'
- model = Session
- permission_classes = [IsOrgAdmin | IsOrgAuditor]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Sessions'),
- 'action': _('Session detail'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class SessionCommandsView(SingleObjectMixin, PermissionsMixin, ListView):
- template_name = 'terminal/session_commands.html'
- model = Session
- object = None
- permission_classes = [IsOrgAdmin | IsOrgAuditor]
-
- def get(self, request, *args, **kwargs):
- self.object = self.get_object(queryset=self.model.objects.all())
- return super().get(request, *args, **kwargs)
-
- def get_queryset(self):
- command_store = get_multi_command_storage()
- return command_store.filter(session=self.object.id)
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Sessions'),
- 'action': _('Session detail'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class SessionReplayDownloadView(PermissionsMixin, DetailView):
- permission_classes = [IsOrgAdmin | IsOrgAuditor]
- model = Session
-
- @staticmethod
- def prepare_offline_file(session, local_path):
- replay_path = default_storage.path(local_path)
- current_dir = os.getcwd()
- dir_path = os.path.dirname(replay_path)
- replay_filename = os.path.basename(replay_path)
- meta_filename = '{}.json'.format(session.id)
- offline_filename = '{}.tar'.format(session.id)
- os.chdir(dir_path)
-
- with open(meta_filename, 'wt') as f:
- f.write(model_to_json(session))
-
- with tarfile.open(offline_filename, 'w') as f:
- f.add(replay_filename)
- f.add(meta_filename)
- file = open(offline_filename, 'rb')
- os.chdir(current_dir)
- return file
-
- def get(self, request, *args, **kwargs):
- session = self.get_object()
- local_path, url = utils.get_session_replay_url(session)
- if local_path is None:
- error = url
- return HttpResponse(error)
- file = self.prepare_offline_file(session, local_path)
- response = FileResponse(file)
- response['Content-Type'] = 'application/octet-stream'
- # 这里要注意哦,网上查到的方法都是response['Content-Disposition']='attachment;filename="filename.py"',
- # 但是如果文件名是英文名没问题,如果文件名包含中文,下载下来的文件名会被改为url中的path。
- filename = escape_uri_path('{}.tar'.format(session.id))
- disposition = "attachment; filename*=UTF-8''{}".format(filename)
- response["Content-Disposition"] = disposition
- return response
diff --git a/apps/terminal/views/storage.py b/apps/terminal/views/storage.py
deleted file mode 100644
index 778cdd489..000000000
--- a/apps/terminal/views/storage.py
+++ /dev/null
@@ -1,181 +0,0 @@
-# coding: utf-8
-#
-
-from django.http import Http404
-from django.views.generic import TemplateView
-from django.views.generic.edit import CreateView, UpdateView
-from django.utils.translation import ugettext as _
-
-from common.permissions import PermissionsMixin, IsSuperUser
-from terminal.models import ReplayStorage, CommandStorage
-from .. import forms, const
-
-
-__all__ = [
- 'ReplayStorageListView', 'ReplayStorageCreateView',
- 'ReplayStorageUpdateView', 'CommandStorageListView',
- 'CommandStorageCreateView', 'CommandStorageUpdateView'
-]
-
-
-class ReplayStorageListView(PermissionsMixin, TemplateView):
- template_name = 'terminal/replay_storage_list.html'
- permission_classes = [IsSuperUser]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Terminal'),
- 'action': _('Replay storage list'),
- 'is_replay': True,
- 'type_choices': const.REPLAY_STORAGE_TYPE_CHOICES_EXTENDS,
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class CommandStorageListView(PermissionsMixin, TemplateView):
- template_name = 'terminal/command_storage_list.html'
- permission_classes = [IsSuperUser]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Terminal'),
- 'action': _('Command storage list'),
- 'type_choices': const.COMMAND_STORAGE_TYPE_CHOICES_EXTENDS,
- 'is_command': True,
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class BaseStorageCreateUpdateViewMixin:
- permission_classes = [IsSuperUser]
- default_type = None
- form_class = None
- form_class_choices = {}
-
- def get_initial(self):
- return {'type': self.get_type()}
-
- def get_type(self):
- return self.default_type
-
- def get_form_class(self):
- tp = self.get_type()
- form_class = self.form_class_choices.get(tp)
- if not form_class:
- raise Http404()
- return form_class
-
-
-class ReplayStorageCreateUpdateViewMixin(BaseStorageCreateUpdateViewMixin):
- model = ReplayStorage
- default_type = const.REPLAY_STORAGE_TYPE_S3
- form_class = forms.ReplayStorageS3Form
- form_class_choices = {
- const.REPLAY_STORAGE_TYPE_S3: forms.ReplayStorageS3Form,
- const.REPLAY_STORAGE_TYPE_CEPH: forms.ReplayStorageCephForm,
- const.REPLAY_STORAGE_TYPE_SWIFT: forms.ReplayStorageSwiftForm,
- const.REPLAY_STORAGE_TYPE_OSS: forms.ReplayStorageOSSForm,
- const.REPLAY_STORAGE_TYPE_AZURE: forms.ReplayStorageAzureForm
- }
-
-
-class ReplayStorageCreateView(ReplayStorageCreateUpdateViewMixin,
- PermissionsMixin, CreateView):
- template_name = 'terminal/replay_storage_create_update.html'
-
- def get_type(self):
- tp = self.request.GET.get("type")
- if tp:
- return tp.lower()
- return super().get_type()
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Terminal'),
- 'action': _('Create replay storage'),
- 'api_action': 'create'
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class ReplayStorageUpdateView(ReplayStorageCreateUpdateViewMixin,
- PermissionsMixin, UpdateView):
- template_name = 'terminal/replay_storage_create_update.html'
-
- def get_initial(self):
- initial_data = super().get_initial()
- for k, v in self.object.meta.items():
- _k = "{}_{}".format(self.object.type, k.lower())
- initial_data[_k] = v
- return initial_data
-
- def get_type(self):
- return self.object.type
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Terminal'),
- 'action': _('Update replay storage'),
- 'api_action': 'update'
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class CommandStorageCreateUpdateViewMixin(BaseStorageCreateUpdateViewMixin):
- model = CommandStorage
- default_type = const.COMMAND_STORAGE_TYPE_ES
- form_class = forms.CommandStorageTypeESForm
- form_class_choices = {
- const.COMMAND_STORAGE_TYPE_ES: forms.CommandStorageTypeESForm
- }
-
-
-class CommandStorageCreateView(CommandStorageCreateUpdateViewMixin,
- PermissionsMixin, CreateView):
- template_name = 'terminal/command_storage_create_update.html'
-
- def get_type(self):
- tp = self.request.GET.get("type")
- if tp:
- return tp.lower()
- return super().get_type()
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Terminal'),
- 'action': _('Create command storage'),
- 'api_action': 'create'
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class CommandStorageUpdateView(CommandStorageCreateUpdateViewMixin,
- PermissionsMixin, UpdateView):
- template_name = 'terminal/command_storage_create_update.html'
-
- def get_initial(self):
- initial_data = super().get_initial()
- for k, v in self.object.meta.items():
- _k = "{}_{}".format(self.object.type, k.lower())
- if k == 'HOSTS':
- v = ','.join(v)
- initial_data[_k] = v
- return initial_data
-
- def get_type(self):
- return self.object.type
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Terminal'),
- 'action': _('Update command storage'),
- 'api_action': 'update'
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
diff --git a/apps/terminal/views/terminal.py b/apps/terminal/views/terminal.py
deleted file mode 100644
index 56e3a4dc9..000000000
--- a/apps/terminal/views/terminal.py
+++ /dev/null
@@ -1,138 +0,0 @@
-# ~*~ coding: utf-8 ~*~
-#
-import time
-from django.views.generic import ListView, UpdateView, DeleteView, \
- DetailView, View
-from django.utils.translation import ugettext as _
-from django.shortcuts import redirect
-from django.urls import reverse_lazy, reverse
-
-from common.mixins import JSONResponseMixin
-from ..models import Terminal
-from ..forms import TerminalForm
-from common.permissions import PermissionsMixin, IsSuperUser
-
-
-__all__ = [
- "TerminalListView", "TerminalUpdateView", "TerminalDetailView",
- "TerminalDeleteView", "TerminalConnectView", "TerminalAcceptView",
- "WebTerminalView", 'WebSFTPView',
-]
-
-
-class TerminalListView(PermissionsMixin, ListView):
- model = Terminal
- template_name = 'terminal/terminal_list.html'
- form_class = TerminalForm
- permission_classes = [IsSuperUser]
-
- def get_context_data(self, **kwargs):
- context = super(TerminalListView, self).get_context_data(**kwargs)
- context.update({
- 'app': _('Sessions'),
- 'action': _('Terminal list'),
- 'form': self.form_class()
- })
- return context
-
-
-class TerminalUpdateView(PermissionsMixin, UpdateView):
- model = Terminal
- form_class = TerminalForm
- template_name = 'terminal/terminal_update.html'
- success_url = reverse_lazy('terminal:terminal-list')
- permission_classes = [IsSuperUser]
-
- def get_context_data(self, **kwargs):
- context = super(TerminalUpdateView, self).get_context_data(**kwargs)
- context.update({'app': _('Sessions'), 'action': _('Update terminal')})
- return context
-
-
-class TerminalDetailView(PermissionsMixin, DetailView):
- model = Terminal
- template_name = 'terminal/terminal_detail.html'
- context_object_name = 'terminal'
- permission_classes = [IsSuperUser]
-
- def get_context_data(self, **kwargs):
- context = super(TerminalDetailView, self).get_context_data(**kwargs)
- context.update({
- 'app': _('Sessions'),
- 'action': _('Terminal detail')
- })
- return context
-
-
-class TerminalDeleteView(PermissionsMixin, DeleteView):
- model = Terminal
- template_name = 'delete_confirm.html'
- success_url = reverse_lazy('terminal:terminal-list')
- permission_classes = [IsSuperUser]
-
-
-class TerminalAcceptView(PermissionsMixin, JSONResponseMixin, UpdateView):
- model = Terminal
- form_class = TerminalForm
- template_name = 'terminal/terminal_modal_accept.html'
- permission_classes = [IsSuperUser]
-
- def form_valid(self, form):
- terminal = form.save()
- terminal.create_app_user()
- terminal.is_accepted = True
- terminal.is_active = True
- terminal.save()
- data = {
- 'success': True,
- 'msg': 'success'
- }
- return self.render_json_response(data)
-
- def form_invalid(self, form):
- data = {
- 'success': False,
- 'msg': str(form.errors),
- }
- return self.render_json_response(data)
-
-
-class TerminalConnectView(PermissionsMixin, DetailView):
- """
- Abandon
- """
- template_name = 'flash_message_standalone.html'
- model = Terminal
- permission_classes = [IsSuperUser]
-
- def get_context_data(self, **kwargs):
- if self.object.type == 'Web':
- context = {
- 'title': _('Redirect to web terminal'),
- 'messages': _('Redirect to web terminal') + self.object.url,
- 'auto_redirect': True,
- 'interval': 3,
- 'redirect_url': self.object.url
- }
- else:
- context = {
- 'title': _('Connect ssh terminal'),
- 'messages': _('You should use your ssh client tools '
- 'connect terminal: {} '
- '{}'.format(self.object.name, self.object.url)),
- 'redirect_url': reverse('terminal:terminal-list')
- }
-
- kwargs.update(context)
- return super(TerminalConnectView, self).get_context_data(**kwargs)
-
-
-class WebTerminalView(View):
- def get(self, request, *args, **kwargs):
- redirect_url = '/luna/?_={}&'.format(int(time.time()))
- return redirect(redirect_url + request.GET.urlencode())
-
-
-class WebSFTPView(View):
- def get(self, request, *args, **kwargs):
- return redirect('/koko/elfinder/sftp/?' + request.GET.urlencode())
diff --git a/apps/tickets/templates/tickets/ticket_detail.html b/apps/tickets/templates/tickets/ticket_detail.html
deleted file mode 100644
index bcbe83045..000000000
--- a/apps/tickets/templates/tickets/ticket_detail.html
+++ /dev/null
@@ -1,181 +0,0 @@
-{% extends 'base.html' %}
-{% load static %}
-{% load i18n %}
-
-{% block content %}
-
-
-
-
-
-
- {{ object.title }}
-
-
-
-
-
-
-
-
-
- {% trans 'User' %}: {{ object.user_display }}
- {% trans 'Type' %}: {{ object.get_type_display | default_if_none:"" }}
- {% trans 'Status' %}:
-
- {% if object.status == "open" %}
-
- {{ object.get_status_display }}
-
- {% elif object.status == "closed" %}
-
- {{ object.get_status_display }}
-
- {% endif %}
-
-
-
-
-
- {% trans 'Assignees' %}: {{ object.assignees_display }}
- {% trans 'Assignee' %}: {{ object.assignee_display | default_if_none:"" }}
- {% trans 'Date created' %}: {{ object.date_created }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
{{ object.user_display }} {{ object.date_created|timesince}} {% trans 'ago' %}
-
-
{{ object.date_created }}
-
- {{ object.body_as_html | safe }}
-
-
-
- {% for comment in object.comments.all %}
-
-
-
-
-
-
{{ comment.user_display }} {{ comment.date_created|timesince}} {% trans 'ago' %}
-
-
{{ comment.date_created }}
-
- {{ comment.body }}
-
-
-
- {% endfor %}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
diff --git a/apps/tickets/templates/tickets/ticket_list.html b/apps/tickets/templates/tickets/ticket_list.html
deleted file mode 100644
index dfbc973e7..000000000
--- a/apps/tickets/templates/tickets/ticket_list.html
+++ /dev/null
@@ -1,117 +0,0 @@
-{% extends 'base.html' %}
-{% load i18n static %}
-
-{% block content %}
-
-
-
-
-
-
-
- {% if False %}
-
-
-
- {% trans 'Create ticket' %}
-
-
-
-
- {% endif %}
-
-
-
-
-
-
-
-{% endblock %}
-{% block content_bottom_left %}{% endblock %}
-{% block custom_foot_js %}
-
-{% endblock %}
-
diff --git a/apps/tickets/urls/views_urls.py b/apps/tickets/urls/views_urls.py
deleted file mode 100644
index 46e15437e..000000000
--- a/apps/tickets/urls/views_urls.py
+++ /dev/null
@@ -1,11 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-from django.urls import path
-from .. import views
-
-app_name = 'tickets'
-
-urlpatterns = [
- path('tickets/', views.TicketListView.as_view(), name='ticket-list'),
- path('tickets//', views.TicketDetailView.as_view(), name='ticket-detail'),
-]
diff --git a/apps/tickets/views.py b/apps/tickets/views.py
deleted file mode 100644
index 93b4aca2f..000000000
--- a/apps/tickets/views.py
+++ /dev/null
@@ -1,41 +0,0 @@
-from django.views.generic import TemplateView, DetailView
-from django.utils.translation import ugettext as _
-
-from common.permissions import PermissionsMixin, IsValidUser
-from .models import Ticket
-from . import mixins
-
-
-class TicketListView(PermissionsMixin, TemplateView):
- template_name = 'tickets/ticket_list.html'
- permission_classes = (IsValidUser,)
-
- def get_context_data(self, **kwargs):
- assign = self.request.GET.get('assign', '0') == '1'
- context = super().get_context_data(**kwargs)
- assigned_open_count = Ticket.get_assigned_tickets(self.request.user)\
- .filter(status=Ticket.STATUS_OPEN).count()
- context.update({
- 'app': _("Tickets"),
- 'action': _("Ticket list"),
- 'assign': assign,
- 'assigned_open_count': assigned_open_count
- })
- return context
-
-
-class TicketDetailView(PermissionsMixin, mixins.TicketMixin, DetailView):
- template_name = 'tickets/ticket_detail.html'
- permission_classes = (IsValidUser,)
- queryset = Ticket.objects.all()
-
- def get_context_data(self, **kwargs):
- ticket = self.get_object()
- has_action_perm = ticket.is_assignee(self.request.user)
- context = super().get_context_data(**kwargs)
- context.update({
- 'app': _("Tickets"),
- 'action': _("Ticket detail"),
- 'has_action_perm': has_action_perm,
- })
- return context
diff --git a/apps/users/urls/views_urls.py b/apps/users/urls/views_urls.py
deleted file mode 100644
index 23f209d5c..000000000
--- a/apps/users/urls/views_urls.py
+++ /dev/null
@@ -1,54 +0,0 @@
-from __future__ import absolute_import
-
-from django.urls import path
-
-from .. import views
-
-app_name = 'users'
-
-urlpatterns = [
- # Login view
- path('login/', views.UserLoginView.as_view(), name='login'),
- path('password/forgot/', views.UserForgotPasswordView.as_view(), name='forgot-password'),
- path('password/forgot/sendmail-success/', views.UserForgotPasswordSendmailSuccessView.as_view(), name='forgot-password-sendmail-success'),
- path('password/reset/', views.UserResetPasswordView.as_view(), name='reset-password'),
- path('password/reset/success/', views.UserResetPasswordSuccessView.as_view(), name='reset-password-success'),
- path('password/verify/', views.UserVerifyPasswordView.as_view(), name='user-verify-password'),
-
- # Profile
- path('profile/', views.UserProfileView.as_view(), name='user-profile'),
- path('profile/update/', views.UserProfileUpdateView.as_view(), name='user-profile-update'),
- path('profile/password/update/', views.UserPasswordUpdateView.as_view(), name='user-password-update'),
- path('profile/pubkey/update/', views.UserPublicKeyUpdateView.as_view(), name='user-pubkey-update'),
- path('profile/pubkey/generate/', views.UserPublicKeyGenerateView.as_view(), name='user-pubkey-generate'),
-
- path('profile/otp/enable/start/', views.UserOtpEnableStartView.as_view(), name='user-otp-enable-start'),
- path('profile/otp/enable/install-app/', views.UserOtpEnableInstallAppView.as_view(), name='user-otp-enable-install-app'),
- path('profile/otp/enable/bind/', views.UserOtpEnableBindView.as_view(), name='user-otp-enable-bind'),
- path('profile/otp/disable/authentication/', views.UserDisableMFAView.as_view(), name='user-otp-disable-authentication'),
- path('profile/otp/update/', views.UserOtpUpdateView.as_view(), name='user-otp-update'),
- path('profile/otp/settings-success/', views.UserOtpSettingsSuccessView.as_view(), name='user-otp-settings-success'),
-
- # User view
- path('user/', views.UserListView.as_view(), name='user-list'),
- path('first-login/', views.UserFirstLoginView.as_view(), name='user-first-login'),
- path('user/create/', views.UserCreateView.as_view(), name='user-create'),
- path('user//update/', views.UserUpdateView.as_view(), name='user-update'),
- path('user/update/', views.UserBulkUpdateView.as_view(), name='user-bulk-update'),
- path('user//', views.UserDetailView.as_view(), name='user-detail'),
- path('user//assets/', views.UserGrantedAssetView.as_view(), name='user-granted-asset'),
- path('user//asset-permissions/', views.UserAssetPermissionListView.as_view(), name='user-asset-permission'),
- path('user//remote-apps/', views.UserGrantedRemoteAppView.as_view(), name='user-granted-remote-app'),
- path('user//remote-app-permissions/', views.UserRemoteAppPermissionListView.as_view(), name='user-remote-app-permission'),
- path('user//database-apps/', views.UserGrantedDatabasesAppView.as_view(), name='user-granted-database-app'),
- path('user//database-app-permissions/', views.UserDatabaseAppPermissionListView.as_view(), name='user-database-app-permission'),
- path('user//login-history/', views.UserDetailView.as_view(), name='user-login-history'),
-
- # User group view
- path('user-group/', views.UserGroupListView.as_view(), name='user-group-list'),
- path('user-group//', views.UserGroupDetailView.as_view(), name='user-group-detail'),
- path('user-group/create/', views.UserGroupCreateView.as_view(), name='user-group-create'),
- path('user-group//update/', views.UserGroupUpdateView.as_view(), name='user-group-update'),
- path('user-group//assets/', views.UserGroupGrantedAssetView.as_view(), name='user-group-granted-asset'),
-
-]
diff --git a/apps/users/views/__init__.py b/apps/users/views/__init__.py
index 17d4f4110..bd184529d 100644
--- a/apps/users/views/__init__.py
+++ b/apps/users/views/__init__.py
@@ -1,6 +1,3 @@
# ~*~ coding: utf-8 ~*~
-from .login import *
-from .user import *
from .profile import *
-from .group import *
diff --git a/apps/users/views/group.py b/apps/users/views/group.py
deleted file mode 100644
index ed9976eab..000000000
--- a/apps/users/views/group.py
+++ /dev/null
@@ -1,103 +0,0 @@
-# ~*~ coding: utf-8 ~*~
-from __future__ import unicode_literals
-from django.utils.translation import ugettext as _
-from django.urls import reverse_lazy
-from django.views.generic.base import TemplateView
-from django.views.generic.edit import CreateView, UpdateView
-from django.views.generic.detail import DetailView
-from django.contrib.messages.views import SuccessMessageMixin
-
-from common.utils import get_logger
-from common.const import create_success_msg, update_success_msg
-from common.permissions import PermissionsMixin, IsOrgAdmin
-from orgs.utils import current_org
-from ..models import User, UserGroup
-from .. import forms
-
-__all__ = ['UserGroupListView', 'UserGroupCreateView', 'UserGroupDetailView',
- 'UserGroupUpdateView', 'UserGroupGrantedAssetView']
-logger = get_logger(__name__)
-
-
-class UserGroupListView(PermissionsMixin, TemplateView):
- template_name = 'users/user_group_list.html'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Users'),
- 'action': _('User group list')
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class UserGroupCreateView(PermissionsMixin, SuccessMessageMixin, CreateView):
- model = UserGroup
- form_class = forms.UserGroupForm
- template_name = 'users/user_group_create_update.html'
- success_url = reverse_lazy('users:user-group-list')
- success_message = create_success_msg
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Users'),
- 'action': _('Create user group'),
- 'type': 'create'
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class UserGroupUpdateView(PermissionsMixin, SuccessMessageMixin, UpdateView):
- model = UserGroup
- form_class = forms.UserGroupForm
- template_name = 'users/user_group_create_update.html'
- success_url = reverse_lazy('users:user-group-list')
- success_message = update_success_msg
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Users'),
- 'action': _('Update user group'),
- 'type': 'update'
-
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class UserGroupDetailView(PermissionsMixin, DetailView):
- model = UserGroup
- context_object_name = 'user_group'
- template_name = 'users/user_group_detail.html'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- users = current_org.get_org_members(exclude=('Auditor',)).exclude(
- groups=self.object)
- context = {
- 'app': _('Users'),
- 'action': _('User group detail'),
- 'users': users,
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class UserGroupGrantedAssetView(PermissionsMixin, DetailView):
- model = UserGroup
- template_name = 'users/user_group_granted_asset.html'
- context_object_name = 'user_group'
- object = None
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Users'),
- 'action': _('User group granted asset'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
diff --git a/apps/users/views/profile/__init__.py b/apps/users/views/profile/__init__.py
index 1bc58d06f..99094f092 100644
--- a/apps/users/views/profile/__init__.py
+++ b/apps/users/views/profile/__init__.py
@@ -5,3 +5,4 @@ from .password import *
from .pubkey import *
from .mfa import *
from .otp import *
+from .reset import *
diff --git a/apps/users/views/login.py b/apps/users/views/profile/reset.py
similarity index 98%
rename from apps/users/views/login.py
rename to apps/users/views/profile/reset.py
index d7db52d51..f1da16a4d 100644
--- a/apps/users/views/login.py
+++ b/apps/users/views/profile/reset.py
@@ -14,11 +14,11 @@ from django.views.generic import FormView
from common.utils import get_object_or_none
from common.permissions import PermissionsMixin, IsValidUser
-from ..models import User
-from ..utils import (
+from ...models import User
+from ...utils import (
send_reset_password_mail, get_password_check_rules, check_password_rules
)
-from .. import forms
+from ... import forms
__all__ = [
diff --git a/apps/users/views/user.py b/apps/users/views/user.py
deleted file mode 100644
index 8e6650240..000000000
--- a/apps/users/views/user.py
+++ /dev/null
@@ -1,280 +0,0 @@
-# ~*~ coding: utf-8 ~*~
-
-from __future__ import unicode_literals
-
-
-from django.contrib import messages
-from django.contrib.messages.views import SuccessMessageMixin
-from django.core.cache import cache
-from django.shortcuts import redirect
-from django.urls import reverse_lazy
-from django.utils.translation import ugettext as _
-from django.views.generic.base import TemplateView
-from django.views.generic.edit import (
- CreateView, UpdateView
-)
-from django.views.generic.detail import DetailView
-
-from common.const import (
- create_success_msg, update_success_msg, KEY_CACHE_RESOURCES_ID
-)
-from common.utils import get_logger
-from common.permissions import (
- PermissionsMixin, IsOrgAdmin,
- CanUpdateDeleteUser,
-)
-from orgs.utils import current_org
-from .. import forms
-from ..models import User, UserGroup
-from ..utils import get_password_check_rules, is_need_unblock
-from ..signals import post_user_create
-
-__all__ = [
- 'UserListView', 'UserCreateView', 'UserDetailView',
- 'UserUpdateView', 'UserBulkUpdateView',
- 'UserGrantedAssetView', 'UserAssetPermissionListView',
- 'UserGrantedRemoteAppView', 'UserRemoteAppPermissionListView',
- 'UserGrantedDatabasesAppView', 'UserDatabaseAppPermissionListView',
-]
-
-logger = get_logger(__name__)
-
-
-class UserListView(PermissionsMixin, TemplateView):
- template_name = 'users/user_list.html'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = super().get_context_data(**kwargs)
- context.update({
- 'app': _('Users'),
- 'action': _('User list'),
- })
- return context
-
-
-class UserCreateView(PermissionsMixin, SuccessMessageMixin, CreateView):
- model = User
- form_class = forms.UserCreateForm
- template_name = 'users/user_create.html'
- success_url = reverse_lazy('users:user-list')
- success_message = create_success_msg
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- check_rules = get_password_check_rules()
- context = {
- 'app': _('Users'),
- 'action': _('Create user'),
- 'password_check_rules': check_rules,
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
- def form_valid(self, form):
- user = form.save(commit=False)
- user.created_by = self.request.user.username or 'System'
- user.save()
- if current_org and current_org.is_real():
- user.related_user_orgs.add(current_org.id)
- post_user_create.send(self.__class__, user=user)
- return super().form_valid(form)
-
- def get_form_kwargs(self):
- kwargs = super(UserCreateView, self).get_form_kwargs()
- data = {'request': self.request}
- kwargs.update(data)
- return kwargs
-
-
-class UserUpdateView(PermissionsMixin, SuccessMessageMixin, UpdateView):
- model = User
- form_class = forms.UserUpdateForm
- template_name = 'users/user_update.html'
- context_object_name = 'user_object'
- success_url = reverse_lazy('users:user-list')
- success_message = update_success_msg
- permission_classes = [IsOrgAdmin]
-
- def _deny_permission(self):
- obj = self.get_object()
- return not self.request.user.is_superuser and obj.is_superuser
-
- def get(self, request, *args, **kwargs):
- if self._deny_permission():
- return redirect(self.success_url)
- return super().get(request, *args, **kwargs)
-
- def get_context_data(self, **kwargs):
- check_rules = get_password_check_rules()
- context = {
- 'app': _('Users'),
- 'action': _('Update user'),
- 'password_check_rules': check_rules,
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
- def get_form_kwargs(self):
- kwargs = super(UserUpdateView, self).get_form_kwargs()
- data = {'request': self.request}
- kwargs.update(data)
- return kwargs
-
-
-class UserBulkUpdateView(PermissionsMixin, TemplateView):
- model = User
- form_class = forms.UserBulkUpdateForm
- template_name = 'users/user_bulk_update.html'
- success_url = reverse_lazy('users:user-list')
- success_message = _("Bulk update user success")
- form = None
- id_list = None
- permission_classes = [IsOrgAdmin]
-
- def get(self, request, *args, **kwargs):
- spm = request.GET.get('spm', '')
- users_id = cache.get(KEY_CACHE_RESOURCES_ID.format(spm))
- if kwargs.get('form'):
- self.form = kwargs['form']
- elif users_id:
- self.form = self.form_class(initial={'users': users_id})
- else:
- self.form = self.form_class()
- return super().get(request, *args, **kwargs)
-
- def post(self, request, *args, **kwargs):
- form = self.form_class(request.POST)
- if form.is_valid():
- form.save()
- messages.success(request, self.success_message)
- return redirect(self.success_url)
- else:
- return self.get(request, form=form, *args, **kwargs)
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': 'Assets',
- 'action': _('Bulk update user'),
- 'form': self.form,
- 'users_selected': self.id_list,
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class UserDetailView(PermissionsMixin, DetailView):
- model = User
- template_name = 'users/user_detail.html'
- context_object_name = "object"
- key_prefix_block = "_LOGIN_BLOCK_{}"
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- user = self.get_object()
- key_block = self.key_prefix_block.format(user.username)
- groups = UserGroup.objects.exclude(id__in=self.object.groups.all())
- context = {
- 'app': _('Users'),
- 'action': _('User detail'),
- 'groups': groups,
- 'unblock': is_need_unblock(key_block),
- 'can_update': CanUpdateDeleteUser.has_update_object_permission(
- self.request, self, user
- ),
- 'can_delete': CanUpdateDeleteUser.has_delete_object_permission(
- self.request, self, user
- ),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
- def get_queryset(self):
- queryset = super().get_queryset()
- org_users = current_org.get_org_members().values_list('id', flat=True)
- queryset = queryset.filter(id__in=org_users)
- return queryset
-
-
-class UserGrantedAssetView(PermissionsMixin, DetailView):
- model = User
- template_name = 'users/user_granted_asset.html'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Users'),
- 'action': _('User granted assets'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class UserAssetPermissionListView(PermissionsMixin, DetailView):
- model = User
- template_name = 'users/user_asset_permission.html'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Users'),
- 'action': _('Asset permission'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class UserGrantedRemoteAppView(PermissionsMixin, DetailView):
- model = User
- template_name = 'users/user_granted_remote_app.html'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Users'),
- 'action': _('User granted RemoteApp'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class UserRemoteAppPermissionListView(PermissionsMixin, DetailView):
- model = User
- template_name = 'users/user_remote_app_permission.html'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Users'),
- 'action': _('RemoteApp permission'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class UserGrantedDatabasesAppView(PermissionsMixin, DetailView):
- model = User
- template_name = 'users/user_granted_database_app.html'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Users'),
- 'action': _('User granted DatabaseApp'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)
-
-
-class UserDatabaseAppPermissionListView(PermissionsMixin, DetailView):
- model = User
- template_name = 'users/user_database_app_permission.html'
- permission_classes = [IsOrgAdmin]
-
- def get_context_data(self, **kwargs):
- context = {
- 'app': _('Users'),
- 'action': _('DatabaseApp permission'),
- }
- kwargs.update(context)
- return super().get_context_data(**kwargs)