mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Fixes #5285: Include plugin API endpoints in root view without needing app_name set
This commit is contained in:
@ -10,8 +10,6 @@ from rest_framework.response import Response
|
|||||||
from rest_framework.reverse import reverse
|
from rest_framework.reverse import reverse
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
|
|
||||||
from extras.plugins.utils import import_object
|
|
||||||
|
|
||||||
|
|
||||||
class InstalledPluginsAdminView(View):
|
class InstalledPluginsAdminView(View):
|
||||||
"""
|
"""
|
||||||
@ -62,11 +60,7 @@ class PluginsAPIRootView(APIView):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_plugin_entry(plugin, app_config, request, format):
|
def _get_plugin_entry(plugin, app_config, request, format):
|
||||||
# Check if the plugin specifies any API URLs
|
# Check if the plugin specifies any API URLs
|
||||||
api_app_name = import_object(f"{plugin}.api.urls.app_name")
|
api_app_name = f'{app_config.name}-api'
|
||||||
if api_app_name is None:
|
|
||||||
# Plugin does not expose an API
|
|
||||||
return None
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
entry = (getattr(app_config, 'base_url', app_config.label), reverse(
|
entry = (getattr(app_config, 'base_url', app_config.label), reverse(
|
||||||
f"plugins-api:{api_app_name}:api-root",
|
f"plugins-api:{api_app_name}:api-root",
|
||||||
|
Reference in New Issue
Block a user