Misc cleanup

This commit is contained in:
Jeremy Stretch 2024-11-01 13:53:50 -04:00
parent 45f29de89f
commit a0c069d880
4 changed files with 12 additions and 7 deletions

View File

@ -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',
)

View File

@ -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),

View File

@ -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',

View File

@ -39,8 +39,12 @@
</td>
</tr>
<tr>
<th scope="row">{% trans "Site" %}</th>
<td>{{ object.site|linkify|placeholder }}</td>
<th scope="row">{% trans "Scope" %}</th>
{% if object.scope %}
<td>{{ object.scope|linkify }} ({% trans object.scope_type.name %})</td>
{% else %}
<td>{{ ''|placeholder }}</td>
{% endif %}
</tr>
</table>
</div>