1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes #4698: Improve display of template code for object in admin UI

This commit is contained in:
Jeremy Stretch
2020-06-04 13:11:24 -04:00
parent 91ba44cc96
commit fae115b995
2 changed files with 50 additions and 10 deletions

View File

@ -2,6 +2,10 @@
## v2.8.6 (FUTURE) ## v2.8.6 (FUTURE)
### Enhancements
* [#4698](https://github.com/netbox-community/netbox/issues/4698) - Improve display of template code for object in admin UI
### Bug Fixes ### Bug Fixes
* [#4702](https://github.com/netbox-community/netbox/issues/4702) - Catch IntegrityError exception when adding a non-unique secret * [#4702](https://github.com/netbox-community/netbox/issues/4702) - Catch IntegrityError exception when adding a non-unique secret

View File

@ -46,24 +46,19 @@ class WebhookAdmin(admin.ModelAdmin):
form = WebhookForm form = WebhookForm
fieldsets = ( fieldsets = (
(None, { (None, {
'fields': ( 'fields': ('name', 'obj_type', 'enabled')
'name', 'obj_type', 'enabled',
)
}), }),
('Events', { ('Events', {
'fields': ( 'fields': ('type_create', 'type_update', 'type_delete')
'type_create', 'type_update', 'type_delete',
)
}), }),
('HTTP Request', { ('HTTP Request', {
'fields': ( 'fields': (
'payload_url', 'http_method', 'http_content_type', 'additional_headers', 'body_template', 'secret', 'payload_url', 'http_method', 'http_content_type', 'additional_headers', 'body_template', 'secret',
) ),
'classes': ('monospace',)
}), }),
('SSL', { ('SSL', {
'fields': ( 'fields': ('ssl_verification', 'ca_file_path')
'ssl_verification', 'ca_file_path',
)
}) })
) )
@ -121,6 +116,8 @@ class CustomLinkForm(forms.ModelForm):
'url': forms.Textarea, 'url': forms.Textarea,
} }
help_texts = { help_texts = {
'weight': 'A numeric weight to influence the ordering of this link among its peers. Lower weights appear '
'first in a list.',
'text': 'Jinja2 template code for the link text. Reference the object as <code>{{ obj }}</code>. Links ' 'text': 'Jinja2 template code for the link text. Reference the object as <code>{{ obj }}</code>. Links '
'which render as empty text will not be displayed.', 'which render as empty text will not be displayed.',
'url': 'Jinja2 template code for the link URL. Reference the object as <code>{{ obj }}</code>.', 'url': 'Jinja2 template code for the link URL. Reference the object as <code>{{ obj }}</code>.',
@ -136,6 +133,15 @@ class CustomLinkForm(forms.ModelForm):
@admin.register(CustomLink) @admin.register(CustomLink)
class CustomLinkAdmin(admin.ModelAdmin): class CustomLinkAdmin(admin.ModelAdmin):
fieldsets = (
('Custom Link', {
'fields': ('content_type', 'name', 'group_name', 'weight', 'button_class', 'new_window')
}),
('Templates', {
'fields': ('text', 'url'),
'classes': ('monospace',)
})
)
list_display = [ list_display = [
'name', 'content_type', 'group_name', 'weight', 'name', 'content_type', 'group_name', 'weight',
] ]
@ -149,8 +155,29 @@ class CustomLinkAdmin(admin.ModelAdmin):
# Graphs # Graphs
# #
class GraphForm(forms.ModelForm):
class Meta:
model = Graph
exclude = ()
widgets = {
'source': forms.Textarea,
'link': forms.Textarea,
}
@admin.register(Graph) @admin.register(Graph)
class GraphAdmin(admin.ModelAdmin): class GraphAdmin(admin.ModelAdmin):
fieldsets = (
('Graph', {
'fields': ('type', 'name', 'weight')
}),
('Templates', {
'fields': ('template_language', 'source', 'link'),
'classes': ('monospace',)
})
)
form = GraphForm
list_display = [ list_display = [
'name', 'type', 'weight', 'template_language', 'source', 'name', 'type', 'weight', 'template_language', 'source',
] ]
@ -179,6 +206,15 @@ class ExportTemplateForm(forms.ModelForm):
@admin.register(ExportTemplate) @admin.register(ExportTemplate)
class ExportTemplateAdmin(admin.ModelAdmin): class ExportTemplateAdmin(admin.ModelAdmin):
fieldsets = (
('Export Template', {
'fields': ('content_type', 'name', 'description', 'mime_type', 'file_extension')
}),
('Content', {
'fields': ('template_language', 'template_code'),
'classes': ('monospace',)
})
)
list_display = [ list_display = [
'name', 'content_type', 'description', 'mime_type', 'file_extension', 'name', 'content_type', 'description', 'mime_type', 'file_extension',
] ]