mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-14 20:39:35 -06:00
Misc cleanup
This commit is contained in:
parent
06447ac637
commit
e6b1f942cd
@ -4,7 +4,7 @@ from django.core.exceptions import ObjectDoesNotExist, ValidationError
|
|||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from dcim.constants import LOCATION_SCOPE_TYPES
|
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 import get_field_value
|
||||||
from utilities.forms.fields import (
|
from utilities.forms.fields import (
|
||||||
ContentTypeChoiceField, CSVContentTypeField, DynamicModelChoiceField,
|
ContentTypeChoiceField, CSVContentTypeField, DynamicModelChoiceField,
|
||||||
@ -138,17 +138,12 @@ class FrontPortFormMixin(forms.Form):
|
|||||||
widget=forms.SelectMultiple(attrs={'size': 8})
|
widget=forms.SelectMultiple(attrs={'size': 8})
|
||||||
)
|
)
|
||||||
|
|
||||||
port_mapping_model = PortTemplateMapping
|
port_mapping_model = PortMapping
|
||||||
|
parent_field = 'device'
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
super().clean()
|
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
|
# 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']:
|
if len(self.cleaned_data['rear_ports']) != self.cleaned_data['positions']:
|
||||||
raise forms.ValidationError({
|
raise forms.ValidationError({
|
||||||
|
|||||||
@ -1124,6 +1124,7 @@ class FrontPortTemplateForm(FrontPortFormMixin, ModularComponentTemplateForm):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Override FrontPortFormMixin attrs
|
||||||
port_mapping_model = PortTemplateMapping
|
port_mapping_model = PortTemplateMapping
|
||||||
parent_field = 'device_type'
|
parent_field = 'device_type'
|
||||||
|
|
||||||
@ -1620,8 +1621,6 @@ class FrontPortForm(FrontPortFormMixin, ModularDeviceComponentForm):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
port_mapping_model = PortMapping
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = FrontPort
|
model = FrontPort
|
||||||
fields = [
|
fields = [
|
||||||
|
|||||||
@ -150,6 +150,7 @@ def nullify_connected_endpoints(instance, **kwargs):
|
|||||||
cablepath.retrace()
|
cablepath.retrace()
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: Adapt signal handler to act on changes to port mappings
|
||||||
@receiver(post_save, sender=FrontPort)
|
@receiver(post_save, sender=FrontPort)
|
||||||
def extend_rearport_cable_paths(instance, created, raw, **kwargs):
|
def extend_rearport_cable_paths(instance, created, raw, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -840,7 +840,7 @@ class DeviceRearPortTable(RearPortTable):
|
|||||||
'description', 'mark_connected', 'cable', 'cable_color', 'link_peer', 'tags', 'actions',
|
'description', 'mark_connected', 'cable', 'cable_color', 'link_peer', 'tags', 'actions',
|
||||||
)
|
)
|
||||||
default_columns = (
|
default_columns = (
|
||||||
'pk', 'name', 'label', 'type', 'positions', 'mappings', 'description', 'cable', 'link_peer',
|
'pk', 'name', 'label', 'type', 'color', 'positions', 'mappings', 'description', 'cable', 'link_peer',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user