Remove ConnectableModel

This commit is contained in:
Jeremy Stretch 2018-10-19 11:56:12 -04:00
parent d908dffab7
commit 59af8cc924
2 changed files with 5 additions and 96 deletions

View File

@ -103,71 +103,6 @@ class Migration(migrations.Migration):
('endpoint_b_type', models.ForeignKey(limit_choices_to={'model__in': ('consoleport', 'consoleserverport', 'interface', 'poweroutlet', 'powerport', 'frontpanelport', 'rearpanelport')}, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='contenttypes.ContentType')),
],
),
migrations.AddField(
model_name='consoleport',
name='connected_endpoint_id',
field=models.PositiveIntegerField(blank=True, null=True),
),
migrations.AddField(
model_name='consoleport',
name='connected_endpoint_type',
field=models.ForeignKey(blank=True, limit_choices_to={'model__in': ('consoleport', 'consoleserverport', 'interface', 'poweroutlet', 'powerport')}, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='contenttypes.ContentType'),
),
migrations.AddField(
model_name='consoleserverport',
name='connected_endpoint_id',
field=models.PositiveIntegerField(blank=True, null=True),
),
migrations.AddField(
model_name='consoleserverport',
name='connected_endpoint_type',
field=models.ForeignKey(blank=True, limit_choices_to={'model__in': ('consoleport', 'consoleserverport', 'interface', 'poweroutlet', 'powerport')}, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='contenttypes.ContentType'),
),
migrations.AddField(
model_name='consoleserverport',
name='connection_status',
field=models.NullBooleanField(default=True),
),
migrations.AddField(
model_name='interface',
name='connected_endpoint_id',
field=models.PositiveIntegerField(blank=True, null=True),
),
migrations.AddField(
model_name='interface',
name='connected_endpoint_type',
field=models.ForeignKey(blank=True, limit_choices_to={'model__in': ('consoleport', 'consoleserverport', 'interface', 'poweroutlet', 'powerport')}, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='contenttypes.ContentType'),
),
migrations.AddField(
model_name='interface',
name='connection_status',
field=models.NullBooleanField(default=True),
),
migrations.AddField(
model_name='poweroutlet',
name='connected_endpoint_id',
field=models.PositiveIntegerField(blank=True, null=True),
),
migrations.AddField(
model_name='poweroutlet',
name='connected_endpoint_type',
field=models.ForeignKey(blank=True, limit_choices_to={'model__in': ('consoleport', 'consoleserverport', 'interface', 'poweroutlet', 'powerport')}, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='contenttypes.ContentType'),
),
migrations.AddField(
model_name='poweroutlet',
name='connection_status',
field=models.NullBooleanField(default=True),
),
migrations.AddField(
model_name='powerport',
name='connected_endpoint_id',
field=models.PositiveIntegerField(blank=True, null=True),
),
migrations.AddField(
model_name='powerport',
name='connected_endpoint_type',
field=models.ForeignKey(blank=True, limit_choices_to={'model__in': ('consoleport', 'consoleserverport', 'interface', 'poweroutlet', 'powerport')}, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='contenttypes.ContentType'),
),
migrations.AlterUniqueTogether(
name='cable',
unique_together={('endpoint_b_type', 'endpoint_b_id'), ('endpoint_a_type', 'endpoint_a_id')},

View File

@ -66,32 +66,6 @@ class ComponentModel(models.Model):
).save()
class ConnectableModel(models.Model):
connected_endpoint_type = models.ForeignKey(
to=ContentType,
limit_choices_to={'model__in': CABLE_ENDPOINT_TYPES},
on_delete=models.PROTECT,
related_name='+',
blank=True,
null=True
)
connected_endpoint_id = models.PositiveIntegerField(
blank=True,
null=True
)
connected_endpoint = GenericForeignKey(
ct_field='connected_endpoint_type',
fk_field='connected_endpoint_id'
)
connection_status = models.NullBooleanField(
choices=CONNECTION_STATUS_CHOICES,
default=CONNECTION_STATUS_CONNECTED
)
class Meta:
abstract = True
#
# Regions
#
@ -1643,7 +1617,7 @@ class Device(ChangeLoggedModel, ConfigContextModel, CustomFieldModel):
# Console ports
#
class ConsolePort(ConnectableModel, ComponentModel):
class ConsolePort(ComponentModel):
"""
A physical console port within a Device. ConsolePorts connect to ConsoleServerPorts.
"""
@ -1706,7 +1680,7 @@ class ConsoleServerPortManager(models.Manager):
}).order_by('device', 'name_padded')
class ConsoleServerPort(ConnectableModel, ComponentModel):
class ConsoleServerPort(ComponentModel):
"""
A physical port within a Device (typically a designated console server) which provides access to ConsolePorts.
"""
@ -1747,7 +1721,7 @@ class ConsoleServerPort(ConnectableModel, ComponentModel):
# Power ports
#
class PowerPort(ConnectableModel, ComponentModel):
class PowerPort(ComponentModel):
"""
A physical power supply (intake) port within a Device. PowerPorts connect to PowerOutlets.
"""
@ -1809,7 +1783,7 @@ class PowerOutletManager(models.Manager):
}).order_by('device', 'name_padded')
class PowerOutlet(ConnectableModel, ComponentModel):
class PowerOutlet(ComponentModel):
"""
A physical power outlet (output) within a Device which provides power to a PowerPort.
"""
@ -1850,7 +1824,7 @@ class PowerOutlet(ConnectableModel, ComponentModel):
# Interfaces
#
class Interface(ConnectableModel, ComponentModel):
class Interface(ComponentModel):
"""
A network interface within a Device or VirtualMachine. A physical Interface can connect to exactly one other
Interface via the creation of an InterfaceConnection.