mirror of https://github.com/jumpserver/jumpserver
[Update] 修改支持xpack
parent
37d89b4ea2
commit
9c4ebf9c75
|
@ -32,3 +32,4 @@ django.db
|
|||
celerybeat-schedule.db
|
||||
data/static
|
||||
docs/_build/
|
||||
xpack
|
||||
|
|
|
@ -78,6 +78,12 @@ INSTALLED_APPS = [
|
|||
'django.contrib.staticfiles',
|
||||
]
|
||||
|
||||
|
||||
XPACK_DIR = os.path.join(BASE_DIR, 'xpack')
|
||||
XPACK_ENABLED = os.path.isdir(XPACK_DIR)
|
||||
if XPACK_ENABLED:
|
||||
INSTALLED_APPS.append('xpack.apps.XpackConfig')
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
|
@ -94,10 +100,30 @@ MIDDLEWARE = [
|
|||
|
||||
ROOT_URLCONF = 'jumpserver.urls'
|
||||
|
||||
|
||||
def get_xpack_context_processor():
|
||||
if XPACK_ENABLED:
|
||||
return ['xpack.context_processor.xpack_processor']
|
||||
return []
|
||||
|
||||
|
||||
def get_xpack_templates_dir():
|
||||
if XPACK_ENABLED:
|
||||
dirs = []
|
||||
from xpack.utils import find_enabled_plugins
|
||||
for i in find_enabled_plugins():
|
||||
template_dir = os.path.join(BASE_DIR, 'xpack', 'plugins', i, 'templates')
|
||||
if os.path.isdir(template_dir):
|
||||
dirs.append(template_dir)
|
||||
return dirs
|
||||
else:
|
||||
return []
|
||||
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [os.path.join(BASE_DIR, 'templates'), ],
|
||||
'DIRS': [os.path.join(BASE_DIR, 'templates'), *get_xpack_templates_dir()],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
|
@ -111,6 +137,7 @@ TEMPLATES = [
|
|||
'django.template.context_processors.request',
|
||||
'django.template.context_processors.media',
|
||||
'orgs.context_processor.org_processor',
|
||||
*get_xpack_context_processor(),
|
||||
],
|
||||
},
|
||||
},
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# ~*~ coding: utf-8 ~*~
|
||||
from __future__ import unicode_literals
|
||||
import re
|
||||
import os
|
||||
|
||||
from django.urls import path, include, re_path
|
||||
from django.conf import settings
|
||||
|
@ -74,6 +75,10 @@ app_view_patterns = [
|
|||
path('orgs/', include('orgs.urls.views_urls', namespace='orgs')),
|
||||
]
|
||||
|
||||
XPACK_DIR = os.path.join(settings.BASE_DIR, 'xpack')
|
||||
if os.path.isdir(XPACK_DIR):
|
||||
app_view_patterns.append(path('xpack/', include('xpack.urls', namespace='xpack')))
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
path('', IndexView.as_view(), name='index'),
|
||||
|
|
|
@ -80,6 +80,18 @@
|
|||
{# <li id="download"><a href="">{% trans 'File download' %}</a></li>#}
|
||||
{# </ul>#}
|
||||
{#</li>#}
|
||||
{% if XPACK_ENABLED %}
|
||||
<li id="xpack">
|
||||
<a>
|
||||
<i class="fa fa-sitemap" style="width: 14px"></i> <span class="nav-label">{% trans 'XPack' %}</span><span class="fa arrow"></span>
|
||||
</a>
|
||||
<ul class="nav nav-second-level">
|
||||
{% for plugin in XPACK_PLUGINS %}
|
||||
<li id="{{ plugin.name }}"><a href="{{ plugin.endpoint }}">{% trans plugin.verbose_name %}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if request.user.is_superuser %}
|
||||
<li id="settings">
|
||||
<a href="{% url 'settings:basic-setting' %}">
|
||||
|
|
Loading…
Reference in New Issue