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
72286342
Commit
72286342
authored
Dec 12, 2017
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Feature] 添加context_processor
parent
99b4c66b
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
33 additions
and
27 deletions
+33
-27
asset_list.html
apps/assets/templates/assets/asset_list.html
+7
-23
views_urls.py
apps/assets/urls/views_urls.py
+1
-1
asset.py
apps/assets/views/asset.py
+1
-0
context_processor.py
apps/jumpserver/context_processor.py
+15
-0
settings.py
apps/jumpserver/settings.py
+1
-0
api_urls.py
apps/ops/urls/api_urls.py
+2
-0
view_urls.py
apps/ops/urls/view_urls.py
+2
-0
jumpserver.js
apps/static/js/jumpserver.js
+1
-1
login.py
apps/users/views/login.py
+3
-2
No files found.
apps/assets/templates/assets/asset_list.html
View file @
72286342
...
...
@@ -63,23 +63,6 @@
{% block custom_foot_js %}
<script
src=
"{% static 'js/jquery.form.min.js' %}"
></script>
<script
type=
"text/javascript"
>
window
.
onload
=
function
(){
var
tag_on
=
document
.
getElementsByName
(
"tag_on"
);
var
oDiv
=
document
.
getElementById
(
"ydxbd"
);
if
(
tag_on
.
length
>
0
){
oDiv
.
style
.
display
=
"block"
;
}
};
function
tagShow
()
{
var
oDiv
=
document
.
getElementById
(
"ydxbd"
);
if
(
oDiv
.
style
.
display
==
'none'
){
oDiv
.
style
.
display
=
"block"
;
}
else
{
oDiv
.
style
.
display
=
"none"
;
}
}
//onload;
$
(
document
).
ready
(
function
(){
...
...
@@ -87,8 +70,10 @@ $(document).ready(function(){
ele
:
$
(
'#asset_list_table'
),
columnDefs
:
[
{
targets
:
1
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
var
detail_btn
=
'<a href="{% url "assets:asset-detail" pk=99991937 %}">'
+
cellData
+
'</a>'
;
$
(
td
).
html
(
detail_btn
.
replace
(
'99991937'
,
rowData
.
id
));
{
%
url
'assets:asset-detail'
pk
=
DEFAULT_PK
as
the_url
%
}
console
.
log
(
'{{ the_url }}'
);
var
detail_btn
=
'<a href="{{ the_url }}">'
+
cellData
+
'</a>'
;
$
(
td
).
html
(
detail_btn
.
replace
(
'{{ DEFAULT_PK }}'
,
rowData
.
id
));
}},
{
targets
:
7
,
createdCell
:
function
(
td
,
cellData
)
{
if
(
!
cellData
)
{
...
...
@@ -107,8 +92,8 @@ $(document).ready(function(){
}
}},
{
targets
:
9
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
var
update_btn
=
'<a href="{% url "assets:asset-update" pk=
99991937 %}" class="btn btn-xs btn-info">{% trans "Update" %}</a>'
.
replace
(
'99991937'
,
cellData
);
var
del_btn
=
'<a class="btn btn-xs btn-danger m-l-xs btn_asset_delete" data-uid="
99991937
">{% trans "Delete" %}</a>'
.
replace
(
'99991937'
,
cellData
);
var
update_btn
=
'<a href="{% url "assets:asset-update" pk=
DEFAULT_PK %}" class="btn btn-xs btn-info">{% trans "Update" %}</a>'
.
replace
(
"{{ DEFAULT_PK }}"
,
cellData
);
var
del_btn
=
'<a class="btn btn-xs btn-danger m-l-xs btn_asset_delete" data-uid="
{{ DEFAULT_PK }}
">{% trans "Delete" %}</a>'
.
replace
(
'99991937'
,
cellData
);
$
(
td
).
html
(
update_btn
+
del_btn
)
}}
],
...
...
@@ -166,8 +151,7 @@ $(document).ready(function(){
var
$data_table
=
$
(
"#asset_list_table"
).
DataTable
();
var
name
=
$
(
this
).
closest
(
"tr"
).
find
(
":nth-child(2)"
).
children
(
'a'
).
html
();
var
uid
=
$this
.
data
(
'uid'
);
var
the_url
=
'{% url "api-assets:asset-detail" pk=99991937 %}'
.
replace
(
'99991937'
,
uid
);
console
.
log
(
the_url
);
var
the_url
=
'{% url "api-assets:asset-detail" pk=99991937 %}'
.
replace
(
"{{ DEFAULT_PK }}"
,
uid
);
objectDelete
(
$this
,
name
,
the_url
);
setTimeout
(
function
()
{
$data_table
.
ajax
.
reload
();
...
...
apps/assets/urls/views_urls.py
View file @
72286342
...
...
@@ -11,7 +11,7 @@ urlpatterns = [
url
(
r'^asset/create/$'
,
views
.
AssetCreateView
.
as_view
(),
name
=
'asset-create'
),
url
(
r'^asset/export/$'
,
views
.
AssetExportView
.
as_view
(),
name
=
'asset-export'
),
url
(
r'^asset/import/$'
,
views
.
BulkImportAssetView
.
as_view
(),
name
=
'asset-import'
),
url
(
r'^asset/(?P<pk>[0-9a-zA-Z\-]
+
)/$'
,
views
.
AssetDetailView
.
as_view
(),
name
=
'asset-detail'
),
url
(
r'^asset/(?P<pk>[0-9a-zA-Z\-]
{36}
)/$'
,
views
.
AssetDetailView
.
as_view
(),
name
=
'asset-detail'
),
url
(
r'^asset/(?P<pk>[0-9a-zA-Z\-]+)/update/$'
,
views
.
AssetUpdateView
.
as_view
(),
name
=
'asset-update'
),
url
(
r'^asset/(?P<pk>[0-9a-zA-Z\-]+)/delete/$'
,
views
.
AssetDeleteView
.
as_view
(),
name
=
'asset-delete'
),
url
(
r'^asset-modal$'
,
views
.
AssetModalListView
.
as_view
(),
name
=
'asset-modal-list'
),
...
...
apps/assets/views/asset.py
View file @
72286342
...
...
@@ -62,6 +62,7 @@ class UserAssetListView(LoginRequiredMixin, TemplateView):
'app'
:
'Assets'
,
'action'
:
'Asset list'
,
'system_users'
:
SystemUser
.
objects
.
all
(),
'default_pk'
:
'00000000-0000-0000-0000-000000000000'
,
}
kwargs
.
update
(
context
)
return
super
(
UserAssetListView
,
self
)
.
get_context_data
(
**
kwargs
)
...
...
apps/jumpserver/context_processor.py
0 → 100644
View file @
72286342
# -*- coding: utf-8 -*-
#
def
jumpserver_processor
(
request
):
context
=
{}
# Setting default pk
context
.
update
(
{
'DEFAULT_PK'
:
'00000000-0000-0000-0000-000000000000'
}
)
return
context
apps/jumpserver/settings.py
View file @
72286342
...
...
@@ -97,6 +97,7 @@ TEMPLATES = [
'APP_DIRS'
:
True
,
'OPTIONS'
:
{
'context_processors'
:
[
'jumpserver.context_processor.jumpserver_processor'
,
'django.template.context_processors.i18n'
,
'django.template.context_processors.debug'
,
'django.template.context_processors.request'
,
...
...
apps/ops/urls/api_urls.py
View file @
72286342
...
...
@@ -5,6 +5,8 @@ from rest_framework.routers import DefaultRouter
from
..
import
api
app_name
=
"ops"
router
=
DefaultRouter
()
router
.
register
(
r'v1/tasks'
,
api
.
TaskViewSet
,
'task'
)
router
.
register
(
r'v1/adhoc'
,
api
.
AdHocViewSet
,
'adhoc'
)
...
...
apps/ops/urls/view_urls.py
View file @
72286342
...
...
@@ -7,6 +7,8 @@ from .. import views
__all__
=
[
"urlpatterns"
]
app_name
=
"ops"
urlpatterns
=
[
# TResource Task url
url
(
r'^task/$'
,
views
.
TaskListView
.
as_view
(),
name
=
'task-list'
),
...
...
apps/static/js/jumpserver.js
View file @
72286342
...
...
@@ -332,4 +332,4 @@ String.prototype.format = function(args) {
}
}
return
result
;
}
}
;
apps/users/views/login.py
View file @
72286342
...
...
@@ -17,7 +17,7 @@ from django.views.decorators.csrf import csrf_protect
from
django.views.decorators.debug
import
sensitive_post_parameters
from
django.views.generic.base
import
TemplateView
from
django.views.generic.edit
import
FormView
from
formtools.wizard.views
import
SessionWizardView
#
from formtools.wizard.views import SessionWizardView
from
django.conf
import
settings
from
django.utils
import
timezone
...
...
@@ -157,7 +157,8 @@ class UserResetPasswordView(TemplateView):
return
HttpResponseRedirect
(
reverse
(
'users:reset-password-success'
))
class
UserFirstLoginView
(
LoginRequiredMixin
,
SessionWizardView
):
class
UserFirstLoginView
(
LoginRequiredMixin
,
ListView
):
# class UserFirstLoginView(LoginRequiredMixin, SessionWizardView):
template_name
=
'users/first_login.html'
form_list
=
[
forms
.
UserProfileForm
,
forms
.
UserPublicKeyForm
]
file_storage
=
default_storage
...
...
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