8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-26 22:52:26 +00:00

Add preferences API endpoints

This commit is contained in:
Maël Kervella 2018-06-16 18:35:08 +00:00 committed by Maël Kervella
parent ca0744a38c
commit 3a0dda0009
3 changed files with 140 additions and 106 deletions

View file

@ -239,66 +239,64 @@ class OuverturePortSerializer(NamespacedHMSerializer):
# PREFERENCES APP # PREFERENCES APP
# class OptionalUserSerializer(NamespacedHMSerializer): class OptionalUserSerializer(NamespacedHMSerializer):
# tel_mandatory = serializers.BooleanField(source='is_tel_mandatory') tel_mandatory = serializers.BooleanField(source='is_tel_mandatory')
#
# class Meta: class Meta:
# model = preferences.OptionalUser model = preferences.OptionalUser
# fields = ('tel_mandatory', 'user_solde', 'solde_negatif', 'max_solde', fields = ('tel_mandatory', 'user_solde', 'solde_negatif', 'max_solde',
# 'min_online_payement', 'gpg_fingerprint', 'min_online_payment', 'gpg_fingerprint',
# 'all_can_create_club', 'self_adhesion', 'shell_default', 'all_can_create_club', 'self_adhesion', 'shell_default')
# 'api_url')
#
# class OptionalMachineSerializer(NamespacedHMSerializer):
# class OptionalMachineSerializer(NamespacedHMSerializer): class Meta:
# class Meta: model = preferences.OptionalMachine
# model = preferences.OptionalMachine fields = ('password_machine', 'max_lambdauser_interfaces',
# fields = ('password_machine', 'max_lambdauser_interfaces', 'max_lambdauser_aliases', 'ipv6_mode', 'create_machine',
# 'max_lambdauser_aliases', 'ipv6_mode', 'create_machine', 'ipv6')
# 'ipv6', 'api_url')
#
# class OptionalTopologieSerializer(NamespacedHMSerializer):
# class OptionalTopologieSerializer(NamespacedHMSerializer): class Meta:
# class Meta: model = preferences.OptionalTopologie
# model = preferences.OptionalTopologie fields = ('radius_general_policy', 'vlan_decision_ok',
# fields = ('radius_general_policy', 'vlan_decision_ok', 'vlan_decision_nok')
# 'vlan_decision_no', 'api_url')
#
# class GeneralOptionSerializer(NamespacedHMSerializer):
# class GeneralOptionSerializer(NamespacedHMSerializer): class Meta:
# class Meta: model = preferences.GeneralOption
# model = preferences.GeneralOption fields = ('general_message', 'search_display_page',
# fields = ('general_message', 'search_display_page', 'pagination_number', 'pagination_large_number',
# 'pagination_number', 'pagination_large_number', 'req_expire_hrs', 'site_name', 'email_from', 'GTU_sum_up',
# 'req_expire_hrs', 'site_name', 'email_from', 'GTU_sum_up', 'GTU')
# 'GTU', 'api_url')
#
# class ServiceSerializer(NamespacedHMSerializer):
# class ServiceOptionSerializer(NamespacedHMSerializer): class Meta:
# class Meta: model = preferences.Service
# model = preferences.ServiceOption fields = ('name', 'url', 'description', 'image', 'api_url')
# fields = ('name', 'url', 'description', 'image', 'api_url')
#
# class AssoOptionSerializer(NamespacedHMSerializer):
# class AssoOptionSerializer(NamespacedHMSerializer): class Meta:
# class Meta: model = preferences.AssoOption
# model = preferences.AssoOption fields = ('name', 'siret', 'adresse1', 'adresse2', 'contact',
# fields = ('name', 'siret', 'adresse1', 'adresse2', 'contact', 'telephone', 'pseudo', 'utilisateur_asso', 'payment',
# 'telephone', 'pseudo', 'utilisateur_asso', 'payement', 'payment_id', 'payment_pass', 'description')
# 'payement_id', 'payement_pass', 'description', 'api_url')
#
# class HomeOptionSerializer(NamespacedHMSerializer):
# class HomeOptionSerializer(NamespacedHMSerializer): class Meta:
# class Meta: model = preferences.HomeOption
# model = preferences.HomeOption fields = ('facebook_url', 'twitter_url', 'twitter_account_name')
# fields = ('facebook_url', 'twitter_url', 'twitter_account_name',
# 'api_url')
# class MailMessageOptionSerializer(NamespacedHMSerializer):
# class Meta:
# class MailMessageOptionSerializer(NamespacedHMSerializer): model = preferences.MailMessageOption
# class Meta: fields = ('welcome_mail_fr', 'welcome_mail_en')
# model = preferences.MailMessageOption
# fields = ('welcome_mail_fr', 'welcome_mail_en', 'api_url')

