Fixing Django 4 compatibility, removing auto_updates refs
This commit is contained in:
parent
d6e8f370e9
commit
f449d2cb4e
@ -44,7 +44,6 @@
|
|||||||
<th class='text-center'>Hostname</th>
|
<th class='text-center'>Hostname</th>
|
||||||
<th class='text-center'>Updates #</th>
|
<th class='text-center'>Updates #</th>
|
||||||
<th class='text-center'>Uptime</th>
|
<th class='text-center'>Uptime</th>
|
||||||
<th class='text-center'>Auto-update</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -56,7 +55,6 @@
|
|||||||
<td><a href="{% url 'packages-by-host' stat.server.hostname %}">{{ stat.server.hostname }}</b></td>
|
<td><a href="{% url 'packages-by-host' stat.server.hostname %}">{{ stat.server.hostname }}</b></td>
|
||||||
<td class='status-{{ stat.updates_status }} text-center'>{{ stat.updates }}</td>
|
<td class='status-{{ stat.updates_status }} text-center'>{{ stat.updates }}</td>
|
||||||
<td class='status-{{ stat.uptime_status }} text-center'>{{ stat.uptime }}</td>
|
<td class='status-{{ stat.uptime_status }} text-center'>{{ stat.uptime }}</td>
|
||||||
<td class='status-{{ stat.auto_updates_status }} text-center'>{{ stat.get_auto_updates_display }}</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -106,34 +104,10 @@ jQuery.fn.dataTableExt.oSort['num-none-desc'] = function(x,y) {
|
|||||||
else return ((parseInt(x) < parseInt(y)) ? 1 : ((parseInt(x) > parseInt(y)) ? -1 : 0));
|
else return ((parseInt(x) < parseInt(y)) ? 1 : ((parseInt(x) > parseInt(y)) ? -1 : 0));
|
||||||
};
|
};
|
||||||
|
|
||||||
// sort auto-updates status: Ok < Unkown < Error < N/A
|
|
||||||
// Error < Unkown < Ok < N/A
|
|
||||||
jQuery.fn.dataTableExt.oSort['auto-updates-asc'] = function(x,y) {
|
|
||||||
if (x == y) return 0;
|
|
||||||
else if (x == 'N/A') return 1;
|
|
||||||
else if (y == 'N/A') return -1;
|
|
||||||
else if (x == 'Ok') return -1;
|
|
||||||
else if (y == 'Ok') return 1;
|
|
||||||
else if (x == 'Error') return 1;
|
|
||||||
else if (y == 'Error') return -1;
|
|
||||||
};
|
|
||||||
jQuery.fn.dataTableExt.oSort['auto-updates-desc'] = function(x,y) {
|
|
||||||
if (x == y) return 0;
|
|
||||||
else if (x == 'N/A') return 1;
|
|
||||||
else if (y == 'N/A') return -1;
|
|
||||||
else if (x == 'Ok') return 1;
|
|
||||||
else if (y == 'Ok') return -1;
|
|
||||||
else if (x == 'Error') return -1;
|
|
||||||
else if (y == 'Error') return 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('#server-list').DataTable({
|
$('#server-list').DataTable({
|
||||||
"paging": false,
|
"paging": false,
|
||||||
"order": [[ 1, "asc" ]],
|
"order": [[ 1, "asc" ]],
|
||||||
"aoColumns": [
|
|
||||||
null, null, null, null, {"sType": "num-none"}, {"sType": "num-none"}, {"sType": "auto-updates"}
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
from django.conf.urls import url, include
|
from django.conf.urls import include
|
||||||
|
from django.urls import re_path
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth import views as auth_views
|
from django.contrib.auth import views as auth_views
|
||||||
@ -7,84 +8,84 @@ from . import views
|
|||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
# home
|
# home
|
||||||
url(r'^/?$',
|
re_path(r'^/?$',
|
||||||
views.index,
|
views.index,
|
||||||
name='index'),
|
name='index'),
|
||||||
|
|
||||||
# server list
|
# server list
|
||||||
url(r'^server-list/?$',
|
re_path(r'^server-list/?$',
|
||||||
views.server_list,
|
views.server_list,
|
||||||
name='server-list'),
|
name='server-list'),
|
||||||
url(r'^server-list/(?P<year>[0-9]{4})/(?P<month>[0-9]{1,2})/(?P<day>[0-9]{1,2})/?$',
|
re_path(r'^server-list/(?P<year>[0-9]{4})/(?P<month>[0-9]{1,2})/(?P<day>[0-9]{1,2})/?$',
|
||||||
views.server_list,
|
views.server_list,
|
||||||
name='server-list-by-date'),
|
name='server-list-by-date'),
|
||||||
url(r'^server-list/(?P<group>[a-z0-9\-_]*)/(?P<year>[0-9]{4})/(?P<month>[0-9]{1,2})/(?P<day>[0-9]{1,2})/?$',
|
re_path(r'^server-list/(?P<group>[a-z0-9\-_]*)/(?P<year>[0-9]{4})/(?P<month>[0-9]{1,2})/(?P<day>[0-9]{1,2})/?$',
|
||||||
views.server_list,
|
views.server_list,
|
||||||
name='server-list-by-group'),
|
name='server-list-by-group'),
|
||||||
url(r'^server-list/team/(?P<team>[a-z]*)/(?P<year>[0-9]{4})/(?P<month>[0-9]{1,2})/(?P<day>[0-9]{1,2})/?$',
|
re_path(r'^server-list/team/(?P<team>[a-z]*)/(?P<year>[0-9]{4})/(?P<month>[0-9]{1,2})/(?P<day>[0-9]{1,2})/?$',
|
||||||
views.server_list,
|
views.server_list,
|
||||||
name='server-list-by-team'),
|
name='server-list-by-team'),
|
||||||
|
|
||||||
# package list
|
# package list
|
||||||
url(r'^packages/?$',
|
re_path(r'^packages/?$',
|
||||||
views.packages_list,
|
views.packages_list,
|
||||||
name='packages-list'),
|
name='packages-list'),
|
||||||
url(r'^packages/package/(?P<package>[a-z0-9\.\-_]*)/?$',
|
re_path(r'^packages/package/(?P<package>[a-z0-9\.\-_]*)/?$',
|
||||||
views.packages,
|
views.packages,
|
||||||
name='packages-by-package'),
|
name='packages-by-package'),
|
||||||
url(r'^packages/host/(?P<hostname>[a-z0-9\.\-_]*)/?$',
|
re_path(r'^packages/host/(?P<hostname>[a-z0-9\.\-_]*)/?$',
|
||||||
views.packages,
|
views.packages,
|
||||||
name='packages-by-host'),
|
name='packages-by-host'),
|
||||||
|
|
||||||
# os statistics
|
# os statistics
|
||||||
url(r'^os-statistics/?$',
|
re_path(r'^os-statistics/?$',
|
||||||
views.os_statistics,
|
views.os_statistics,
|
||||||
name='os-statistics'),
|
name='os-statistics'),
|
||||||
|
|
||||||
# history graphs
|
# history graphs
|
||||||
url(r'^history/(?P<obj>updates|uptime|os)/?$',
|
re_path(r'^history/(?P<obj>updates|uptime|os)/?$',
|
||||||
views.history,
|
views.history,
|
||||||
name='history'),
|
name='history'),
|
||||||
url(r'^history/(?P<obj>updates|uptime|os)/(?P<year>[0-9]{4})/(?P<month>[0-9]{1,2})/?$',
|
re_path(r'^history/(?P<obj>updates|uptime|os)/(?P<year>[0-9]{4})/(?P<month>[0-9]{1,2})/?$',
|
||||||
views.history,
|
views.history,
|
||||||
name='history'),
|
name='history'),
|
||||||
|
|
||||||
# manage statuses
|
# manage statuses
|
||||||
url(r'^manage/?$',
|
re_path(r'^manage/?$',
|
||||||
views.manage,
|
views.manage,
|
||||||
name='manage'),
|
name='manage'),
|
||||||
url(r'^manage/purge/?$',
|
re_path(r'^manage/purge/?$',
|
||||||
views.purge_all,
|
views.purge_all,
|
||||||
name='purge_all'),
|
name='purge_all'),
|
||||||
url(r'^manage/purge/(?P<year>[0-9]{4})/(?P<month>[0-9]{1,2})/(?P<day>[0-9]{1,2})/?$',
|
re_path(r'^manage/purge/(?P<year>[0-9]{4})/(?P<month>[0-9]{1,2})/(?P<day>[0-9]{1,2})/?$',
|
||||||
views.purge_statuses_by_date,
|
views.purge_statuses_by_date,
|
||||||
name='purge_statuses_by_date'),
|
name='purge_statuses_by_date'),
|
||||||
url(r'^manage/import/(?P<year>[0-9]{4})/(?P<month>[0-9]{1,2})/(?P<day>[0-9]{1,2})/?$',
|
re_path(r'^manage/import/(?P<year>[0-9]{4})/(?P<month>[0-9]{1,2})/(?P<day>[0-9]{1,2})/?$',
|
||||||
views.import_csv,
|
views.import_csv,
|
||||||
name='import'),
|
name='import'),
|
||||||
url(r'^manage/update-groups/?$',
|
re_path(r'^manage/update-groups/?$',
|
||||||
views.update_groups,
|
views.update_groups,
|
||||||
name='update_groups'),
|
name='update_groups'),
|
||||||
|
|
||||||
# manage packages
|
# manage packages
|
||||||
url(r'^manage-packages/?$',
|
re_path(r'^manage-packages/?$',
|
||||||
views.manage_packages,
|
views.manage_packages,
|
||||||
name='manage-packages'),
|
name='manage-packages'),
|
||||||
url(r'^manage-packages/purge/?$',
|
re_path(r'^manage-packages/purge/?$',
|
||||||
views.purge_packages,
|
views.purge_packages,
|
||||||
name='purge_packages'),
|
name='purge_packages'),
|
||||||
url(r'^manage-packages/import/(?P<year>[0-9]{4})/(?P<month>[0-9]{1,2})/(?P<day>[0-9]{1,2})/?$',
|
re_path(r'^manage-packages/import/(?P<year>[0-9]{4})/(?P<month>[0-9]{1,2})/(?P<day>[0-9]{1,2})/?$',
|
||||||
views.import_csv_packages,
|
views.import_csv_packages,
|
||||||
name='import-packages'),
|
name='import-packages'),
|
||||||
|
|
||||||
# user
|
# user
|
||||||
url(r'^login/?$', auth_views.LoginView.as_view(), name='login'),
|
re_path(r'^login/?$', auth_views.LoginView.as_view(), name='login'),
|
||||||
url(r'^logout/?$', auth_views.LogoutView.as_view(), name='logout'),
|
re_path(r'^logout/?$', auth_views.LogoutView.as_view(), name='logout'),
|
||||||
]
|
]
|
||||||
|
|
||||||
# debug toolbar
|
# debug toolbar
|
||||||
if settings.DEBUG and settings.DEBUG_TOOLBAR:
|
if settings.DEBUG and settings.DEBUG_TOOLBAR:
|
||||||
import debug_toolbar
|
import debug_toolbar
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^__debug__/', include(debug_toolbar.urls)),
|
re_path(r'^__debug__/', include(debug_toolbar.urls)),
|
||||||
] + urlpatterns
|
] + urlpatterns
|
||||||
|
|||||||
@ -379,8 +379,7 @@ def purge_packages(request):
|
|||||||
@login_required
|
@login_required
|
||||||
def import_csv(request, year, month, day):
|
def import_csv(request, year, month, day):
|
||||||
# Reminder: the imported file must be in this format:
|
# Reminder: the imported file must be in this format:
|
||||||
# myserver.fr;Ubuntu;16;28;12;UNK
|
# myserver.fr;Ubuntu;16;28;12
|
||||||
# | | | | | |- 5: auto updates status
|
|
||||||
# | | | | |----- 4: uptime in days
|
# | | | | |----- 4: uptime in days
|
||||||
# | | | |-------- 3: number of available updates
|
# | | | |-------- 3: number of available updates
|
||||||
# | | |----------- 2: OS major version (string). Must match with OS model data
|
# | | |----------- 2: OS major version (string). Must match with OS model data
|
||||||
@ -417,7 +416,6 @@ def import_csv(request, year, month, day):
|
|||||||
row_os_version = row[2]
|
row_os_version = row[2]
|
||||||
row_updates = row[3] if row[3] else None
|
row_updates = row[3] if row[3] else None
|
||||||
row_uptime = row[4] if row[4] else None
|
row_uptime = row[4] if row[4] else None
|
||||||
row_auto_updates = row[5] if row[5] else None
|
|
||||||
|
|
||||||
# get OS
|
# get OS
|
||||||
cache_key_os = "os_%s_%s" % (row_os_distribution, row_os_version)
|
cache_key_os = "os_%s_%s" % (row_os_distribution, row_os_version)
|
||||||
@ -453,7 +451,6 @@ def import_csv(request, year, month, day):
|
|||||||
)
|
)
|
||||||
current_st.updates = row_updates
|
current_st.updates = row_updates
|
||||||
current_st.uptime = row_uptime
|
current_st.uptime = row_uptime
|
||||||
current_st.auto_updates = row_auto_updates
|
|
||||||
try:
|
try:
|
||||||
current_st.save()
|
current_st.save()
|
||||||
except IntegrityError:
|
except IntegrityError:
|
||||||
|
|||||||
@ -9,6 +9,7 @@ SECRET_KEY = 'long random key'
|
|||||||
#DEBUG = True
|
#DEBUG = True
|
||||||
|
|
||||||
ALLOWED_HOSTS = ['127.0.0.1', ]
|
ALLOWED_HOSTS = ['127.0.0.1', ]
|
||||||
|
CSRF_TRUSTED_ORIGINS ['127.0.0.1']
|
||||||
|
|
||||||
# for debug_toolbar
|
# for debug_toolbar
|
||||||
INTERNAL_IPS = ['127.0.0.1', ]
|
INTERNAL_IPS = ['127.0.0.1', ]
|
||||||
|
|||||||
@ -5,18 +5,19 @@ The `urlpatterns` list routes URLs to views. For more information please see:
|
|||||||
Examples:
|
Examples:
|
||||||
Function views
|
Function views
|
||||||
1. Add an import: from my_app import views
|
1. Add an import: from my_app import views
|
||||||
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
|
2. Add a URL to urlpatterns: re_path(r'^$', views.home, name='home')
|
||||||
Class-based views
|
Class-based views
|
||||||
1. Add an import: from other_app.views import Home
|
1. Add an import: from other_app.views import Home
|
||||||
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
|
2. Add a URL to urlpatterns: re_path(r'^$', Home.as_view(), name='home')
|
||||||
Including another URLconf
|
Including another URLconf
|
||||||
1. Import the include() function: from django.conf.urls import url, include
|
1. Import the include() function: from django.conf.urls import url, include
|
||||||
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
|
2. Add a URL to urlpatterns: re_path(r'^blog/', include('blog.urls'))
|
||||||
"""
|
"""
|
||||||
from django.conf.urls import url, include
|
from django.conf.urls import include
|
||||||
|
from django.urls import re_path
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^admin/', admin.site.urls),
|
re_path(r'^admin/', admin.site.urls),
|
||||||
url(r'^', include('dashboard.urls')),
|
re_path(r'^', include('dashboard.urls')),
|
||||||
]
|
]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user