From edf89dac982e4bca3a41134f768399c1c05b6902 Mon Sep 17 00:00:00 2001 From: detraz Date: Fri, 4 Jan 2019 12:31:10 +0100 Subject: [PATCH] Fix crash of optionaltopologie serializer --- api/serializers.py | 16 ++++++++++++++-- api/urls.py | 1 + api/views.py | 11 +++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/api/serializers.py b/api/serializers.py index af92e0d0..8c22ed21 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -391,13 +391,25 @@ class OptionalTopologieSerializer(NamespacedHMSerializer): class Meta: model = preferences.OptionalTopologie - fields = ('radius_general_policy', 'vlan_decision_ok', - 'vlan_decision_nok', 'switchs_ip_type', 'switchs_web_management', + fields = ('switchs_ip_type', 'switchs_web_management', 'switchs_web_management_ssl', 'switchs_rest_management', 'switchs_management_utils', 'switchs_management_interface_ip', 'provision_switchs_enabled', 'switchs_provision', 'switchs_management_sftp_creds') +class RadiusOptionSerializer(NamespacedHMSerializer): + """Serialize `preferences.models.RadiusOption` objects + """ + + class Meta: + model = preferences.RadiusOption + fields = ('radius_general_policy', 'unknown_machine', + 'unknown_machine_vlan', 'unknown_port', + 'unknown_port_vlan', 'unknown_room', 'unknown_room_vlan', + 'non_member', 'non_member_vlan', 'banned', 'banned_vlan', + 'vlan_decision_ok') + + class GeneralOptionSerializer(NamespacedHMSerializer): """Serialize `preferences.models.GeneralOption` objects. """ diff --git a/api/urls.py b/api/urls.py index 723ca78c..4a34c1de 100644 --- a/api/urls.py +++ b/api/urls.py @@ -67,6 +67,7 @@ router.register_viewset(r'machines/role', views.RoleViewSet) router.register_view(r'preferences/optionaluser', views.OptionalUserView), router.register_view(r'preferences/optionalmachine', views.OptionalMachineView), router.register_view(r'preferences/optionaltopologie', views.OptionalTopologieView), +router.register_view(r'preferences/radiusoption', views.RadiusOptionView), router.register_view(r'preferences/generaloption', views.GeneralOptionView), router.register_viewset(r'preferences/service', views.HomeServiceViewSet, base_name='homeservice'), router.register_view(r'preferences/assooption', views.AssoOptionView), diff --git a/api/views.py b/api/views.py index 21f7b438..8f7b9c1f 100644 --- a/api/views.py +++ b/api/views.py @@ -292,6 +292,17 @@ class OptionalTopologieView(generics.RetrieveAPIView): return preferences.OptionalTopologie.objects.first() +class RadiusOptionView(generics.RetrieveAPIView): + """Exposes details of `preferences.models.OptionalTopologie` settings. + """ + permission_classes = (ACLPermission,) + perms_map = {'GET': [preferences.RadiusOption.can_view_all]} + serializer_class = serializers.RadiusOptionSerializer + + def get_object(self): + return preferences.RadiusOption.objects.first() + + class GeneralOptionView(generics.RetrieveAPIView): """Exposes details of `preferences.models.GeneralOption` settings. """