From 7c913fecb7cec53ef84fc19796b759dca4c18ef4 Mon Sep 17 00:00:00 2001 From: Daniel Sheppard Date: Sun, 2 Jun 2024 22:13:23 -0500 Subject: [PATCH] Change to translation strings --- netbox/dcim/models/cables.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/netbox/dcim/models/cables.py b/netbox/dcim/models/cables.py index e9b58e413..86a610e24 100644 --- a/netbox/dcim/models/cables.py +++ b/netbox/dcim/models/cables.py @@ -535,8 +535,9 @@ class CablePath(models.Model): # Ensure all originating terminations are attached to the same link if len(terminations) > 1: - assert all(t.link == terminations[0].link for t in terminations[1:]), \ - "All originating terminations must start must be attached to the same link" + assert all(t.link == terminations[0].link for t in terminations[1:]), ( + _("All originating terminations must start must be attached to the same link") + ) path = [] position_stack = [] @@ -547,13 +548,15 @@ class CablePath(models.Model): while terminations: # Terminations must all be of the same type - assert all(isinstance(t, type(terminations[0])) for t in terminations[1:]), \ - "All mid-span terminations must have the same termination type" + assert all(isinstance(t, type(terminations[0])) for t in terminations[1:]), ( + _("All mid-span terminations must have the same termination type") + ) # All mid-span terminations must all be attached to the same device if not isinstance(terminations[0], PathEndpoint): - assert all(t.parent_object == terminations[0].parent_object for t in terminations[1:]), \ - "All mid-span terminations must have the same parent object" + assert all(t.parent_object == terminations[0].parent_object for t in terminations[1:]), ( + _("All mid-span terminations must have the same parent object") + ) # Check for a split path (e.g. rear port fanning out to multiple front ports with # different cables attached) @@ -576,8 +579,8 @@ class CablePath(models.Model): return None # Otherwise, halt the trace if no link exists break - assert all(type(link) in (Cable, WirelessLink) for link in links), "All links must be cable or wireless" - assert all(isinstance(link, type(links[0])) for link in links), "All links must match first link type" + assert all(type(link) in (Cable, WirelessLink) for link in links), _("All links must be cable or wireless") + assert all(isinstance(link, type(links[0])) for link in links), _("All links must match first link type") # Step 3: Record asymmetric paths as split not_connected_terminations = [termination.link for termination in terminations if termination.link is None] @@ -654,14 +657,16 @@ class CablePath(models.Model): positions = position_stack.pop() # Ensure we have a number of positions equal to the amount of remote terminations - assert len(remote_terminations) == len(positions) + assert len(remote_terminations) == len(positions), ( + _("All positions counts within the path on opposite ends of links must match") + ) # Get our front ports q_filter = Q() for rt in remote_terminations: position = positions.pop() q_filter |= Q(rear_port_id=rt.pk, rear_port_position=position) - assert q_filter is not Q(), "Remote termination query filter is empty, please open a bug report" + assert q_filter is not Q(), _("Remote termination query filter is empty, please open a bug report") front_ports = FrontPort.objects.filter(q_filter) # Obtain the individual front ports based on the termination and position elif position_stack: