From 7166318e19048cbf6b38c7e82ec2b7c5827338a9 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Thu, 12 Jul 2018 00:11:55 +0200 Subject: [PATCH] Repare le get_instance de role --- api/serializers.py | 7 ++++++- machines/models.py | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/api/serializers.py b/api/serializers.py index ffb3aaba..db3f1b7b 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -338,10 +338,15 @@ class OptionalMachineSerializer(NamespacedHMSerializer): class OptionalTopologieSerializer(NamespacedHMSerializer): """Serialize `preferences.models.OptionalTopologie` objects. """ + switchs_management_interface_ip= serializers.CharField(read_only=True) + class Meta: model = preferences.OptionalTopologie fields = ('radius_general_policy', 'vlan_decision_ok', - 'vlan_decision_nok') + 'vlan_decision_nok', 'switchs_ip_type', 'switchs_web_management', + 'switchs_web_management_ssl', 'switchs_rest_management', + 'switchs_management_utils', 'switchs_management_interface_ip', + 'provision_switchs_enabled') class GeneralOptionSerializer(NamespacedHMSerializer): diff --git a/machines/models.py b/machines/models.py index 6ce84adb..e981bf10 100644 --- a/machines/models.py +++ b/machines/models.py @@ -1497,6 +1497,13 @@ class Role(RevMixin, AclMixin, models.Model): role=cls.objects.filter(specific_role=roletype) ) + @classmethod + def all_interfaces_for_roletype(cls, roletype): + """Return all interfaces for a roletype""" + return Interface.objects.filter( + machine__interface__role=cls.objects.filter(specific_role=roletype) + ) + def save(self, *args, **kwargs): super(Role, self).save(*args, **kwargs)