From 5de22014eb193c5f5458cc146316ea5ada4ec8fa Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Sat, 24 Mar 2018 04:08:48 +0100 Subject: [PATCH] =?UTF-8?q?Migrations=20des=20bornes=20dans=20la=20classe?= =?UTF-8?q?=20d=C3=A9di=C3=A9e=20+=20fix=20divers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- re2o/utils.py | 3 +- topologie/migrations/0036_transferborne.py | 32 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 topologie/migrations/0036_transferborne.py diff --git a/re2o/utils.py b/re2o/utils.py index a3de2a89..d577ba70 100644 --- a/re2o/utils.py +++ b/re2o/utils.py @@ -235,7 +235,8 @@ class SortTable: } TOPOLOGIE_INDEX_BORNE = { 'borne_name': ['domain__name'], - 'borne_ipv4': ['borne__ipv4__ipv4'], + 'borne_ip': ['ipv4__ipv4'], + 'borne_mac': ['mac_address'], 'default': ['domain__name'] } TOPOLOGIE_INDEX_STACK = { diff --git a/topologie/migrations/0036_transferborne.py b/topologie/migrations/0036_transferborne.py new file mode 100644 index 00000000..2b59e3b9 --- /dev/null +++ b/topologie/migrations/0036_transferborne.py @@ -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), + ]