Move some panels to extras

This commit is contained in:
Jeremy Stretch
2025-11-03 14:59:54 -05:00
parent 17cffd7860
commit ed3dd019a7
3 changed files with 47 additions and 42 deletions

View File

@@ -0,0 +1,42 @@
from django.contrib.contenttypes.models import ContentType
from django.utils.translation import gettext_lazy as _
from netbox.ui import actions, panels
__all__ = (
'CustomFieldsPanel',
'ImageAttachmentsPanel',
'TagsPanel',
)
class CustomFieldsPanel(panels.Panel):
template_name = 'ui/panels/custom_fields.html'
title = _('Custom Fields')
def get_context(self, obj):
return {
'custom_fields': obj.get_custom_fields_by_group(),
}
class ImageAttachmentsPanel(panels.ObjectsTablePanel):
actions = [
actions.AddObject(
'extras.imageattachment',
url_params={
'object_type': lambda obj: ContentType.objects.get_for_model(obj).pk,
'object_id': lambda obj: obj.pk,
'return_url': lambda obj: obj.get_absolute_url(),
},
label=_('Attach an image'),
),
]
def __init__(self, **kwargs):
super().__init__('extras.imageattachment', **kwargs)
class TagsPanel(panels.Panel):
template_name = 'ui/panels/tags.html'
title = _('Tags')