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

initial pass on migrating to custom tag model with color and comments fields

This commit is contained in:
John Anderson
2019-02-20 03:52:47 -05:00
parent e521508de9
commit fc2bb724fa
32 changed files with 524 additions and 63 deletions

View File

@@ -12,8 +12,10 @@ from django.db.models import F, Q
from django.http import HttpResponse
from django.template import Template, Context
from django.urls import reverse
from taggit.models import TagBase, GenericTaggedItemBase
from dcim.constants import CONNECTION_STATUS_CONNECTED
from utilities.fields import ColorField
from utilities.utils import deepmerge, foreground_color
from .constants import *
from .querysets import ConfigContextQuerySet
@@ -860,3 +862,23 @@ class ObjectChange(models.Model):
self.object_repr,
self.object_data,
)
#
# Tags
#
class Tag(TagBase):
color = ColorField()
comments = models.TextField(
blank=True
)
class TaggedItem(GenericTaggedItemBase):
tag = models.ForeignKey(
to=Tag,
related_name="%(app_label)s_%(class)s_items",
on_delete=models.CASCADE
)