mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-25 22:22:26 +00:00
Migrations des bornes dans la classe dédiée + fix divers
This commit is contained in:
parent
4cd7066fa0
commit
5de22014eb
2 changed files with 34 additions and 1 deletions
|
@ -235,7 +235,8 @@ class SortTable:
|
||||||
}
|
}
|
||||||
TOPOLOGIE_INDEX_BORNE = {
|
TOPOLOGIE_INDEX_BORNE = {
|
||||||
'borne_name': ['domain__name'],
|
'borne_name': ['domain__name'],
|
||||||
'borne_ipv4': ['borne__ipv4__ipv4'],
|
'borne_ip': ['ipv4__ipv4'],
|
||||||
|
'borne_mac': ['mac_address'],
|
||||||
'default': ['domain__name']
|
'default': ['domain__name']
|
||||||
}
|
}
|
||||||
TOPOLOGIE_INDEX_STACK = {
|
TOPOLOGIE_INDEX_STACK = {
|
||||||
|
|
32
topologie/migrations/0036_transferborne.py
Normal file
32
topologie/migrations/0036_transferborne.py
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.7 on 2017-12-31 19:53
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('topologie', '0035_auto_20180324_0023'),
|
||||||
|
]
|
||||||
|
|
||||||
|
def transfer_bornes(apps, schema_editor):
|
||||||
|
db_alias = schema_editor.connection.alias
|
||||||
|
machinetype = apps.get_model("machines", "MachineType")
|
||||||
|
borne = apps.get_model("topologie", "Borne")
|
||||||
|
interface = apps.get_model("machines", "Interface")
|
||||||
|
bornes_list = machinetype.objects.using(db_alias).filter(type__icontains='borne')
|
||||||
|
if bornes_list:
|
||||||
|
for inter in interface.objects.using(db_alias).filter(type=bornes_list.first()):
|
||||||
|
borne_object = borne()
|
||||||
|
borne_object.interface_ptr_id = inter.pk
|
||||||
|
borne_object.__dict__.update(inter.__dict__)
|
||||||
|
borne_object.save()
|
||||||
|
|
||||||
|
def untransfer_bornes(apps, schema_editor):
|
||||||
|
return
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(transfer_bornes, untransfer_bornes),
|
||||||
|
]
|
Loading…
Reference in a new issue