From a77ecd25f09a0a3d17c3a59b2e8111e2f7f8f7a1 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Sat, 19 Nov 2016 00:34:42 +0100 Subject: [PATCH] =?UTF-8?q?Bricoles,=20lacp=20pour=20les=20serveurs,=20ret?= =?UTF-8?q?ire=20l'unicit=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migrations/0020_auto_20161119_0033.py | 20 +++++++++++++ topologie/models.py | 4 +-- topologie/views.py | 6 ++-- users/migrations/0039_auto_20161119_0033.py | 29 +++++++++++++++++++ 4 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 topologie/migrations/0020_auto_20161119_0033.py create mode 100644 users/migrations/0039_auto_20161119_0033.py diff --git a/topologie/migrations/0020_auto_20161119_0033.py b/topologie/migrations/0020_auto_20161119_0033.py new file mode 100644 index 00000000..d4db68d9 --- /dev/null +++ b/topologie/migrations/0020_auto_20161119_0033.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('topologie', '0019_auto_20161026_1348'), + ] + + operations = [ + migrations.AlterField( + model_name='port', + name='machine_interface', + field=models.ForeignKey(blank=True, to='machines.Interface', null=True, on_delete=django.db.models.deletion.SET_NULL), + ), + ] diff --git a/topologie/models.py b/topologie/models.py index 0e14fdf7..44214310 100644 --- a/topologie/models.py +++ b/topologie/models.py @@ -24,7 +24,7 @@ class Switch(models.Model): details = models.CharField(max_length=255, blank=True) def __str__(self): - return str(self.location) + return str(self.location) + ' ' + str(self.switch_interface) class Port(models.Model): PRETTY_NAME = "Port de switch" @@ -32,7 +32,7 @@ class Port(models.Model): switch = models.ForeignKey('Switch', related_name="ports") port = models.IntegerField() room = models.ForeignKey('Room', on_delete=models.PROTECT, blank=True, null=True) - machine_interface = models.OneToOneField('machines.Interface', on_delete=models.SET_NULL, blank=True, null=True) + machine_interface = models.ForeignKey('machines.Interface', on_delete=models.SET_NULL, blank=True, null=True) related = models.OneToOneField('self', null=True, blank=True, related_name='related_port') details = models.CharField(max_length=255, blank=True) diff --git a/topologie/views.py b/topologie/views.py index 6f2ec787..6d14cb01 100644 --- a/topologie/views.py +++ b/topologie/views.py @@ -103,18 +103,18 @@ def new_port(request, switch_id): @permission_required('infra') def edit_port(request, port_id): try: - port = Port.objects.get(pk=port_id) + port_object = Port.objects.get(pk=port_id) except Port.DoesNotExist: messages.error(request, u"Port inexistant") return redirect("/topologie/") - port = EditPortForm(request.POST or None, instance=port) + port = EditPortForm(request.POST or None, instance=port_object) if port.is_valid(): with transaction.atomic(), reversion.create_revision(): port.save() reversion.set_user(request.user) reversion.set_comment("Champs modifié(s) : %s" % ', '.join(field for field in port.changed_data)) messages.success(request, "Le port a bien été modifié") - return redirect("/topologie/") + return redirect("/topologie/switch/" + str(port_object.switch.id)) return form({'topoform':port}, 'topologie/topo.html', request) @login_required diff --git a/users/migrations/0039_auto_20161119_0033.py b/users/migrations/0039_auto_20161119_0033.py new file mode 100644 index 00000000..7a2fcba7 --- /dev/null +++ b/users/migrations/0039_auto_20161119_0033.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0038_auto_20161031_0258'), + ] + + operations = [ + migrations.AlterField( + model_name='ldapserviceuser', + name='dn', + field=models.CharField(serialize=False, max_length=200, primary_key=True), + ), + migrations.AlterField( + model_name='ldapuser', + name='dn', + field=models.CharField(serialize=False, max_length=200, primary_key=True), + ), + migrations.AlterField( + model_name='ldapusergroup', + name='dn', + field=models.CharField(serialize=False, max_length=200, primary_key=True), + ), + ]