Skip to content

Commit

Permalink
Closes #11737: ChangeLoggedModel should inherit WebhooksMixin
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystretch committed Feb 20, 2023
1 parent 8d68b6a commit 96a79c2
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 24 deletions.
3 changes: 0 additions & 3 deletions netbox/circuits/models/circuits.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from django.apps import apps
from django.contrib.contenttypes.fields import GenericRelation
from django.core.exceptions import ValidationError
from django.db import models
Expand All @@ -10,7 +9,6 @@
from netbox.models import (
ChangeLoggedModel, CustomFieldsMixin, CustomLinksMixin, OrganizationalModel, PrimaryModel, TagsMixin,
)
from netbox.models.features import WebhooksMixin

__all__ = (
'Circuit',
Expand Down Expand Up @@ -132,7 +130,6 @@ class CircuitTermination(
CustomFieldsMixin,
CustomLinksMixin,
TagsMixin,
WebhooksMixin,
ChangeLoggedModel,
CabledObjectModel
):
Expand Down
3 changes: 1 addition & 2 deletions netbox/dcim/models/device_component_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from dcim.choices import *
from dcim.constants import *
from netbox.models import ChangeLoggedModel
from netbox.models.features import WebhooksMixin
from utilities.fields import ColorField, NaturalOrderingField
from utilities.mptt import TreeManager
from utilities.ordering import naturalize_interface
Expand All @@ -33,7 +32,7 @@
)


