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

Closes #9006: Enable custom fields, custom links, and tags for journal entries

This commit is contained in:
jeremystretch
2022-03-31 11:40:02 -04:00
parent 7a54658710
commit 1d55c04c21
12 changed files with 68 additions and 46 deletions

View File

@ -12,7 +12,6 @@ __all__ = (
'ExportTemplateTable',
'JournalEntryTable',
'ObjectChangeTable',
'ObjectJournalTable',
'TaggedItemTable',
'TagTable',
'WebhookTable',
@ -210,25 +209,11 @@ class ObjectChangeTable(NetBoxTable):
)
class ObjectJournalTable(NetBoxTable):
"""
Used for displaying a set of JournalEntries within the context of a single object.
"""
class JournalEntryTable(NetBoxTable):
created = tables.DateTimeColumn(
linkify=True,
format=settings.SHORT_DATETIME_FORMAT
)
kind = columns.ChoiceFieldColumn()
comments = tables.TemplateColumn(
template_code='{{ value|markdown|truncatewords_html:50 }}'
)
class Meta(NetBoxTable.Meta):
model = JournalEntry
fields = ('id', 'created', 'created_by', 'kind', 'comments', 'actions')
class JournalEntryTable(ObjectJournalTable):
assigned_object_type = columns.ContentTypeColumn(
verbose_name='Object type'
)
@ -237,13 +222,22 @@ class JournalEntryTable(ObjectJournalTable):
orderable=False,
verbose_name='Object'
)
kind = columns.ChoiceFieldColumn()
comments = columns.MarkdownColumn()
comments_short = tables.TemplateColumn(
accessor=tables.A('comments'),
template_code='{{ value|markdown|truncatewords_html:50 }}',
verbose_name='Comments (Short)'
)
tags = columns.TagColumn(
url_name='extras:journalentry_list'
)
class Meta(NetBoxTable.Meta):
model = JournalEntry
fields = (
'pk', 'id', 'created', 'created_by', 'assigned_object_type', 'assigned_object', 'kind', 'comments',
'actions',
'comments_short', 'tags', 'actions',
)
default_columns = (
'pk', 'created', 'created_by', 'assigned_object_type', 'assigned_object', 'kind', 'comments'