Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 26 additions & 15 deletions netbox/netbox/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,15 @@ def get_absolute_url(self):
# Base model classes
#

class ChangeLoggedModel(ChangeLoggingMixin, CustomValidationMixin, EventRulesMixin, models.Model):
class BaseModel(models.Model):
"""
Base model for ancillary models; provides limited functionality for models which don't
support NetBox's full feature set.
"""
objects = RestrictedQuerySet.as_manager()

class Meta:
abstract = True

A global base model for all NetBox objects.

class NetBoxModel(NetBoxFeatureSet, models.Model):
"""
Base model for most object types. Suitable for use by plugins.
This class provides some important overrides to Django's default functionality, such as
- Overriding the default manager to use RestrictedQuerySet
- Extending `clean()` to validate GenericForeignKey fields
"""

objects = RestrictedQuerySet.as_manager()

class Meta:
Expand Down Expand Up @@ -103,6 +97,25 @@ def clean(self):
setattr(self, field.name, obj)


class ChangeLoggedModel(ChangeLoggingMixin, CustomValidationMixin, EventRulesMixin, BaseModel):
"""
Base model for ancillary models; provides limited functionality for models which don't
support NetBox's full feature set.
"""

class Meta:
abstract = True


class NetBoxModel(NetBoxFeatureSet, BaseModel):
"""
Base model for most object types. Suitable for use by plugins.
"""

class Meta:
abstract = True


#
# NetBox internal base models
#
Expand Down Expand Up @@ -177,7 +190,7 @@ def clean(self):
})


class OrganizationalModel(NetBoxFeatureSet, models.Model):
class OrganizationalModel(NetBoxModel):
"""
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
Expand All @@ -202,8 +215,6 @@ class OrganizationalModel(NetBoxFeatureSet, models.Model):
blank=True
)

objects = RestrictedQuerySet.as_manager()

class Meta:
abstract = True
ordering = ('name',)
Expand Down