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

Introduce ContentTypesColumn for custom field and webhook tables

This commit is contained in:
jeremystretch
2021-08-26 12:55:37 -04:00
parent 58203dbcfa
commit 94b8d36065
3 changed files with 22 additions and 8 deletions

View File

@@ -12,6 +12,8 @@ from django_tables2.data import TableQuerysetData
from django_tables2.utils import Accessor
from extras.models import CustomField
from extras.utils import FeatureQuery
from .utils import content_type_name
from .paginator import EnhancedPaginator, get_paginate_count
@@ -235,12 +237,20 @@ class ContentTypeColumn(tables.Column):
Display a ContentType instance.
"""
def render(self, value):
return value.name[0].upper() + value.name[1:]
return content_type_name(value)
def value(self, value):
return f"{value.app_label}.{value.model}"
class ContentTypesColumn(tables.ManyToManyColumn):
"""
Display a list of ContentType instances.
"""
def transform(self, obj):
return content_type_name(obj)
class ColorColumn(tables.Column):
"""
Display a color (#RRGGBB).