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

Closes #8451: Include ChangeLoggingMixin in BaseModel

This commit is contained in:
jeremystretch
2022-01-26 20:41:41 -05:00
parent b67859832a
commit a795b95f7e
3 changed files with 7 additions and 7 deletions

View File

@ -47,6 +47,7 @@ For more background on schema migrations, see the [Django documentation](https:/
Plugin models can leverage certain NetBox features by inheriting from NetBox's `BaseModel` class. This class extends the plugin model to enable numerous feature, including:
* Change logging
* Custom fields
* Custom links
* Custom validation
@ -92,6 +93,8 @@ The example above will enable export templates and tags, but no other NetBox fea
!!! note
Please note that only the classes which appear in this documentation are currently supported. Although other classes may be present within the `features` module, they are not yet supported for use by plugins.
::: netbox.models.features.ChangeLoggingMixin
::: netbox.models.features.CustomLinksMixin
::: netbox.models.features.CustomFieldsMixin

View File

@ -19,6 +19,7 @@ __all__ = (
#
class BaseModel(
ChangeLoggingMixin,
CustomFieldsMixin,
CustomLinksMixin,
CustomValidationMixin,
@ -41,7 +42,7 @@ class ChangeLoggedModel(ChangeLoggingMixin, CustomValidationMixin, models.Model)
abstract = True
class PrimaryModel(BaseModel, ChangeLoggingMixin, models.Model):
class PrimaryModel(BaseModel, models.Model):
"""
Primary models represent real objects within the infrastructure being modeled.
"""
@ -51,7 +52,7 @@ class PrimaryModel(BaseModel, ChangeLoggingMixin, models.Model):
abstract = True
class NestedGroupModel(BaseModel, ChangeLoggingMixin, MPTTModel):
class NestedGroupModel(BaseModel, MPTTModel):
"""
Base model for objects which are used to form a hierarchy (regions, locations, etc.). These models nest
recursively using MPTT. Within each parent, each child instance must have a unique name.
@ -93,7 +94,7 @@ class NestedGroupModel(BaseModel, ChangeLoggingMixin, MPTTModel):
})
class OrganizationalModel(BaseModel, ChangeLoggingMixin, models.Model):
class OrganizationalModel(BaseModel, models.Model):
"""
Organizational models are those which are used solely to categorize and qualify other objects, and do not convey
any real information about the infrastructure being modeled (for example, functional device roles). Organizational

View File

@ -1,5 +1,3 @@
import logging
from django.contrib.contenttypes.fields import GenericRelation
from django.db.models.signals import class_prepared
from django.dispatch import receiver
@ -53,8 +51,6 @@ class ChangeLoggingMixin(models.Model):
"""
Save a snapshot of the object's current state in preparation for modification.
"""
logger = logging.getLogger('netbox')
logger.debug(f"Taking a snapshot of {self}")
self._prechange_snapshot = serialize_object(self)
def to_objectchange(self, action):