mirror of https://github.com/jumpserver/jumpserver
[Feature] 添加context_processor
parent
99b4c66b5e
commit
722863428d
|
@ -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();
|
||||
|
|
|
@ -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'),
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
|
||||
|
||||
def jumpserver_processor(request):
|
||||
context = {}
|
||||
|
||||
# Setting default pk
|
||||
context.update(
|
||||
{'DEFAULT_PK': '00000000-0000-0000-0000-000000000000'}
|
||||
)
|
||||
return context
|
||||
|
||||
|
||||
|
|
@ -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',
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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'),
|
||||
|
|
|
@ -332,4 +332,4 @@ String.prototype.format = function(args) {
|
|||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue