mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-12 06:42:16 -06:00
Compare commits
1 Commits
20239-plug
...
update-cha
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6fce84644c |
@@ -10,9 +10,11 @@ Change records are exposed in the API via the read-only endpoint `/api/extras/ob
|
|||||||
|
|
||||||
## User Messages
|
## User Messages
|
||||||
|
|
||||||
!!! info "This feature was introduced in NetBox v4.4."
|
When creating, modifying, or deleting an object in NetBox, a user has the option of recording an arbitrary message (up to 200 characters) that will appear in the change record. This can be helpful to capture additional context, such as the reason for a change or a reference to an external ticket.
|
||||||
|
|
||||||
When creating, modifying, or deleting an object in NetBox, a user has the option of recording an arbitrary message that will appear in the change record. This can be helpful to capture additional context, such as the reason for the change.
|
When editing an object via the web UI, the "Changelog message" field appears at the bottom of the form. This field is optional. The changelog message field is available in object create forms, object edit forms, delete confirmation dialogs, and bulk operations.
|
||||||
|
|
||||||
|
For information on including changelog messages when making changes via the REST API, see [Changelog Messages](../integrations/rest-api.md#changelog-messages).
|
||||||
|
|
||||||
## Correlating Changes by Request
|
## Correlating Changes by Request
|
||||||
|
|
||||||
|
|||||||
@@ -610,9 +610,7 @@ http://netbox/api/dcim/sites/ \
|
|||||||
|
|
||||||
## Changelog Messages
|
## Changelog Messages
|
||||||
|
|
||||||
!!! info "This feature was introduced in NetBox v4.4."
|
Most objects in NetBox support [change logging](../features/change-logging.md), which generates a detailed record each time an object is created, modified, or deleted. Additionally, users can attach a message to the change record as well. This is accomplished via the REST API by including a `changelog_message` field in the object representation.
|
||||||
|
|
||||||
Most objects in NetBox support [change logging](../features/change-logging.md), which generates a detailed record each time an object is created, modified, or deleted. Beginning in NetBox v4.4, users can attach a message to the change record as well. This is accomplished via the REST API by including a `changelog_message` field in the object representation.
|
|
||||||
|
|
||||||
For example, the following API request will create a new site and record a message in the resulting changelog entry:
|
For example, the following API request will create a new site and record a message in the resulting changelog entry:
|
||||||
|
|
||||||
@@ -628,7 +626,7 @@ http://netbox/api/dcim/sites/ \
|
|||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
This approach works when creating, modifying, or deleting objects, either individually or in bulk.
|
This approach works when creating, modifying, or deleting objects, either individually or in bulk. For more information about change logging, see [Change Logging](../features/change-logging.md).
|
||||||
|
|
||||||
## Uploading Files
|
## Uploading Files
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ class PluginMenuItem:
|
|||||||
Alternatively, a pre-generated url can be set on the object which will be rendered literally.
|
Alternatively, a pre-generated url can be set on the object which will be rendered literally.
|
||||||
Buttons are each specified as a list of PluginMenuButton instances.
|
Buttons are each specified as a list of PluginMenuButton instances.
|
||||||
"""
|
"""
|
||||||
|
permissions = []
|
||||||
|
buttons = []
|
||||||
_url = None
|
_url = None
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
@@ -52,14 +54,10 @@ class PluginMenuItem:
|
|||||||
if type(permissions) not in (list, tuple):
|
if type(permissions) not in (list, tuple):
|
||||||
raise TypeError(_("Permissions must be passed as a tuple or list."))
|
raise TypeError(_("Permissions must be passed as a tuple or list."))
|
||||||
self.permissions = permissions
|
self.permissions = permissions
|
||||||
else:
|
|
||||||
self.permissions = []
|
|
||||||
if buttons is not None:
|
if buttons is not None:
|
||||||
if type(buttons) not in (list, tuple):
|
if type(buttons) not in (list, tuple):
|
||||||
raise TypeError(_("Buttons must be passed as a tuple or list."))
|
raise TypeError(_("Buttons must be passed as a tuple or list."))
|
||||||
self.buttons = buttons
|
self.buttons = buttons
|
||||||
else:
|
|
||||||
self.buttons = []
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def url(self):
|
def url(self):
|
||||||
@@ -76,6 +74,7 @@ class PluginMenuButton:
|
|||||||
ButtonColorChoices.
|
ButtonColorChoices.
|
||||||
"""
|
"""
|
||||||
color = ButtonColorChoices.DEFAULT
|
color = ButtonColorChoices.DEFAULT
|
||||||
|
permissions = []
|
||||||
_url = None
|
_url = None
|
||||||
|
|
||||||
def __init__(self, link, title, icon_class, color=None, permissions=None):
|
def __init__(self, link, title, icon_class, color=None, permissions=None):
|
||||||
@@ -88,8 +87,6 @@ class PluginMenuButton:
|
|||||||
if type(permissions) not in (list, tuple):
|
if type(permissions) not in (list, tuple):
|
||||||
raise TypeError(_("Permissions must be passed as a tuple or list."))
|
raise TypeError(_("Permissions must be passed as a tuple or list."))
|
||||||
self.permissions = permissions
|
self.permissions = permissions
|
||||||
else:
|
|
||||||
self.permissions = []
|
|
||||||
if color is not None:
|
if color is not None:
|
||||||
if color not in ButtonColorChoices.values():
|
if color not in ButtonColorChoices.values():
|
||||||
raise ValueError(_("Button color must be a choice within ButtonColorChoices."))
|
raise ValueError(_("Button color must be a choice within ButtonColorChoices."))
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from netbox.tests.dummy_plugin import config as dummy_config
|
|||||||
from netbox.tests.dummy_plugin.data_backends import DummyBackend
|
from netbox.tests.dummy_plugin.data_backends import DummyBackend
|
||||||
from netbox.tests.dummy_plugin.jobs import DummySystemJob
|
from netbox.tests.dummy_plugin.jobs import DummySystemJob
|
||||||
from netbox.tests.dummy_plugin.webhook_callbacks import set_context
|
from netbox.tests.dummy_plugin.webhook_callbacks import set_context
|
||||||
from netbox.plugins.navigation import PluginMenu, PluginMenuItem, PluginMenuButton
|
from netbox.plugins.navigation import PluginMenu
|
||||||
from netbox.plugins.utils import get_plugin_config
|
from netbox.plugins.utils import get_plugin_config
|
||||||
from netbox.graphql.schema import Query
|
from netbox.graphql.schema import Query
|
||||||
from netbox.registry import registry
|
from netbox.registry import registry
|
||||||
@@ -227,46 +227,3 @@ class PluginTest(TestCase):
|
|||||||
Test the registration of webhook callbacks.
|
Test the registration of webhook callbacks.
|
||||||
"""
|
"""
|
||||||
self.assertIn(set_context, registry['webhook_callbacks'])
|
self.assertIn(set_context, registry['webhook_callbacks'])
|
||||||
|
|
||||||
|
|
||||||
class PluginNavigationTest(TestCase):
|
|
||||||
|
|
||||||
def test_plugin_menu_item_independent_permissions(self):
|
|
||||||
item1 = PluginMenuItem(link='test1', link_text='Test 1')
|
|
||||||
item1.permissions.append('leaked_permission')
|
|
||||||
|
|
||||||
item2 = PluginMenuItem(link='test2', link_text='Test 2')
|
|
||||||
|
|
||||||
self.assertIsNot(item1.permissions, item2.permissions)
|
|
||||||
self.assertEqual(item1.permissions, ['leaked_permission'])
|
|
||||||
self.assertEqual(item2.permissions, [])
|
|
||||||
|
|
||||||
def test_plugin_menu_item_independent_buttons(self):
|
|
||||||
item1 = PluginMenuItem(link='test1', link_text='Test 1')
|
|
||||||
button = PluginMenuButton(link='button1', title='Button 1', icon_class='mdi-test')
|
|
||||||
item1.buttons.append(button)
|
|
||||||
|
|
||||||
item2 = PluginMenuItem(link='test2', link_text='Test 2')
|
|
||||||
|
|
||||||
self.assertIsNot(item1.buttons, item2.buttons)
|
|
||||||
self.assertEqual(len(item1.buttons), 1)
|
|
||||||
self.assertEqual(item1.buttons[0], button)
|
|
||||||
self.assertEqual(item2.buttons, [])
|
|
||||||
|
|
||||||
def test_plugin_menu_button_independent_permissions(self):
|
|
||||||
button1 = PluginMenuButton(link='button1', title='Button 1', icon_class='mdi-test')
|
|
||||||
button1.permissions.append('leaked_permission')
|
|
||||||
|
|
||||||
button2 = PluginMenuButton(link='button2', title='Button 2', icon_class='mdi-test')
|
|
||||||
|
|
||||||
self.assertIsNot(button1.permissions, button2.permissions)
|
|
||||||
self.assertEqual(button1.permissions, ['leaked_permission'])
|
|
||||||
self.assertEqual(button2.permissions, [])
|
|
||||||
|
|
||||||
def test_explicit_permissions_remain_independent(self):
|
|
||||||
item1 = PluginMenuItem(link='test1', link_text='Test 1', permissions=['explicit_permission'])
|
|
||||||
item2 = PluginMenuItem(link='test2', link_text='Test 2', permissions=['different_permission'])
|
|
||||||
|
|
||||||
self.assertIsNot(item1.permissions, item2.permissions)
|
|
||||||
self.assertEqual(item1.permissions, ['explicit_permission'])
|
|
||||||
self.assertEqual(item2.permissions, ['different_permission'])
|
|
||||||
|
|||||||
Reference in New Issue
Block a user