Skip to content

Commit

Permalink
16136 remove Django Admin (#17619)
Browse files Browse the repository at this point in the history
* 16136 remove Django Admin

* 16136 fix plugin test

* 16136 fix migrations

* Revert "16136 fix migrations"

This reverts commit 80296fa.

* Remove obsolete admin module from dummy plugin

* Remove obsolete admin site configuration

* Remove unused import statement

* Remove obsolete admin module

* Misc cleanup

---------

Co-authored-by: Jeremy Stretch <[email protected]>
  • Loading branch information
arthanson and jeremystretch authored Sep 27, 2024
1 parent 8539686 commit c60a0f4
Show file tree
Hide file tree
Showing 10 changed files with 0 additions and 61 deletions.
8 changes: 0 additions & 8 deletions docs/configuration/miscellaneous.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,6 @@ The maximum size (in bytes) of an incoming HTTP request (i.e. `GET` or `POST` da

---

## DJANGO_ADMIN_ENABLED

Default: False

Setting this to True installs the `django.contrib.admin` app and enables the [Django admin UI](https://docs.djangoproject.com/en/5.0/ref/contrib/admin/). This may be necessary to support older plugins which do not integrate with the native NetBox interface.

---

## ENFORCE_GLOBAL_UNIQUE

!!! tip "Dynamic Configuration Parameter"
Expand Down
14 changes: 0 additions & 14 deletions netbox/netbox/admin.py

This file was deleted.

2 changes: 0 additions & 2 deletions netbox/netbox/configuration_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@

SECRET_KEY = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'

DJANGO_ADMIN_ENABLED = True

DEFAULT_PERMISSIONS = {}

LOGGING = {
Expand Down
2 changes: 0 additions & 2 deletions netbox/netbox/plugins/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
from django.apps import apps
from django.conf import settings
from django.conf.urls import include
from django.contrib.admin.views.decorators import staff_member_required
from django.urls import path
from django.utils.module_loading import import_string, module_has_submodule

from . import views

# Initialize URL base, API, and admin URL patterns for plugins
plugin_patterns = []
plugin_api_patterns = [
path('', views.PluginsAPIRootView.as_view(), name='api-root'),
Expand Down
5 changes: 0 additions & 5 deletions netbox/netbox/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@
'users.delete_token': ({'user': '$user'},),
})
DEVELOPER = getattr(configuration, 'DEVELOPER', False)
DJANGO_ADMIN_ENABLED = getattr(configuration, 'DJANGO_ADMIN_ENABLED', False)
DOCS_ROOT = getattr(configuration, 'DOCS_ROOT', os.path.join(os.path.dirname(BASE_DIR), 'docs'))
EMAIL = getattr(configuration, 'EMAIL', {})
EVENTS_PIPELINE = getattr(configuration, 'EVENTS_PIPELINE', (
Expand Down Expand Up @@ -373,7 +372,6 @@ def _setting(name, default=None):
#

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
Expand Down Expand Up @@ -411,8 +409,6 @@ def _setting(name, default=None):
]
if not DEBUG:
INSTALLED_APPS.remove('debug_toolbar')
if not DJANGO_ADMIN_ENABLED:
INSTALLED_APPS.remove('django.contrib.admin')

# Middleware
MIDDLEWARE = [
Expand Down Expand Up @@ -549,7 +545,6 @@ def _setting(name, default=None):

# All URLs starting with a string listed here are exempt from maintenance mode enforcement
MAINTENANCE_EXEMPT_PATHS = (
f'/{BASE_PATH}admin/',
f'/{BASE_PATH}extras/config-revisions/', # Allow modifying the configuration
LOGIN_URL,
LOGIN_REDIRECT_URL,
Expand Down
9 changes: 0 additions & 9 deletions netbox/netbox/tests/dummy_plugin/admin.py

This file was deleted.

6 changes: 0 additions & 6 deletions netbox/netbox/tests/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ def test_models(self):
instance.delete()
self.assertIsNone(instance.pk)

def test_admin(self):

# Test admin view URL resolution
url = reverse('admin:dummy_plugin_dummymodel_add')
self.assertEqual(url, '/admin/dummy_plugin/dummymodel/add/')

@override_settings(LOGIN_REQUIRED=False)
def test_views(self):

Expand Down
5 changes: 0 additions & 5 deletions netbox/netbox/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@
path('api/plugins/', include((plugin_api_patterns, 'plugins-api'))),
]

# Django admin UI
if settings.DJANGO_ADMIN_ENABLED:
from .admin import admin_site
_patterns.append(path('admin/', admin_site.urls))

# django-debug-toolbar
if settings.DEBUG:
import debug_toolbar
Expand Down
5 changes: 0 additions & 5 deletions netbox/templates/inc/user_menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@
</div>
</a>
<div class="dropdown-menu dropdown-menu-end dropdown-menu-arrow" {% htmx_boost %}>
{% if config.DJANGO_ADMIN_ENABLED and request.user.is_staff %}
<a class="dropdown-item" href="{% url 'admin:index' %}">
<i class="mdi mdi-cog"></i> {% trans "Django Admin" %}
</a>
{% endif %}
<a href="{% url 'account:profile' %}" class="dropdown-item">
<i class="mdi mdi-account"></i> {% trans "Profile" %}
</a>
Expand Down
5 changes: 0 additions & 5 deletions netbox/users/admin.py

This file was deleted.

0 comments on commit c60a0f4

Please sign in to comment.