mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-28 15:42:25 +00:00
Unifie les résultats de l'API pour les preferences avec une liste de 1 élément
This commit is contained in:
parent
b710e2a56a
commit
77eb634320
3 changed files with 24 additions and 49 deletions
|
@ -429,8 +429,7 @@ class AssoOptionSerializer(NamespacedHMSerializer):
|
|||
|
||||
class Meta:
|
||||
model = preferences.AssoOption
|
||||
fields = ('name', 'siret', 'adresse1', 'adresse2', 'contact',
|
||||
'telephone', 'pseudo', 'utilisateur_asso', 'description')
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class HomeOptionSerializer(NamespacedHMSerializer):
|
||||
|
@ -439,7 +438,7 @@ class HomeOptionSerializer(NamespacedHMSerializer):
|
|||
|
||||
class Meta:
|
||||
model = preferences.HomeOption
|
||||
fields = ('facebook_url', 'twitter_url', 'twitter_account_name')
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class MailMessageOptionSerializer(NamespacedHMSerializer):
|
||||
|
@ -448,8 +447,7 @@ class MailMessageOptionSerializer(NamespacedHMSerializer):
|
|||
|
||||
class Meta:
|
||||
model = preferences.MailMessageOption
|
||||
fields = ('welcome_mail_fr', 'welcome_mail_en')
|
||||
|
||||
fields = '__all__'
|
||||
|
||||
# TOPOLOGIE
|
||||
|
||||
|
@ -470,7 +468,6 @@ class AccessPointSerializer(NamespacedHMSerializer):
|
|||
|
||||
class Meta:
|
||||
model = topologie.AccessPoint
|
||||
fields = ('user', 'name', 'active', 'location', 'api_url')
|
||||
|
||||
|
||||
class SwitchSerializer(NamespacedHMSerializer):
|
||||
|
|
14
api/urls.py
14
api/urls.py
|
@ -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/role', views.RoleViewSet)
|
||||
# PREFERENCES
|
||||
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/generaloption', views.GeneralOptionView),
|
||||
router.register_viewset(r'preferences/optionaluser', views.OptionalUserViewSet),
|
||||
router.register_viewset(r'preferences/optionalmachine', views.OptionalMachineViewSet),
|
||||
router.register_viewset(r'preferences/optionaltopologie', views.OptionalTopologieViewSet),
|
||||
router.register_viewset(r'preferences/generaloption', views.GeneralOptionViewSet),
|
||||
router.register_viewset(r'preferences/service', views.HomeServiceViewSet, base_name='homeservice'),
|
||||
router.register_view(r'preferences/assooption', views.AssoOptionView),
|
||||
router.register_view(r'preferences/homeoption', views.HomeOptionView),
|
||||
router.register_view(r'preferences/mailmessageoption', views.MailMessageOptionView),
|
||||
router.register_viewset(r'preferences/assooption', views.AssoOptionViewSet),
|
||||
router.register_viewset(r'preferences/homeoption', views.HomeOptionViewSet),
|
||||
router.register_viewset(r'preferences/mailmessageoption', views.MailMessageOptionViewSet),
|
||||
# TOPOLOGIE
|
||||
router.register_viewset(r'topologie/stack', views.StackViewSet)
|
||||
router.register_viewset(r'topologie/acesspoint', views.AccessPointViewSet)
|
||||
|
|
50
api/views.py
50
api/views.py
|
@ -259,48 +259,36 @@ class RoleViewSet(viewsets.ReadOnlyModelViewSet):
|
|||
# Those views differ a bit because there is only one object
|
||||
# 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.
|
||||
"""
|
||||
permission_classes = (ACLPermission,)
|
||||
perms_map = {'GET': [preferences.OptionalUser.can_view_all]}
|
||||
queryset = preferences.OptionalUser.objects.all()
|
||||
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.
|
||||
"""
|
||||
permission_classes = (ACLPermission,)
|
||||
perms_map = {'GET': [preferences.OptionalMachine.can_view_all]}
|
||||
queryset = preferences.OptionalMachine.objects.all()
|
||||
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.
|
||||
"""
|
||||
permission_classes = (ACLPermission,)
|
||||
perms_map = {'GET': [preferences.OptionalTopologie.can_view_all]}
|
||||
queryset = preferences.OptionalTopologie.objects.all()
|
||||
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.
|
||||
"""
|
||||
permission_classes = (ACLPermission,)
|
||||
perms_map = {'GET': [preferences.GeneralOption.can_view_all]}
|
||||
queryset = preferences.GeneralOption.objects.all()
|
||||
serializer_class = serializers.GeneralOptionSerializer
|
||||
|
||||
def get_object(self):
|
||||
return preferences.GeneralOption.objects.first()
|
||||
|
||||
|
||||
class HomeServiceViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
|
@ -310,37 +298,27 @@ class HomeServiceViewSet(viewsets.ReadOnlyModelViewSet):
|
|||
serializer_class = serializers.HomeServiceSerializer
|
||||
|
||||
|
||||
class AssoOptionView(generics.RetrieveAPIView):
|
||||
class AssoOptionViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
"""Exposes details of `preferences.models.AssoOption` settings.
|
||||
"""
|
||||
permission_classes = (ACLPermission,)
|
||||
perms_map = {'GET': [preferences.AssoOption.can_view_all]}
|
||||
queryset = preferences.AssoOption.objects.all()
|
||||
serializer_class = serializers.AssoOptionSerializer
|
||||
|
||||
def get_object(self):
|
||||
return preferences.AssoOption.objects.first()
|
||||
|
||||
|
||||
class HomeOptionView(generics.RetrieveAPIView):
|
||||
class HomeOptionViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
"""Exposes details of `preferences.models.HomeOption` settings.
|
||||
"""
|
||||
permission_classes = (ACLPermission,)
|
||||
perms_map = {'GET': [preferences.HomeOption.can_view_all]}
|
||||
queryset = preferences.HomeOption.objects.all()
|
||||
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.
|
||||
"""
|
||||
permission_classes = (ACLPermission,)
|
||||
perms_map = {'GET': [preferences.MailMessageOption.can_view_all]}
|
||||
queryset = preferences.MailMessageOption.objects.all()
|
||||
serializer_class = serializers.MailMessageOptionSerializer
|
||||
|
||||
def get_object(self):
|
||||
return preferences.MailMessageOption.objects.first()
|
||||
|
||||
|
||||
# TOPOLOGIE
|
||||
|
|
Loading…
Reference in a new issue