mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Closes #7858: Standardize the representation of content types across import & export functions
This commit is contained in:
@@ -13,7 +13,7 @@ from django_tables2.utils import Accessor
|
||||
|
||||
from extras.choices import CustomFieldTypeChoices
|
||||
from extras.models import CustomField
|
||||
from .utils import content_type_name
|
||||
from .utils import content_type_identifier, content_type_name
|
||||
from .paginator import EnhancedPaginator, get_paginate_count
|
||||
|
||||
|
||||
@@ -289,16 +289,27 @@ class ContentTypeColumn(tables.Column):
|
||||
def value(self, value):
|
||||
if value is None:
|
||||
return None
|
||||
return f"{value.app_label}.{value.model}"
|
||||
return content_type_identifier(value)
|
||||
|
||||
|
||||
class ContentTypesColumn(tables.ManyToManyColumn):
|
||||
"""
|
||||
Display a list of ContentType instances.
|
||||
"""
|
||||
def __init__(self, separator=None, *args, **kwargs):
|
||||
# Use a line break as the default separator
|
||||
if separator is None:
|
||||
separator = mark_safe('<br />')
|
||||
super().__init__(separator=separator, *args, **kwargs)
|
||||
|
||||
def transform(self, obj):
|
||||
return content_type_name(obj)
|
||||
|
||||
def value(self, value):
|
||||
return ','.join([
|
||||
content_type_identifier(ct) for ct in self.filter(value)
|
||||
])
|
||||
|
||||
|
||||
class ColorColumn(tables.Column):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user