Misc cleanup
Some checks are pending
CI / build (20.x, 3.12) (push) Waiting to run
CI / build (20.x, 3.13) (push) Waiting to run

This commit is contained in:
Jeremy Stretch 2025-11-26 12:20:40 -05:00
parent 06447ac637
commit e6b1f942cd
4 changed files with 6 additions and 11 deletions

View File

@ -4,7 +4,7 @@ from django.core.exceptions import ObjectDoesNotExist, ValidationError
from django.utils.translation import gettext_lazy as _
from dcim.constants import LOCATION_SCOPE_TYPES
from dcim.models import PortTemplateMapping, Site
from dcim.models import PortMapping, Site
from utilities.forms import get_field_value
from utilities.forms.fields import (
ContentTypeChoiceField, CSVContentTypeField, DynamicModelChoiceField,
@ -138,17 +138,12 @@ class FrontPortFormMixin(forms.Form):
widget=forms.SelectMultiple(attrs={'size': 8})
)
port_mapping_model = PortTemplateMapping
port_mapping_model = PortMapping
parent_field = 'device'
def clean(self):
super().clean()
# FrontPort with no positions cannot be mapped to more than one RearPort
if not self.cleaned_data['positions'] and len(self.cleaned_data['rear_ports']) > 1:
raise forms.ValidationError({
'positions': _("A front port with no positions cannot be mapped to multiple rear ports.")
})
# Count of selected rear port & position pairs much match the assigned number of positions
if len(self.cleaned_data['rear_ports']) != self.cleaned_data['positions']:
raise forms.ValidationError({

View File

@ -1124,6 +1124,7 @@ class FrontPortTemplateForm(FrontPortFormMixin, ModularComponentTemplateForm):
),
)
# Override FrontPortFormMixin attrs
port_mapping_model = PortTemplateMapping
parent_field = 'device_type'
@ -1620,8 +1621,6 @@ class FrontPortForm(FrontPortFormMixin, ModularDeviceComponentForm):
),
)
port_mapping_model = PortMapping
class Meta:
model = FrontPort
fields = [

View File

@ -150,6 +150,7 @@ def nullify_connected_endpoints(instance, **kwargs):
cablepath.retrace()
# TODO: Adapt signal handler to act on changes to port mappings
@receiver(post_save, sender=FrontPort)
def extend_rearport_cable_paths(instance, created, raw, **kwargs):
"""

View File

@ -840,7 +840,7 @@ class DeviceRearPortTable(RearPortTable):
'description', 'mark_connected', 'cable', 'cable_color', 'link_peer', 'tags', 'actions',
)
default_columns = (
'pk', 'name', 'label', 'type', 'positions', 'mappings', 'description', 'cable', 'link_peer',
'pk', 'name', 'label', 'type', 'color', 'positions', 'mappings', 'description', 'cable', 'link_peer',
)