1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #2624: Delete associated content type and permissions when removing InterfaceConnection model

This commit is contained in:
Jeremy Stretch
2018-11-28 13:45:02 -05:00
parent 4da755e75f
commit 5acd429c55
2 changed files with 14 additions and 28 deletions

View File

@@ -131,6 +131,15 @@ def interface_connections_to_cables(apps, schema_editor):
print("{} cables created".format(cable_count))
def delete_interfaceconnection_content_type(apps, schema_editor):
"""
Delete the ContentType for the InterfaceConnection model. (This is not done automatically upon model deletion.)
"""
ContentType = apps.get_model('contenttypes', 'ContentType')
InterfaceConnection = apps.get_model('dcim', 'InterfaceConnection')
ContentType.objects.get_for_model(InterfaceConnection).delete()
class Migration(migrations.Migration):
atomic = False
@@ -291,7 +300,8 @@ class Migration(migrations.Migration):
migrations.RunPython(power_connections_to_cables),
migrations.RunPython(interface_connections_to_cables),
# Delete the InterfaceConnection model
# Delete the InterfaceConnection model and its ContentType
migrations.RunPython(delete_interfaceconnection_content_type),
migrations.RemoveField(
model_name='interfaceconnection',
name='interface_a',