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
d6ec92d8
Commit
d6ec92d8
authored
Jul 12, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改url
parent
ad321464
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
113 additions
and
13 deletions
+113
-13
urls.py
apps/jumpserver/urls.py
+55
-11
__init__.py
apps/orgs/urls/__init__.py
+2
-0
api_urls.py
apps/orgs/urls/api_urls.py
+12
-0
views_urls.py
apps/orgs/urls/views_urls.py
+13
-0
views.py
apps/orgs/views.py
+15
-2
_nav.html
apps/templates/_nav.html
+16
-0
No files found.
apps/jumpserver/urls.py
View file @
d6ec92d8
# ~*~ coding: utf-8 ~*~
# ~*~ coding: utf-8 ~*~
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
import
re
from
django.conf.urls
import
url
,
include
from
django.conf.urls
import
url
,
include
from
django.conf
import
settings
from
django.conf
import
settings
from
django.conf.urls.static
import
static
from
django.conf.urls.static
import
static
from
rest_framework.response
import
Response
from
django.views.decorators.csrf
import
csrf_exempt
from
django.http
import
HttpResponse
from
django.utils.encoding
import
iri_to_uri
from
rest_framework.schemas
import
get_schema_view
from
rest_framework.schemas
import
get_schema_view
from
rest_framework_swagger.renderers
import
SwaggerUIRenderer
,
OpenAPIRenderer
from
rest_framework_swagger.renderers
import
SwaggerUIRenderer
,
OpenAPIRenderer
...
@@ -11,30 +16,69 @@ from rest_framework_swagger.renderers import SwaggerUIRenderer, OpenAPIRenderer
...
@@ -11,30 +16,69 @@ from rest_framework_swagger.renderers import SwaggerUIRenderer, OpenAPIRenderer
from
.views
import
IndexView
,
LunaView
from
.views
import
IndexView
,
LunaView
schema_view
=
get_schema_view
(
title
=
'Users API'
,
renderer_classes
=
[
OpenAPIRenderer
,
SwaggerUIRenderer
])
schema_view
=
get_schema_view
(
title
=
'Users API'
,
renderer_classes
=
[
OpenAPIRenderer
,
SwaggerUIRenderer
])
urlpatterns
=
[
api_url_pattern
=
re
.
compile
(
r'^/api/(?P<app>\w+)/(?P<version>\w+)/(?P<extra>.*)$'
)
url
(
r'^$'
,
IndexView
.
as_view
(),
name
=
'index'
),
url
(
r'^luna/'
,
LunaView
.
as_view
(),
name
=
'luna-error'
),
class
HttpResponseTemporaryRedirect
(
HttpResponse
):
status_code
=
307
def
__init__
(
self
,
redirect_to
):
HttpResponse
.
__init__
(
self
)
self
[
'Location'
]
=
iri_to_uri
(
redirect_to
)
@csrf_exempt
def
redirect_old_format_api
(
request
,
*
args
,
**
kwargs
):
path
,
query
=
request
.
path
,
request
.
GET
.
urlencode
()
matched
=
api_url_pattern
.
match
(
path
)
if
matched
:
app
,
version
,
extra
=
matched
.
groups
()
path
=
'/api/{version}/{app}/{extra}?{query}'
.
format
(
**
{
"app"
:
app
,
"version"
:
version
,
"extra"
:
extra
,
"query"
:
query
})
return
HttpResponseTemporaryRedirect
(
path
)
else
:
return
Response
({
"msg"
:
"Redirect url failed: {}"
.
format
(
path
)},
status
=
404
)
v1_api_patterns
=
[
url
(
r'^users/'
,
include
(
'users.urls.api_urls'
,
namespace
=
'api-users'
)),
url
(
r'^assets/'
,
include
(
'assets.urls.api_urls'
,
namespace
=
'api-assets'
)),
url
(
r'^perms/'
,
include
(
'perms.urls.api_urls'
,
namespace
=
'api-perms'
)),
url
(
r'^terminal/'
,
include
(
'terminal.urls.api_urls'
,
namespace
=
'api-terminal'
)),
url
(
r'^ops/'
,
include
(
'ops.urls.api_urls'
,
namespace
=
'api-ops'
)),
url
(
r'^audits/'
,
include
(
'audits.urls.api_urls'
,
namespace
=
'api-audits'
)),
url
(
r'^orgs/'
,
include
(
'orgs.urls.api_urls'
,
namespace
=
'api-orgs'
)),
url
(
r'^common/'
,
include
(
'common.urls.api_urls'
,
namespace
=
'api-common'
)),
]
app_view_patterns
=
[
url
(
r'^users/'
,
include
(
'users.urls.views_urls'
,
namespace
=
'users'
)),
url
(
r'^users/'
,
include
(
'users.urls.views_urls'
,
namespace
=
'users'
)),
url
(
r'^assets/'
,
include
(
'assets.urls.views_urls'
,
namespace
=
'assets'
)),
url
(
r'^assets/'
,
include
(
'assets.urls.views_urls'
,
namespace
=
'assets'
)),
url
(
r'^perms/'
,
include
(
'perms.urls.views_urls'
,
namespace
=
'perms'
)),
url
(
r'^perms/'
,
include
(
'perms.urls.views_urls'
,
namespace
=
'perms'
)),
url
(
r'^terminal/'
,
include
(
'terminal.urls.views_urls'
,
namespace
=
'terminal'
)),
url
(
r'^terminal/'
,
include
(
'terminal.urls.views_urls'
,
namespace
=
'terminal'
)),
url
(
r'^ops/'
,
include
(
'ops.urls.view_urls'
,
namespace
=
'ops'
)),
url
(
r'^ops/'
,
include
(
'ops.urls.view_urls'
,
namespace
=
'ops'
)),
url
(
r'^audits/'
,
include
(
'audits.urls.view_urls'
,
namespace
=
'audits'
)),
url
(
r'^audits/'
,
include
(
'audits.urls.view_urls'
,
namespace
=
'audits'
)),
url
(
r'^orgs/'
,
include
(
'orgs.urls.views_urls'
,
namespace
=
'orgs'
)),
]
urlpatterns
=
[
url
(
r'^$'
,
IndexView
.
as_view
(),
name
=
'index'
),
url
(
r'^luna/'
,
LunaView
.
as_view
(),
name
=
'luna-error'
),
url
(
r'^settings/'
,
include
(
'common.urls.view_urls'
,
namespace
=
'settings'
)),
url
(
r'^settings/'
,
include
(
'common.urls.view_urls'
,
namespace
=
'settings'
)),
url
(
r'^common/'
,
include
(
'common.urls.view_urls'
,
namespace
=
'common'
)),
url
(
r'^common/'
,
include
(
'common.urls.view_urls'
,
namespace
=
'common'
)),
url
(
r'^api/v1/'
,
include
(
v1_api_patterns
)),
url
(
r'^api/(?P<app>.*)/v1/.*'
,
redirect_old_format_api
),
# Api url view map
# Api url view map
url
(
r'^api/users/'
,
include
(
'users.urls.api_urls'
,
namespace
=
'api-users'
)),
url
(
r'^api/assets/'
,
include
(
'assets.urls.api_urls'
,
namespace
=
'api-assets'
)),
url
(
r'^api/perms/'
,
include
(
'perms.urls.api_urls'
,
namespace
=
'api-perms'
)),
url
(
r'^api/terminal/'
,
include
(
'terminal.urls.api_urls'
,
namespace
=
'api-terminal'
)),
url
(
r'^api/ops/'
,
include
(
'ops.urls.api_urls'
,
namespace
=
'api-ops'
)),
url
(
r'^api/audits/'
,
include
(
'audits.urls.api_urls'
,
namespace
=
'api-audits'
)),
url
(
r'^api/common/'
,
include
(
'common.urls.api_urls'
,
namespace
=
'api-common'
)),
# External apps url
# External apps url
url
(
r'^captcha/'
,
include
(
'captcha.urls'
)),
url
(
r'^captcha/'
,
include
(
'captcha.urls'
)),
]
]
urlpatterns
+=
app_view_patterns
# urlpatterns = wrapper_patterns_with_org(urlpatterns)
urlpatterns
+=
static
(
settings
.
MEDIA_URL
,
document_root
=
settings
.
MEDIA_ROOT
)
\
urlpatterns
+=
static
(
settings
.
MEDIA_URL
,
document_root
=
settings
.
MEDIA_ROOT
)
\
+
static
(
settings
.
STATIC_URL
,
document_root
=
settings
.
STATIC_ROOT
)
+
static
(
settings
.
STATIC_URL
,
document_root
=
settings
.
STATIC_ROOT
)
...
...
apps/orgs/urls/__init__.py
0 → 100644
View file @
d6ec92d8
# -*- coding: utf-8 -*-
#
apps/orgs/urls/api_urls.py
0 → 100644
View file @
d6ec92d8
# -*- coding: utf-8 -*-
#
from
django.conf.urls
import
url
from
..
import
views
app_name
=
'orgs'
urlpatterns
=
[
# url(r'^(?P<pk>[0-9a-zA-Z\-]{36})/$', views.OrgDetailView.as_view(), name='asset-index')
]
\ No newline at end of file
apps/orgs/urls/views_urls.py
0 → 100644
View file @
d6ec92d8
# -*- coding: utf-8 -*-
#
from
django.conf.urls
import
url
from
..
import
views
app_name
=
'orgs'
urlpatterns
=
[
url
(
r'^(?P<pk>.*)/switch/$'
,
views
.
SwitchOrgView
.
as_view
(),
name
=
'org-switch'
)
]
apps/orgs/views.py
View file @
d6ec92d8
from
django.shortcuts
import
re
nder
from
django.shortcuts
import
re
direct
# Create your views here.
from
django.views.generic
import
DetailView
from
.models
import
Organization
class
SwitchOrgView
(
DetailView
):
model
=
Organization
object
=
None
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
pk
=
kwargs
.
get
(
'pk'
)
self
.
object
=
Organization
.
get_instance
(
pk
)
request
.
session
[
'oid'
]
=
self
.
object
.
id
.
__str__
()
return
redirect
(
'index'
)
apps/templates/_nav.html
View file @
d6ec92d8
{% load i18n %}
{% load i18n %}
{% if ADMIN_ORGS %}
<li
id=
"org"
>
<a
class=
"dropdown-toggle"
data-toggle=
"dropdown"
aria-expanded=
"false"
>
<i
class=
"fa fa-star"
style=
"width: 14px"
></i>
<span
class=
"nav-label"
>
{{ CURRENT_ORG.name }}
</span>
<span
class=
"fa fa-caret-down arrow"
></span>
</a>
<ul
class=
"dropdown-menu"
>
{% for org in ADMIN_ORGS %}
{% if org.is_default %}
<li><a
class=
"org-dropdown"
href=
"{% url 'orgs:org-switch' pk=org.id %}"
data-id=
"{{ org.id }}"
>
{{ org.name }}
</a></li>
{% endif %}
{% endfor %}
</ul>
</li>
<hr>
{% endif %}
<li
id=
"index"
>
<li
id=
"index"
>
<a
href=
"{% url 'index' %}"
>
<a
href=
"{% url 'index' %}"
>
<i
class=
"fa fa-dashboard"
style=
"width: 14px"
></i>
<span
class=
"nav-label"
>
{% trans 'Dashboard' %}
</span><span
<i
class=
"fa fa-dashboard"
style=
"width: 14px"
></i>
<span
class=
"nav-label"
>
{% trans 'Dashboard' %}
</span><span
...
...
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