diff --git a/netbox/dcim/constants.py b/netbox/dcim/constants.py index df7c18b32..4927b0198 100644 --- a/netbox/dcim/constants.py +++ b/netbox/dcim/constants.py @@ -124,7 +124,7 @@ COMPATIBLE_TERMINATION_TYPES = { 'rearport': ['consoleport', 'consoleserverport', 'interface', 'frontport', 'rearport', 'circuittermination'], } -# models values for ContentTypes which may be Cluster scope types +# Models which can serve to scope an object by location LOCATION_SCOPE_TYPES = ( 'region', 'sitegroup', 'site', 'location', ) diff --git a/netbox/dcim/forms/mixins.py b/netbox/dcim/forms/mixins.py index f15bc12d4..98862af10 100644 --- a/netbox/dcim/forms/mixins.py +++ b/netbox/dcim/forms/mixins.py @@ -15,6 +15,7 @@ from utilities.forms.widgets import HTMXSelect __all__ = ( 'ScopedBulkEditForm', 'ScopedForm', + 'ScopedImportForm', ) @@ -95,6 +96,7 @@ class ScopedBulkEditForm(forms.Form): except ObjectDoesNotExist: pass + class ScopedImportForm(forms.Form): scope_type = CSVContentTypeField( queryset=ContentType.objects.filter(model__in=LOCATION_SCOPE_TYPES), diff --git a/netbox/dcim/models/mixins.py b/netbox/dcim/models/mixins.py index 8ea695de2..1df3364c4 100644 --- a/netbox/dcim/models/mixins.py +++ b/netbox/dcim/models/mixins.py @@ -35,10 +35,9 @@ class RenderConfigMixin(models.Model): class CachedScopeMixin(models.Model): """ - Mixin for adding a GFK Scope to a model that can point to a Region, SiteGroup, Site, or Location. Includes - cached fields for each to allow efficient filtering. Must do any appropriate validation in the clean method - as this does not have any as validation is generally model specific. - + Mixin for adding a GenericForeignKey scope to a model that can point to a Region, SiteGroup, Site, or Location. + Includes cached fields for each to allow efficient filtering. Appropriate validation must be done in the clean() + method as this does not have any as validation is generally model-specific. """ scope_type = models.ForeignKey( to='contenttypes.ContentType', diff --git a/netbox/templates/virtualization/cluster.html b/netbox/templates/virtualization/cluster.html index d79d8075c..4155dacb2 100644 --- a/netbox/templates/virtualization/cluster.html +++ b/netbox/templates/virtualization/cluster.html @@ -39,8 +39,12 @@ - {% trans "Site" %} - {{ object.site|linkify|placeholder }} + {% trans "Scope" %} + {% if object.scope %} + {{ object.scope|linkify }} ({% trans object.scope_type.name %}) + {% else %} + {{ ''|placeholder }} + {% endif %}