Jelajahi Sumber

Closes #4386: Update admin links for Django RQ to reflect multiple queues

Jeremy Stretch 5 tahun lalu
induk
melakukan
05fdf5e9a0

+ 1 - 0
docs/release-notes/version-2.7.md

@@ -11,6 +11,7 @@
 * [#4380](https://github.com/netbox-community/netbox/issues/4380) - Enable webhooks for rack reservations
 * [#4381](https://github.com/netbox-community/netbox/issues/4381) - Enable export templates for rack reservations
 * [#4382](https://github.com/netbox-community/netbox/issues/4382) - Enable custom links for rack reservations
+* [#4386](https://github.com/netbox-community/netbox/issues/4386) - Update admin links for Django RQ to reflect multiple queues
 
 ### Bug Fixes
 

+ 0 - 1
netbox/netbox/admin.py

@@ -11,7 +11,6 @@ class NetBoxAdminSite(AdminSite):
     site_header = 'NetBox Administration'
     site_title = 'NetBox'
     site_url = '/{}'.format(settings.BASE_PATH)
-    index_template = 'django_rq/index.html'
 
 
 admin_site = NetBoxAdminSite(name='admin')

+ 17 - 2
netbox/netbox/urls.py

@@ -1,6 +1,7 @@
 from django.conf import settings
 from django.conf.urls import include
-from django.urls import path, re_path
+from django.urls import path, re_path, reverse
+from django.views.generic.base import RedirectView
 from django.views.static import serve
 from drf_yasg import openapi
 from drf_yasg.views import get_schema_view
@@ -9,6 +10,18 @@ from netbox.views import APIRootView, HomeView, StaticMediaFailureView, SearchVi
 from users.views import LoginView, LogoutView
 from .admin import admin_site
 
+
+# TODO: Remove in v2.9
+class RQRedirectView(RedirectView):
+    """
+    Temporary 301 redirect from the old URL to the new one.
+    """
+    permanent = True
+
+    def get_redirect_url(self, *args, **kwargs):
+        return reverse('rq_home')
+
+
 openapi_info = openapi.Info(
     title="NetBox API",
     default_version='v2',
@@ -61,7 +74,9 @@ _patterns = [
 
     # Admin
     path('admin/', admin_site.urls),
-    path('admin/webhook-backend-status/', include('django_rq.urls')),
+    path('admin/background-tasks/', include('django_rq.urls')),
+    # TODO: Remove in v2.9
+    path('admin/webhook-backend-status/', RQRedirectView.as_view()),
 
     # Errors
     path('media-failure/', StaticMediaFailureView.as_view(), name='media_failure'),

+ 19 - 0
netbox/templates/admin/index.html

@@ -0,0 +1,19 @@
+{% extends "admin/index.html" %}
+
+{% block content_title %}{% endblock %}
+
+{% block sidebar %}
+    {{ block.super }}
+    <div class="module">
+        <table style="width: 100%">
+            <caption>Utilities</caption>
+            <tbody>
+                <tr>
+                    <th>
+                        <a href="{% url 'rq_home' %}">Background Tasks</a>
+                    </th>
+                </tr>
+            </tbody>
+        </table>
+    </div>
+{% endblock %}