8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-25 04:43:10 +00:00

Unifie les résultats de l'API pour les preferences avec une liste de 1 élément

This commit is contained in:
Grizzly 2018-11-05 18:27:28 +00:00
parent b710e2a56a
commit 77eb634320
3 changed files with 24 additions and 49 deletions

View file

@ -429,8 +429,7 @@ class AssoOptionSerializer(NamespacedHMSerializer):
class Meta: class Meta:
model = preferences.AssoOption model = preferences.AssoOption
fields = ('name', 'siret', 'adresse1', 'adresse2', 'contact', fields = '__all__'
'telephone', 'pseudo', 'utilisateur_asso', 'description')
class HomeOptionSerializer(NamespacedHMSerializer): class HomeOptionSerializer(NamespacedHMSerializer):
@ -439,7 +438,7 @@ class HomeOptionSerializer(NamespacedHMSerializer):
class Meta: class Meta:
model = preferences.HomeOption model = preferences.HomeOption
fields = ('facebook_url', 'twitter_url', 'twitter_account_name') fields = '__all__'
class MailMessageOptionSerializer(NamespacedHMSerializer): class MailMessageOptionSerializer(NamespacedHMSerializer):
@ -448,8 +447,7 @@ class MailMessageOptionSerializer(NamespacedHMSerializer):
class Meta: class Meta:
model = preferences.MailMessageOption model = preferences.MailMessageOption
fields = ('welcome_mail_fr', 'welcome_mail_en') fields = '__all__'
# TOPOLOGIE # TOPOLOGIE
@ -470,7 +468,6 @@ class AccessPointSerializer(NamespacedHMSerializer):
class Meta: class Meta:
model = topologie.AccessPoint model = topologie.AccessPoint
fields = ('user', 'name', 'active', 'location', 'api_url')
class SwitchSerializer(NamespacedHMSerializer): class SwitchSerializer(NamespacedHMSerializer):

View file