class ComponentTemplateModel(WebhooksMixin, ChangeLoggedModel):
class ComponentTemplateModel(ChangeLoggedModel):
device_type = models.ForeignKey(
to='dcim.DeviceType',
on_delete=models.CASCADE,
Expand Down
5 changes: 2 additions & 3 deletions netbox/extras/models/configcontexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@

from extras.querysets import ConfigContextQuerySet
from netbox.models import ChangeLoggedModel
from netbox.models.features import SyncedDataMixin, WebhooksMixin
from netbox.models.features import SyncedDataMixin
from utilities.utils import deepmerge


__all__ = (
'ConfigContext',
'ConfigContextModel',
Expand All @@ -20,7 +19,7 @@
# Config contexts
#

class ConfigContext(SyncedDataMixin, WebhooksMixin, ChangeLoggedModel):
class ConfigContext(SyncedDataMixin, ChangeLoggedModel):
"""
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
Expand Down
4 changes: 2 additions & 2 deletions netbox/extras/models/customfields.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from extras.choices import *
from extras.utils import FeatureQuery
from netbox.models import ChangeLoggedModel
from netbox.models.features import CloningMixin, ExportTemplatesMixin, WebhooksMixin
from netbox.models.features import CloningMixin, ExportTemplatesMixin
from netbox.search import FieldTypes
from utilities import filters
from utilities.forms.fields import (
Expand Down Expand Up @@ -56,7 +56,7 @@ def get_for_model(self, model):
return self.get_queryset().filter(content_types=content_type)


class CustomField(CloningMixin, ExportTemplatesMixin, WebhooksMixin, ChangeLoggedModel):
class CustomField(CloningMixin, ExportTemplatesMixin, ChangeLoggedModel):
content_types = models.ManyToManyField(
to=ContentType,
related_name='custom_fields',
Expand Down
14 changes: 7 additions & 7 deletions netbox/extras/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from netbox.models import ChangeLoggedModel
from netbox.models.features import (
CloningMixin, CustomFieldsMixin, CustomLinksMixin, ExportTemplatesMixin, JobResultsMixin, SyncedDataMixin,
TagsMixin, WebhooksMixin,
TagsMixin,
)
from utilities.querysets import RestrictedQuerySet
from utilities.utils import render_jinja2
Expand All @@ -46,7 +46,7 @@
)


class Webhook(ExportTemplatesMixin, WebhooksMixin, ChangeLoggedModel):
class Webhook(ExportTemplatesMixin, ChangeLoggedModel):
"""
A Webhook defines a request that will be sent to a remote application when an object is created, updated, and/or
delete in NetBox. The request will contain a representation of the object, which the remote application can act on.
Expand Down Expand Up @@ -203,7 +203,7 @@ def render_payload_url(self, context):
return render_jinja2(self.payload_url, context)


class CustomLink(CloningMixin, ExportTemplatesMixin, WebhooksMixin, ChangeLoggedModel):
class CustomLink(CloningMixin, ExportTemplatesMixin, ChangeLoggedModel):
"""
A custom link to an external representation of a NetBox object. The link text and URL fields accept Jinja2 template
code to be rendered with an object as context.
Expand Down Expand Up @@ -282,7 +282,7 @@ def render(self, context):
}


class ExportTemplate(SyncedDataMixin, ExportTemplatesMixin, WebhooksMixin, ChangeLoggedModel):
class ExportTemplate(SyncedDataMixin, ExportTemplatesMixin, ChangeLoggedModel):
content_types = models.ManyToManyField(
to=ContentType,
related_name='export_templates',
Expand Down Expand Up @@ -376,7 +376,7 @@ def render_to_response(self, queryset):
return response


class SavedFilter(CloningMixin, ExportTemplatesMixin, WebhooksMixin, ChangeLoggedModel):
class SavedFilter(CloningMixin, ExportTemplatesMixin, ChangeLoggedModel):
"""
A set of predefined keyword parameters that can be reused to filter for specific objects.
"""
Expand Down Expand Up @@ -447,7 +447,7 @@ def url_params(self):
return qd.urlencode()


class ImageAttachment(WebhooksMixin, ChangeLoggedModel):
class ImageAttachment(ChangeLoggedModel):
"""
An uploaded image which is associated with an object.
"""
Expand Down Expand Up @@ -523,7 +523,7 @@ def to_objectchange(self, action):
return objectchange


class JournalEntry(CustomFieldsMixin, CustomLinksMixin, TagsMixin, WebhooksMixin, ExportTemplatesMixin, ChangeLoggedModel):
class JournalEntry(CustomFieldsMixin, CustomLinksMixin, TagsMixin, ExportTemplatesMixin, ChangeLoggedModel):
"""
A historical remark concerning an object; collectively, these form an object's journal. The journal is used to
preserve historical context around an object, and complements NetBox's built-in change logging. For example, you
Expand Down
4 changes: 2 additions & 2 deletions netbox/extras/models/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from taggit.models import TagBase, GenericTaggedItemBase

from netbox.models import ChangeLoggedModel
from netbox.models.features import ExportTemplatesMixin, WebhooksMixin
from netbox.models.features import ExportTemplatesMixin
from utilities.choices import ColorChoices
from utilities.fields import ColorField

Expand All @@ -14,7 +14,7 @@
# Tags
#

class Tag(ExportTemplatesMixin, WebhooksMixin, ChangeLoggedModel, TagBase):
class Tag(ExportTemplatesMixin, ChangeLoggedModel, TagBase):
id = models.BigAutoField(
primary_key=True
)
Expand Down
3 changes: 1 addition & 2 deletions netbox/ipam/models/fhrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from django.urls import reverse

from netbox.models import ChangeLoggedModel, PrimaryModel
from netbox.models.features import WebhooksMixin
from ipam.choices import *
from ipam.constants import *

Expand Down Expand Up @@ -73,7 +72,7 @@ def get_absolute_url(self):
return reverse('ipam:fhrpgroup', args=[self.pk])


class FHRPGroupAssignment(WebhooksMixin, ChangeLoggedModel):
class FHRPGroupAssignment(ChangeLoggedModel):
interface_type = models.ForeignKey(
to=ContentType,
on_delete=models.CASCADE
Expand Down
2 changes: 1 addition & 1 deletion netbox/netbox/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def docs_url(self):
# Base model classes
#

class ChangeLoggedModel(ChangeLoggingMixin, CustomValidationMixin, models.Model):
class ChangeLoggedModel(ChangeLoggingMixin, CustomValidationMixin, WebhooksMixin, models.Model):
"""
Base model for ancillary models; provides limited functionality for models which don't
support NetBox's full feature set.
Expand Down
3 changes: 1 addition & 2 deletions netbox/tenancy/models/contacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from django.urls import reverse

from netbox.models import ChangeLoggedModel, NestedGroupModel, OrganizationalModel, PrimaryModel
from netbox.models.features import WebhooksMixin
from tenancy.choices import *

__all__ = (
Expand Down Expand Up @@ -93,7 +92,7 @@ def get_absolute_url(self):
return reverse('tenancy:contact', args=[self.pk])


class ContactAssignment(WebhooksMixin, ChangeLoggedModel):
class ContactAssignment(ChangeLoggedModel):
content_type = models.ForeignKey(
to=ContentType,
on_delete=models.CASCADE
Expand Down

0 comments on commit 96a79c2

Please sign in to comment.