Jeremy Stretch 5 лет назад
Родитель
Сommit
2a47bb8b54

+ 2 - 2
docs/plugins/development.md

@@ -84,7 +84,7 @@ class AnimalSoundsConfig(PluginConfig):
     version = '0.1'
     author = 'Author Name'
     description = 'Show animals and the sounds they make'
-    url_slug = 'animal-sounds'
+    base_url = 'animal-sounds'
     required_settings = []
     default_settings = {
         'loud': False
@@ -99,7 +99,7 @@ class AnimalSoundsConfig(PluginConfig):
 * `verbose_name` - Human-friendly name
 * `version` - Plugin version
 * `description` - Brief description of the plugin's purpose
-* `url_slug` - Base path to use for plugin URLs (optional). If not specified, the project's `name` will be used.
+* `base_url` - Base path to use for plugin URLs (optional). If not specified, the project's `name` will be used.
 * `required_settings`: A list of configuration parameters that **must** be defined by the user
 * `default_settings`: A dictionary of configuration parameter names and their default values
 * `min_version`: Minimum version of NetBox with which the plugin is compatible

+ 1 - 1
netbox/extras/plugins/__init__.py

@@ -23,7 +23,7 @@ class PluginConfig(AppConfig):
     version = ''
 
     # Root URL path under /plugins. If not set, the plugin's label will be used.
-    url_slug = None
+    base_url = None
 
     # Minimum/maximum compatible versions of NetBox
     min_version = None

+ 3 - 4
netbox/extras/plugins/urls.py

@@ -13,13 +13,13 @@ plugin_api_patterns = []
 for plugin in settings.PLUGINS:
     app = apps.get_app_config(plugin)
 
-    url_slug = getattr(app, 'url_slug') or app.label
+    base_url = getattr(app, 'base_url') or app.label
 
     # Check if the plugin specifies any URLs
     try:
         urlpatterns = import_string(f"{plugin}.urls.urlpatterns")
         plugin_patterns.append(
-            path(f"{url_slug}/", include((urlpatterns, app.label)))
+            path(f"{base_url}/", include((urlpatterns, app.label)))
         )
     except ImportError:
         pass
@@ -27,9 +27,8 @@ for plugin in settings.PLUGINS:
     # Check if the plugin specifies any API URLs
     try:
         urlpatterns = import_string(f"{plugin}.api.urls.urlpatterns")
-        app_name = f"{url_slug}-api"
         plugin_api_patterns.append(
-            path(f"{url_slug}/", include((urlpatterns, app_name)))
+            path(f"{base_url}/", include((urlpatterns, f"{app.label}-api")))
         )
     except ImportError:
         pass

+ 1 - 1
netbox/extras/plugins/views.py

@@ -69,7 +69,7 @@ class PluginsAPIRootView(APIView):
             return None
 
         try:
-            entry = (getattr(app_config, 'url_slug', app_config.label), reverse(
+            entry = (getattr(app_config, 'base_url', app_config.label), reverse(
                 f"plugins-api:{api_app_name}:api-root",
                 request=request,
                 format=format