Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
9c4ebf9c
Commit
9c4ebf9c
authored
Aug 02, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改支持xpack
parent
37d89b4e
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
1 deletion
+46
-1
.gitignore
.gitignore
+1
-0
settings.py
apps/jumpserver/settings.py
+28
-1
urls.py
apps/jumpserver/urls.py
+5
-0
_nav.html
apps/templates/_nav.html
+12
-0
No files found.
.gitignore
View file @
9c4ebf9c
...
...
@@ -32,3 +32,4 @@ django.db
celerybeat-schedule.db
data/static
docs/_build/
xpack
apps/jumpserver/settings.py
View file @
9c4ebf9c
...
...
@@ -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
(),
],
},
},
...
...
apps/jumpserver/urls.py
View file @
9c4ebf9c
# ~*~ 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'
),
...
...
apps/templates/_nav.html
View file @
9c4ebf9c
...
...
@@ -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' %}"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment