mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-16 05: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
|
# 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
|
A global base model for all NetBox objects.
|
||||||
support NetBox's full feature set.
|
|
||||||
"""
|
|
||||||
objects = RestrictedQuerySet.as_manager()
|
|
||||||
|
|
||||||
class Meta:
|
This class provides some important overrides to Django's default functionality, such as
|
||||||
abstract = True
|
- Overriding the default manager to use RestrictedQuerySet
|
||||||
|
- Extending `clean()` to validate GenericForeignKey fields
|
||||||
|
|
||||||
class NetBoxModel(NetBoxFeatureSet, models.Model):
|
|
||||||
"""
|
|
||||||
Base model for most object types. Suitable for use by plugins.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
objects = RestrictedQuerySet.as_manager()
|
objects = RestrictedQuerySet.as_manager()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@ -103,6 +97,25 @@ class NetBoxModel(NetBoxFeatureSet, models.Model):
|
|||||||
setattr(self, field.name, obj)
|
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
|
# 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
|
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
|
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
|
blank=True
|
||||||
)
|
)
|
||||||
|
|
||||||
objects = RestrictedQuerySet.as_manager()
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
ordering = ('name',)
|
ordering = ('name',)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user