2018-03-24 03:08:48 +00:00
|
|
|
# -*- 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):
|
|
|
|
|
2019-11-04 16:55:03 +00:00
|
|
|
dependencies = [("topologie", "0035_auto_20180324_0023")]
|
2018-03-24 03:08:48 +00:00
|
|
|
|
|
|
|
def transfer_bornes(apps, schema_editor):
|
|
|
|
db_alias = schema_editor.connection.alias
|
|
|
|
machinetype = apps.get_model("machines", "MachineType")
|
|
|
|
borne = apps.get_model("topologie", "Borne")
|
2019-11-04 16:55:03 +00:00
|
|
|
interface = apps.get_model("machines", "Interface")
|
|
|
|
bornes_list = machinetype.objects.using(db_alias).filter(
|
|
|
|
ip_type__name__icontains="borne"
|
|
|
|
)
|
2018-03-24 03:08:48 +00:00
|
|
|
if bornes_list:
|
2019-11-04 16:55:03 +00:00
|
|
|
for inter in interface.objects.using(db_alias).filter(
|
|
|
|
machine_type=bornes_list.first()
|
|
|
|
):
|
2018-03-24 03:08:48 +00:00
|
|
|
borne_object = borne()
|
|
|
|
borne_object.interface_ptr_id = inter.pk
|
2019-09-05 15:56:35 +00:00
|
|
|
borne_object.__dict__.update(inter.__dict__)
|
2018-03-24 03:08:48 +00:00
|
|
|
borne_object.save()
|
|
|
|
|
|
|
|
def untransfer_bornes(apps, schema_editor):
|
|
|
|
return
|
|
|
|
|
2019-11-04 16:55:03 +00:00
|
|
|
operations = [migrations.RunPython(transfer_bornes, untransfer_bornes)]
|