|
@@ -5,10 +5,17 @@ import mptt.managers
|
|
|
|
|
|
|
|
def rebuild_mptt(apps, schema_editor):
|
|
def rebuild_mptt(apps, schema_editor):
|
|
|
"""
|
|
"""
|
|
|
- Rebuild the MPPT tree for ModuleBay to apply new ordering by 'name'
|
|
|
|
|
|
|
+ Rebuild the MPTT tree for ModuleBay to apply new ordering by 'name'
|
|
|
instead of 'module'.
|
|
instead of 'module'.
|
|
|
"""
|
|
"""
|
|
|
ModuleBay = apps.get_model('dcim', 'ModuleBay')
|
|
ModuleBay = apps.get_model('dcim', 'ModuleBay')
|
|
|
|
|
+
|
|
|
|
|
+ # Set MPTTMeta with the correct order_insertion_by
|
|
|
|
|
+ class MPTTMeta:
|
|
|
|
|
+ order_insertion_by = ('module', 'name',)
|
|
|
|
|
+
|
|
|
|
|
+ ModuleBay.MPTTMeta = MPTTMeta
|
|
|
|
|
+
|
|
|
manager = mptt.managers.TreeManager()
|
|
manager = mptt.managers.TreeManager()
|
|
|
manager.model = ModuleBay
|
|
manager.model = ModuleBay
|
|
|
mptt.register(ModuleBay)
|
|
mptt.register(ModuleBay)
|