mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Introduce ChangeLoggedModel as a standard model
This commit is contained in:
@ -6,7 +6,7 @@ from dcim.fields import ASNField
|
|||||||
from dcim.models import CableTermination, PathEndpoint
|
from dcim.models import CableTermination, PathEndpoint
|
||||||
from extras.models import ObjectChange, TaggedItem
|
from extras.models import ObjectChange, TaggedItem
|
||||||
from extras.utils import extras_features
|
from extras.utils import extras_features
|
||||||
from netbox.models import BigIDModel, ChangeLoggingMixin, OrganizationalModel, PrimaryModel
|
from netbox.models import BigIDModel, ChangeLoggedModel, OrganizationalModel, PrimaryModel
|
||||||
from utilities.querysets import RestrictedQuerySet
|
from utilities.querysets import RestrictedQuerySet
|
||||||
from .choices import *
|
from .choices import *
|
||||||
from .querysets import CircuitQuerySet
|
from .querysets import CircuitQuerySet
|
||||||
@ -234,7 +234,7 @@ class Circuit(PrimaryModel):
|
|||||||
return self._get_termination('Z')
|
return self._get_termination('Z')
|
||||||
|
|
||||||
|
|
||||||
class CircuitTermination(ChangeLoggingMixin, BigIDModel, PathEndpoint, CableTermination):
|
class CircuitTermination(ChangeLoggedModel, PathEndpoint, CableTermination):
|
||||||
circuit = models.ForeignKey(
|
circuit = models.ForeignKey(
|
||||||
to='circuits.Circuit',
|
to='circuits.Circuit',
|
||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
|
@ -5,7 +5,7 @@ from django.db import models
|
|||||||
from dcim.choices import *
|
from dcim.choices import *
|
||||||
from dcim.constants import *
|
from dcim.constants import *
|
||||||
from extras.utils import extras_features
|
from extras.utils import extras_features
|
||||||
from netbox.models import BigIDModel, ChangeLoggingMixin
|
from netbox.models import ChangeLoggedModel
|
||||||
from utilities.fields import NaturalOrderingField
|
from utilities.fields import NaturalOrderingField
|
||||||
from utilities.querysets import RestrictedQuerySet
|
from utilities.querysets import RestrictedQuerySet
|
||||||
from utilities.ordering import naturalize_interface
|
from utilities.ordering import naturalize_interface
|
||||||
@ -26,7 +26,7 @@ __all__ = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ComponentTemplateModel(ChangeLoggingMixin, BigIDModel):
|
class ComponentTemplateModel(ChangeLoggedModel):
|
||||||
device_type = models.ForeignKey(
|
device_type = models.ForeignKey(
|
||||||
to='dcim.DeviceType',
|
to='dcim.DeviceType',
|
||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
|
@ -16,7 +16,7 @@ from extras.choices import *
|
|||||||
from extras.constants import *
|
from extras.constants import *
|
||||||
from extras.querysets import ConfigContextQuerySet
|
from extras.querysets import ConfigContextQuerySet
|
||||||
from extras.utils import extras_features, FeatureQuery, image_upload
|
from extras.utils import extras_features, FeatureQuery, image_upload
|
||||||
from netbox.models import BigIDModel, ChangeLoggingMixin
|
from netbox.models import BigIDModel, ChangeLoggedModel
|
||||||
from utilities.querysets import RestrictedQuerySet
|
from utilities.querysets import RestrictedQuerySet
|
||||||
from utilities.utils import deepmerge, render_jinja2
|
from utilities.utils import deepmerge, render_jinja2
|
||||||
|
|
||||||
@ -379,7 +379,7 @@ class ImageAttachment(BigIDModel):
|
|||||||
# Config contexts
|
# Config contexts
|
||||||
#
|
#
|
||||||
|
|
||||||
class ConfigContext(ChangeLoggingMixin, BigIDModel):
|
class ConfigContext(ChangeLoggedModel):
|
||||||
"""
|
"""
|
||||||
A ConfigContext represents a set of arbitrary data available to any Device or VirtualMachine matching its assigned
|
A ConfigContext represents a set of arbitrary data available to any Device or VirtualMachine matching its assigned
|
||||||
qualifiers (region, site, etc.). For example, the data stored in a ConfigContext assigned to site A and tenant B
|
qualifiers (region, site, etc.). For example, the data stored in a ConfigContext assigned to site A and tenant B
|
||||||
|
@ -2,7 +2,7 @@ from django.db import models
|
|||||||
from django.utils.text import slugify
|
from django.utils.text import slugify
|
||||||
from taggit.models import TagBase, GenericTaggedItemBase
|
from taggit.models import TagBase, GenericTaggedItemBase
|
||||||
|
|
||||||
from netbox.models import BigIDModel, ChangeLoggingMixin
|
from netbox.models import BigIDModel, ChangeLoggedModel
|
||||||
from utilities.choices import ColorChoices
|
from utilities.choices import ColorChoices
|
||||||
from utilities.fields import ColorField
|
from utilities.fields import ColorField
|
||||||
from utilities.querysets import RestrictedQuerySet
|
from utilities.querysets import RestrictedQuerySet
|
||||||
@ -12,7 +12,7 @@ from utilities.querysets import RestrictedQuerySet
|
|||||||
# Tags
|
# Tags
|
||||||
#
|
#
|
||||||
|
|
||||||
class Tag(ChangeLoggingMixin, BigIDModel, TagBase):
|
class Tag(ChangeLoggedModel, TagBase):
|
||||||
color = ColorField(
|
color = ColorField(
|
||||||
default=ColorChoices.COLOR_GREY
|
default=ColorChoices.COLOR_GREY
|
||||||
)
|
)
|
||||||
|
@ -12,8 +12,7 @@ from utilities.utils import serialize_object
|
|||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
'BigIDModel',
|
'BigIDModel',
|
||||||
'ChangeLoggingMixin',
|
'ChangeLoggedModel',
|
||||||
'CustomFieldsMixin',
|
|
||||||
'NestedGroupModel',
|
'NestedGroupModel',
|
||||||
'OrganizationalModel',
|
'OrganizationalModel',
|
||||||
'PrimaryModel',
|
'PrimaryModel',
|
||||||
@ -137,6 +136,14 @@ class BigIDModel(models.Model):
|
|||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
|
|
||||||
|
class ChangeLoggedModel(ChangeLoggingMixin, BigIDModel):
|
||||||
|
"""
|
||||||
|
Base model for all objects which support change logging.
|
||||||
|
"""
|
||||||
|
class Meta:
|
||||||
|
abstract = True
|
||||||
|
|
||||||
|
|
||||||
class PrimaryModel(ChangeLoggingMixin, CustomFieldsMixin, BigIDModel):
|
class PrimaryModel(ChangeLoggingMixin, CustomFieldsMixin, BigIDModel):
|
||||||
"""
|
"""
|
||||||
Primary models represent real objects within the infrastructure being modeled.
|
Primary models represent real objects within the infrastructure being modeled.
|
||||||
|
@ -9,7 +9,7 @@ from dcim.models import BaseInterface, Device
|
|||||||
from extras.models import ConfigContextModel, TaggedItem
|
from extras.models import ConfigContextModel, TaggedItem
|
||||||
from extras.querysets import ConfigContextModelQuerySet
|
from extras.querysets import ConfigContextModelQuerySet
|
||||||
from extras.utils import extras_features
|
from extras.utils import extras_features
|
||||||
from netbox.models import BigIDModel, ChangeLoggingMixin, OrganizationalModel, PrimaryModel
|
from netbox.models import ChangeLoggedModel, OrganizationalModel, PrimaryModel
|
||||||
from utilities.fields import NaturalOrderingField
|
from utilities.fields import NaturalOrderingField
|
||||||
from utilities.ordering import naturalize_interface
|
from utilities.ordering import naturalize_interface
|
||||||
from utilities.query_functions import CollateAsChar
|
from utilities.query_functions import CollateAsChar
|
||||||
@ -374,7 +374,7 @@ class VirtualMachine(PrimaryModel, ConfigContextModel):
|
|||||||
|
|
||||||
# TODO: Inherit from PrimaryModel
|
# TODO: Inherit from PrimaryModel
|
||||||
@extras_features('export_templates', 'webhooks')
|
@extras_features('export_templates', 'webhooks')
|
||||||
class VMInterface(ChangeLoggingMixin, BigIDModel, BaseInterface):
|
class VMInterface(ChangeLoggedModel, BaseInterface):
|
||||||
virtual_machine = models.ForeignKey(
|
virtual_machine = models.ForeignKey(
|
||||||
to='virtualization.VirtualMachine',
|
to='virtualization.VirtualMachine',
|
||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
|
Reference in New Issue
Block a user