@ -64,14 +64,14 @@ router.register_viewset(r'machines/ouvertureportlist', views.OuverturePortListVi
router.register_viewset(r'machines/ouvertureport', views.OuverturePortViewSet) router.register_viewset(r'machines/ouvertureport', views.OuverturePortViewSet)
router.register_viewset(r'machines/role', views.RoleViewSet) router.register_viewset(r'machines/role', views.RoleViewSet)
# PREFERENCES # PREFERENCES
router.register_view(r'preferences/optionaluser', views.OptionalUserView), router.register_viewset(r'preferences/optionaluser', views.OptionalUserViewSet),
router.register_view(r'preferences/optionalmachine', views.OptionalMachineView), router.register_viewset(r'preferences/optionalmachine', views.OptionalMachineViewSet),
router.register_view(r'preferences/optionaltopologie', views.OptionalTopologieView), router.register_viewset(r'preferences/optionaltopologie', views.OptionalTopologieViewSet),
router.register_view(r'preferences/generaloption', views.GeneralOptionView), router.register_viewset(r'preferences/generaloption', views.GeneralOptionViewSet),
router.register_viewset(r'preferences/service', views.HomeServiceViewSet, base_name='homeservice'), router.register_viewset(r'preferences/service', views.HomeServiceViewSet, base_name='homeservice'),
router.register_view(r'preferences/assooption', views.AssoOptionView), router.register_viewset(r'preferences/assooption', views.AssoOptionViewSet),
router.register_view(r'preferences/homeoption', views.HomeOptionView), router.register_viewset(r'preferences/homeoption', views.HomeOptionViewSet),
router.register_view(r'preferences/mailmessageoption', views.MailMessageOptionView), router.register_viewset(r'preferences/mailmessageoption', views.MailMessageOptionViewSet),
# TOPOLOGIE # TOPOLOGIE
router.register_viewset(r'topologie/stack', views.StackViewSet) router.register_viewset(r'topologie/stack', views.StackViewSet)
router.register_viewset(r'topologie/acesspoint', views.AccessPointViewSet) router.register_viewset(r'topologie/acesspoint', views.AccessPointViewSet)

View file

@ -259,48 +259,36 @@ class RoleViewSet(viewsets.ReadOnlyModelViewSet):
# Those views differ a bit because there is only one object # Those views differ a bit because there is only one object
# to display, so we don't bother with the listing part # to display, so we don't bother with the listing part
class OptionalUserView(generics.RetrieveAPIView): class OptionalUserViewSet(viewsets.ReadOnlyModelViewSet):
"""Exposes details of `preferences.models.` settings. """Exposes details of `preferences.models.` settings.
""" """
permission_classes = (ACLPermission,) queryset = preferences.OptionalUser.objects.all()
perms_map = {'GET': [preferences.OptionalUser.can_view_all]}
serializer_class = serializers.OptionalUserSerializer serializer_class = serializers.OptionalUserSerializer
def get_object(self):
return preferences.OptionalUser.objects.first()
class OptionalMachineView(generics.RetrieveAPIView): class OptionalMachineViewSet(viewsets.ReadOnlyModelViewSet):
"""Exposes details of `preferences.models.OptionalMachine` settings. """Exposes details of `preferences.models.OptionalMachine` settings.
""" """
permission_classes = (ACLPermission,) queryset = preferences.OptionalMachine.objects.all()
perms_map = {'GET': [preferences.OptionalMachine.can_view_all]}
serializer_class = serializers.OptionalMachineSerializer serializer_class = serializers.OptionalMachineSerializer
def get_object(self):
return preferences.OptionalMachine.objects.first()
class OptionalTopologieView(generics.RetrieveAPIView): class OptionalTopologieViewSet(viewsets.ReadOnlyModelViewSet):
"""Exposes details of `preferences.models.OptionalTopologie` settings. """Exposes details of `preferences.models.OptionalTopologie` settings.
""" """
permission_classes = (ACLPermission,) queryset = preferences.OptionalTopologie.objects.all()
perms_map = {'GET': [preferences.OptionalTopologie.can_view_all]}
serializer_class = serializers.OptionalTopologieSerializer serializer_class = serializers.OptionalTopologieSerializer
def get_object(self):
return preferences.OptionalTopologie.objects.first()
class GeneralOptionView(generics.RetrieveAPIView): class GeneralOptionViewSet(viewsets.ReadOnlyModelViewSet):
"""Exposes details of `preferences.models.GeneralOption` settings. """Exposes details of `preferences.models.GeneralOption` settings.
""" """
permission_classes = (ACLPermission,) queryset = preferences.GeneralOption.objects.all()
perms_map = {'GET': [preferences.GeneralOption.can_view_all]}
serializer_class = serializers.GeneralOptionSerializer serializer_class = serializers.GeneralOptionSerializer
def get_object(self):
return preferences.GeneralOption.objects.first()
class HomeServiceViewSet(viewsets.ReadOnlyModelViewSet): class HomeServiceViewSet(viewsets.ReadOnlyModelViewSet):
@ -310,37 +298,27 @@ class HomeServiceViewSet(viewsets.ReadOnlyModelViewSet):
serializer_class = serializers.HomeServiceSerializer serializer_class = serializers.HomeServiceSerializer
class AssoOptionView(generics.RetrieveAPIView): class AssoOptionViewSet(viewsets.ReadOnlyModelViewSet):
"""Exposes details of `preferences.models.AssoOption` settings. """Exposes details of `preferences.models.AssoOption` settings.
""" """
permission_classes = (ACLPermission,) queryset = preferences.AssoOption.objects.all()
perms_map = {'GET': [preferences.AssoOption.can_view_all]}
serializer_class = serializers.AssoOptionSerializer serializer_class = serializers.AssoOptionSerializer
def get_object(self):
return preferences.AssoOption.objects.first()
class HomeOptionViewSet(viewsets.ReadOnlyModelViewSet):
class HomeOptionView(generics.RetrieveAPIView):
"""Exposes details of `preferences.models.HomeOption` settings. """Exposes details of `preferences.models.HomeOption` settings.
""" """
permission_classes = (ACLPermission,) queryset = preferences.HomeOption.objects.all()
perms_map = {'GET': [preferences.HomeOption.can_view_all]}
serializer_class = serializers.HomeOptionSerializer serializer_class = serializers.HomeOptionSerializer
def get_object(self):
return preferences.HomeOption.objects.first()
class MailMessageOptionView(generics.RetrieveAPIView): class MailMessageOptionViewSet(viewsets.ReadOnlyModelViewSet):
"""Exposes details of `preferences.models.MailMessageOption` settings. """Exposes details of `preferences.models.MailMessageOption` settings.
""" """
permission_classes = (ACLPermission,) queryset = preferences.MailMessageOption.objects.all()
perms_map = {'GET': [preferences.MailMessageOption.can_view_all]}
serializer_class = serializers.MailMessageOptionSerializer serializer_class = serializers.MailMessageOptionSerializer
def get_object(self):
return preferences.MailMessageOption.objects.first()
# TOPOLOGIE # TOPOLOGIE