Initial work on FR #20788 (cable profiles)

This commit is contained in:
Jeremy Stretch
2025-11-13 17:06:55 -05:00
parent a4365be0a3
commit 4c5e380106
21 changed files with 484 additions and 50 deletions

View File

@@ -175,6 +175,15 @@ class CabledObjectModel(models.Model):
blank=True,
null=True
)
cable_position = models.PositiveIntegerField(
verbose_name=_('cable position'),
blank=True,
null=True,
validators=(
MinValueValidator(CABLETERMINATION_POSITION_MIN),
MaxValueValidator(CABLETERMINATION_POSITION_MAX)
),
)
mark_connected = models.BooleanField(
verbose_name=_('mark connected'),
default=False,
@@ -194,14 +203,23 @@ class CabledObjectModel(models.Model):
def clean(self):
super().clean()
if self.cable and not self.cable_end:
raise ValidationError({
"cable_end": _("Must specify cable end (A or B) when attaching a cable.")
})
if self.cable:
if not self.cable_end:
raise ValidationError({
"cable_end": _("Must specify cable end (A or B) when attaching a cable.")
})
if not self.cable_position:
raise ValidationError({
"cable_position": _("Must specify cable termination position when attaching a cable.")
})
if self.cable_end and not self.cable:
raise ValidationError({
"cable_end": _("Cable end must not be set without a cable.")
})
if self.cable_position and not self.cable:
raise ValidationError({
"cable_position": _("Cable termination position must not be set without a cable.")
})
if self.mark_connected and self.cable:
raise ValidationError({
"mark_connected": _("Cannot mark as connected with a cable attached.")