8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-24 20:33:11 +00:00

Export list_modules + return [] if no models for modules

This commit is contained in:
Gabriel Detraz 2018-12-30 19:22:43 +01:00 committed by root
parent 9086a51839
commit 903f3486c7
2 changed files with 3 additions and 2 deletions

View file

@ -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

View file

@ -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():