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'], '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 = ( LOCATION_SCOPE_TYPES = (
'region', 'sitegroup', 'site', 'location', 'region', 'sitegroup', 'site', 'location',
) )

View File

@ -15,6 +15,7 @@ from utilities.forms.widgets import HTMXSelect
__all__ = ( __all__ = (
'ScopedBulkEditForm', 'ScopedBulkEditForm',
'ScopedForm', 'ScopedForm',
'ScopedImportForm',
) )
@ -95,6 +96,7 @@ class ScopedBulkEditForm(forms.Form):
except ObjectDoesNotExist: except ObjectDoesNotExist:
pass pass
class ScopedImportForm(forms.Form): class ScopedImportForm(forms.Form):
scope_type = CSVContentTypeField( scope_type = CSVContentTypeField(
queryset=ContentType.objects.filter(model__in=LOCATION_SCOPE_TYPES), queryset=ContentType.objects.filter(model__in=LOCATION_SCOPE_TYPES),

View File

@ -35,10 +35,9 @@ class RenderConfigMixin(models.Model):
class CachedScopeMixin(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 Mixin for adding a GenericForeignKey scope to a model that can point to a Region, SiteGroup, Site, or Location.
cached fields for each to allow efficient filtering. Must do any appropriate validation in the clean method Includes cached fields for each to allow efficient filtering. Appropriate validation must be done in the clean()
as this does not have any as validation is generally model specific. method as this does not have any as validation is generally model-specific.
""" """
scope_type = models.ForeignKey( scope_type = models.ForeignKey(
to='contenttypes.ContentType', to='contenttypes.ContentType',

View File

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