From ddee0352bc9b004959688c3d5295ba91fdf44416 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Sun, 6 Aug 2017 20:00:29 +0200 Subject: [PATCH] Repasse sur l'ancienne utilisation de l'objet extension --- machines/models.py | 3 +-- machines/serializers.py | 2 +- machines/views.py | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/machines/models.py b/machines/models.py index 241e3a14..247ca0f7 100644 --- a/machines/models.py +++ b/machines/models.py @@ -243,7 +243,7 @@ class Domain(models.Model): super(Domain, self).save(*args, **kwargs) def __str__(self): - return str(self.name) + str(self.get_extension()) + return str(self.name) + str(self.extension) class IpList(models.Model): PRETTY_NAME = "Addresses ipv4" @@ -300,4 +300,3 @@ def machine_post_save(sender, **kwargs): machinetype = kwargs['instance'] for interface in machinetype.all_interfaces(): interface.update_type() - diff --git a/machines/serializers.py b/machines/serializers.py index 4288c0d7..f21f1d41 100644 --- a/machines/serializers.py +++ b/machines/serializers.py @@ -50,7 +50,7 @@ class InterfaceSerializer(serializers.ModelSerializer): return obj.domain.name def get_interface_extension(self, obj): - return obj.domain.get_extension().name + return obj.domain.extension.name def get_macaddress(self, obj): return str(obj.mac_address) diff --git a/machines/views.py b/machines/views.py index 6e0eb46b..6115aaae 100644 --- a/machines/views.py +++ b/machines/views.py @@ -52,7 +52,7 @@ from preferences.models import GeneralOption, OptionalMachine def all_active_interfaces(): """Renvoie l'ensemble des machines autorisées à sortir sur internet """ - return Interface.objects.filter(machine__in=Machine.objects.filter(user__in=all_has_access()).filter(active=True)).select_related('domain').select_related('machine').select_related('type').select_related('ipv4').select_related('type__ip_type__extension').select_related('ipv4__ip_type').distinct() + return Interface.objects.filter(machine__in=Machine.objects.filter(user__in=all_has_access()).filter(active=True)).select_related('domain').select_related('machine').select_related('type').select_related('ipv4').select_related('domain_extension').select_related('ipv4__ip_type').distinct() def all_active_assigned_interfaces(): """ Renvoie l'ensemble des machines qui ont une ipv4 assignées et disposant de l'accès internet"""