mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-14 04:19:36 -06:00
Closes #20617: Introduce BaseModel
This commit is contained in:
parent
adad7c2209
commit
77c08b7bf9
@ -50,21 +50,15 @@ class NetBoxFeatureSet(
|
||||
# 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()
|
||||
A global base model for all NetBox objects.
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
|
||||
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:
|
||||
@ -103,6 +97,25 @@ class NetBoxModel(NetBoxFeatureSet, models.Model):
|
||||
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
|
||||
#
|
||||
@ -177,7 +190,7 @@ class NestedGroupModel(NetBoxFeatureSet, MPTTModel):
|
||||
})
|
||||
|
||||
|
||||
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
|
||||
@ -202,8 +215,6 @@ class OrganizationalModel(NetBoxFeatureSet, models.Model):
|
||||
blank=True
|
||||
)
|
||||
|
||||
objects = RestrictedQuerySet.as_manager()
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
ordering = ('name',)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user