mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-21 03:27:21 -06:00
CablePath.origin should be unique
This commit is contained in:
parent
e0abd7ef3e
commit
66355da04c
@ -1,3 +1,5 @@
|
||||
# Generated by Django 3.1 on 2020-10-02 15:49
|
||||
|
||||
import dcim.fields
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
@ -18,9 +20,12 @@ class Migration(migrations.Migration):
|
||||
('origin_id', models.PositiveIntegerField()),
|
||||
('destination_id', models.PositiveIntegerField(blank=True, null=True)),
|
||||
('path', dcim.fields.PathField(base_field=models.CharField(max_length=40), size=None)),
|
||||
('is_connected', models.BooleanField(default=False)),
|
||||
('destination_type', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='+', to='contenttypes.contenttype')),
|
||||
('origin_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='contenttypes.contenttype')),
|
||||
('is_connected', models.BooleanField(default=False)),
|
||||
],
|
||||
options={
|
||||
'unique_together': {('origin_type', 'origin_id')},
|
||||
},
|
||||
),
|
||||
]
|
||||
|
@ -1197,6 +1197,9 @@ class CablePath(models.Model):
|
||||
|
||||
objects = CablePathManager()
|
||||
|
||||
class Meta:
|
||||
unique_together = ('origin_type', 'origin_id')
|
||||
|
||||
def __str__(self):
|
||||
path = ', '.join([str(path_node_to_object(node)) for node in self.path])
|
||||
return f"Path #{self.pk}: {self.origin} to {self.destination} via ({path})"
|
||||
|
Loading…
Reference in New Issue
Block a user