mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Rename url_slug to base_url
This commit is contained in:
@ -84,7 +84,7 @@ class AnimalSoundsConfig(PluginConfig):
|
|||||||
version = '0.1'
|
version = '0.1'
|
||||||
author = 'Author Name'
|
author = 'Author Name'
|
||||||
description = 'Show animals and the sounds they make'
|
description = 'Show animals and the sounds they make'
|
||||||
url_slug = 'animal-sounds'
|
base_url = 'animal-sounds'
|
||||||
required_settings = []
|
required_settings = []
|
||||||
default_settings = {
|
default_settings = {
|
||||||
'loud': False
|
'loud': False
|
||||||
@ -99,7 +99,7 @@ class AnimalSoundsConfig(PluginConfig):
|
|||||||
* `verbose_name` - Human-friendly name
|
* `verbose_name` - Human-friendly name
|
||||||
* `version` - Plugin version
|
* `version` - Plugin version
|
||||||
* `description` - Brief description of the plugin's purpose
|
* `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
|
* `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
|
* `default_settings`: A dictionary of configuration parameter names and their default values
|
||||||
* `min_version`: Minimum version of NetBox with which the plugin is compatible
|
* `min_version`: Minimum version of NetBox with which the plugin is compatible
|
||||||
|
@ -23,7 +23,7 @@ class PluginConfig(AppConfig):
|
|||||||
version = ''
|
version = ''
|
||||||
|
|
||||||
# Root URL path under /plugins. If not set, the plugin's label will be used.
|
# 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
|
# Minimum/maximum compatible versions of NetBox
|
||||||
min_version = None
|
min_version = None
|
||||||
|
@ -13,13 +13,13 @@ plugin_api_patterns = []
|
|||||||
for plugin in settings.PLUGINS:
|
for plugin in settings.PLUGINS:
|
||||||
app = apps.get_app_config(plugin)
|
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
|
# Check if the plugin specifies any URLs
|
||||||
try:
|
try:
|
||||||
urlpatterns = import_string(f"{plugin}.urls.urlpatterns")
|
urlpatterns = import_string(f"{plugin}.urls.urlpatterns")
|
||||||
plugin_patterns.append(
|
plugin_patterns.append(
|
||||||
path(f"{url_slug}/", include((urlpatterns, app.label)))
|
path(f"{base_url}/", include((urlpatterns, app.label)))
|
||||||
)
|
)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
@ -27,9 +27,8 @@ for plugin in settings.PLUGINS:
|
|||||||
# Check if the plugin specifies any API URLs
|
# Check if the plugin specifies any API URLs
|
||||||
try:
|
try:
|
||||||
urlpatterns = import_string(f"{plugin}.api.urls.urlpatterns")
|
urlpatterns = import_string(f"{plugin}.api.urls.urlpatterns")
|
||||||
app_name = f"{url_slug}-api"
|
|
||||||
plugin_api_patterns.append(
|
plugin_api_patterns.append(
|
||||||
path(f"{url_slug}/", include((urlpatterns, app_name)))
|
path(f"{base_url}/", include((urlpatterns, f"{app.label}-api")))
|
||||||
)
|
)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
@ -69,7 +69,7 @@ class PluginsAPIRootView(APIView):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
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",
|
f"plugins-api:{api_app_name}:api-root",
|
||||||
request=request,
|
request=request,
|
||||||
format=format
|
format=format
|
||||||
|
Reference in New Issue
Block a user