mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-22 05:12:22 -06:00
General cleanup of tables
This commit is contained in:
@@ -78,6 +78,12 @@ class ObjectChangeActionChoices(ChoiceSet):
|
||||
(ACTION_DELETE, 'Deleted'),
|
||||
)
|
||||
|
||||
CSS_CLASSES = {
|
||||
ACTION_CREATE: 'success',
|
||||
ACTION_UPDATE: 'primary',
|
||||
ACTION_DELETE: 'danger',
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Log Levels for Reports and Scripts
|
||||
|
||||
@@ -152,3 +152,6 @@ class ObjectChange(models.Model):
|
||||
self.object_repr,
|
||||
self.object_data,
|
||||
)
|
||||
|
||||
def get_action_class(self):
|
||||
return ObjectChangeActionChoices.CSS_CLASSES.get(self.action)
|
||||
|
||||
@@ -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'
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user