View file

@ -58,14 +58,7 @@ router.register(r'machines/servicelinks', views.ServiceLinkViewSet, base_name='s
router.register(r'machines/ouvertureportlists', views.OuverturePortListViewSet) router.register(r'machines/ouvertureportlists', views.OuverturePortListViewSet)
router.register(r'machines/ouvertureports', views.OuverturePortViewSet) router.register(r'machines/ouvertureports', views.OuverturePortViewSet)
# PREFERENCES APP # PREFERENCES APP
#router.register(r'preferences/optionaluser', views.OptionalUserSerializer) router.register(r'preferences/service', views.ServiceViewSet),
#router.register(r'preferences/optionalmachine', views.OptionalMachineSerializer)
#router.register(r'preferences/optionaltopologie', views.OptionalTopologieSerializer)
#router.register(r'preferences/generaloption', views.GeneralOptionSerializer)
#router.register(r'preferences/serviceoption', views.ServiceOptionSerializer)
#router.register(r'preferences/assooption', views.AssoOptionSerializer)
#router.register(r'preferences/homeoption', views.HomeOptionSerializer)
#router.register(r'preferences/mailmessageoption', views.MailMessageOptionSerializer)
# TOPOLOGIE APP # TOPOLOGIE APP
router.register(r'topologie/stack', views.StackViewSet) router.register(r'topologie/stack', views.StackViewSet)
router.register(r'topologie/acesspoint', views.AccessPointViewSet) router.register(r'topologie/acesspoint', views.AccessPointViewSet)
@ -91,10 +84,23 @@ router.register(r'services/regen', views.ServiceRegenViewSet, base_name='service
urlpatterns = [ urlpatterns = [
# VIEWSETS
url(r'^', include(router.urls)), url(r'^', include(router.urls)),
# PREFERENCES APP
url(r'^preferences/optionaluser', views.OptionalUserView.as_view()),
url(r'^preferences/optionalmachine', views.OptionalMachineView.as_view()),
url(r'^preferences/optionaltopologie', views.OptionalTopologieView.as_view()),
url(r'^preferences/generaloption', views.GeneralOptionView.as_view()),
url(r'^preferences/assooption', views.AssoOptionView.as_view()),
url(r'^preferences/homeoption', views.HomeOptionView.as_view()),
url(r'^preferences/mailmessageoption', views.MailMessageOptionView.as_view()),
# DHCP
url(r'^dhcp/hostmacip', views.HostMacIpView.as_view()), url(r'^dhcp/hostmacip', views.HostMacIpView.as_view()),
# DNS
url(r'^dns/zones', views.DNSZonesView.as_view()), url(r'^dns/zones', views.DNSZonesView.as_view()),
# MAILING
url(r'^mailing/standard', views.StandardMailingView.as_view()), url(r'^mailing/standard', views.StandardMailingView.as_view()),
url(r'^mailing/club', views.ClubMailingView.as_view()), url(r'^mailing/club', views.ClubMailingView.as_view()),
# TOKEN-AUTH
url(r'^token-auth', views.ObtainExpiringAuthToken.as_view()) url(r'^token-auth', views.ObtainExpiringAuthToken.as_view())
] ]

View file

@ -178,45 +178,75 @@ class OuverturePortViewSet(viewsets.ReadOnlyModelViewSet):
# PREFERENCES APP # PREFERENCES APP
# Those views differ a bit because there is only one object
# to display, so we don't bother with the listing part
# class OptionalUserViewSet(viewsets.ReadOnlyModelViewSet): class OptionalUserView(generics.RetrieveAPIView):
# queryset = preferences.OptionalUser.objects.all() permission_classes = (ACLPermission, )
# serializer_class = serializers.OptionalUserSerializer perms_map = {'GET' : [preferences.OptionalUser.can_view_all]}
# serializer_class = serializers.OptionalUserSerializer
#
# class OptionalMachineViewSet(viewsets.ReadOnlyModelViewSet): def get_object(self):
# queryset = preferences.OptionalMachine.objects.all() return preferences.OptionalUser.objects.first()
# serializer_class = serializers.OptionalMachineSerializer
#
# class OptionalMachineView(generics.RetrieveAPIView):
# class OptionalTopologieViewSet(viewsets.ReadOnlyModelViewSet): permission_classes = (ACLPermission, )
# queryset = preferences.OptionalTopologie.objects.all() perms_map = {'GET' : [preferences.OptionalMachine.can_view_all]}
# serializer_class = serializers.OptionalTopologieSerializer serializer_class = serializers.OptionalMachineSerializer
#
# def get_object(self):
# class GeneralOptionViewSet(viewsets.ReadOnlyModelViewSet): return preferences.OptionalMachine.objects.first()
# queryset = preferences.GeneralOption.objects.all()
# serializer_class = serializers.GeneralOptionSerializer
# class OptionalTopologieView(generics.RetrieveAPIView):
# permission_classes = (ACLPermission, )
# class ServiceOptionViewSet(viewsets.ReadOnlyModelViewSet): perms_map = {'GET' : [preferences.OptionalTopologie.can_view_all]}
# queryset = preferences.ServiceOption.objects.all() serializer_class = serializers.OptionalTopologieSerializer
# serializer_class = serializers.ServiceOptionSerializer
# def get_object(self):
# return preferences.OptionalTopologie.objects.first()
# class AssoOptionViewSet(viewsets.ReadOnlyModelViewSet):
# queryset = preferences.AssoOption.objects.all()
# serializer_class = serializers.AssoOptionSerializer class GeneralOptionView(generics.RetrieveAPIView):
# permission_classes = (ACLPermission, )
# perms_map = {'GET' : [preferences.GeneralOption.can_view_all]}
# class HomeOptionViewSet(viewsets.ReadOnlyModelViewSet): serializer_class = serializers.GeneralOptionSerializer
# queryset = preferences.HomeOption.objects.all()
# serializer_class = serializers.HomeOptionSerializer def get_object(self):
# return preferences.GeneralOption.objects.first()
#
# class MailMessageOptionViewSet(viewsets.ReadOnlyModelViewSet):
# queryset = preferences.MailMessageOption.objects.all() class ServiceViewSet(viewsets.ReadOnlyModelViewSet):
# serializer_class = serializers.MailMessageOptionSerializer queryset = preferences.Service.objects.all()
serializer_class = serializers.ServiceSerializer
class AssoOptionView(generics.RetrieveAPIView):
permission_classes = (ACLPermission, )
perms_map = {'GET' : [preferences.AssoOption.can_view_all]}
serializer_class = serializers.AssoOptionSerializer
def get_object(self):
return preferences.AssoOption.objects.first()
class HomeOptionView(generics.RetrieveAPIView):
permission_classes = (ACLPermission, )
perms_map = {'GET' : [preferences.HomeOption.can_view_all]}
serializer_class = serializers.HomeOptionSerializer
def get_object(self):
return preferences.HomeOption.objects.first()
class MailMessageOptionView(generics.RetrieveAPIView):
permission_classes = (ACLPermission, )
perms_map = {'GET' : [preferences.MailMessageOption.can_view_all]}
serializer_class = serializers.MailMessageOptionSerializer
def get_object(self):
return preferences.MailMessageOption.objects.first()
# TOPOLOGIE APP # TOPOLOGIE APP