From 903f3486c7ca55cc99622e89161657a35e3b1028 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Sun, 30 Dec 2018 19:22:43 +0100 Subject: [PATCH] Export list_modules + return [] if no models for modules --- api/serializers.py | 3 ++- topologie/models.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/api/serializers.py b/api/serializers.py index e7b23f32..af92e0d0 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -811,7 +811,8 @@ class SwitchPortSerializer(serializers.ModelSerializer): model = topologie.Switch fields = ('short_name', 'model', 'switchbay', 'ports', 'ipv4', 'ipv6', 'interfaces_subnet', 'interfaces6_subnet', 'automatic_provision', 'rest_enabled', - 'web_management_enabled', 'get_radius_key_value', 'get_management_cred_value') + 'web_management_enabled', 'get_radius_key_value', 'get_management_cred_value', + 'list_modules') # LOCAL EMAILS diff --git a/topologie/models.py b/topologie/models.py index b9b2c6f2..38af0089 100644 --- a/topologie/models.py +++ b/topologie/models.py @@ -385,7 +385,7 @@ class Switch(AclMixin, Machine): def list_modules(self): """Return modules of that switch, list of dict (rank, reference)""" modules = [] - if self.model.is_modular: + if getattr(self.model, 'is_modular', None): if self.model.is_itself_module: modules.append((1, self.model.reference)) for module_of_self in self.moduleonswitch_set.all():