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

General cleanup of tables

This commit is contained in:
Jeremy Stretch
2020-09-25 14:18:29 -04:00
parent 28f0da0bc1
commit 12e2537222
7 changed files with 27 additions and 106 deletions

View File

@ -1,6 +1,7 @@
import django_tables2 as tables
from django.conf import settings
from utilities.tables import BaseTable, BooleanColumn, ButtonsColumn, ColorColumn, ToggleColumn
from utilities.tables import BaseTable, BooleanColumn, ButtonsColumn, ChoiceFieldColumn, ColorColumn, ToggleColumn
from .models import ConfigContext, ObjectChange, Tag, TaggedItem
TAGGED_ITEM = """
@ -20,20 +21,6 @@ CONFIGCONTEXT_ACTIONS = """
{% endif %}
"""
OBJECTCHANGE_TIME = """
<a href="{{ record.get_absolute_url }}">{{ value|date:"SHORT_DATETIME_FORMAT" }}</a>
"""
OBJECTCHANGE_ACTION = """
{% if record.action == 'create' %}
<span class="label label-success">Created</span>
{% elif record.action == 'update' %}
<span class="label label-primary">Updated</span>
{% elif record.action == 'delete' %}
<span class="label label-danger">Deleted</span>
{% endif %}
"""
OBJECTCHANGE_OBJECT = """
{% if record.action != 3 and record.changed_object.get_absolute_url %}
<a href="{{ record.changed_object.get_absolute_url }}">{{ record.object_repr }}</a>
@ -91,12 +78,11 @@ class ConfigContextTable(BaseTable):
class ObjectChangeTable(BaseTable):
time = tables.TemplateColumn(
template_code=OBJECTCHANGE_TIME
)
action = tables.TemplateColumn(
template_code=OBJECTCHANGE_ACTION
time = tables.DateTimeColumn(
linkify=True,
format=settings.SHORT_DATETIME_FORMAT
)
action = ChoiceFieldColumn()
changed_object_type = tables.Column(
verbose_name='Type'
)