mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-05 01:16:27 +00:00
Add preferences API endpoints
This commit is contained in:
parent
ca0744a38c
commit
3a0dda0009
3 changed files with 140 additions and 106 deletions
|
@ -239,66 +239,64 @@ class OuverturePortSerializer(NamespacedHMSerializer):
|
|||
# PREFERENCES APP
|
||||
|
||||
|
||||
# class OptionalUserSerializer(NamespacedHMSerializer):
|
||||
# tel_mandatory = serializers.BooleanField(source='is_tel_mandatory')
|
||||
#
|
||||
# class Meta:
|
||||
# model = preferences.OptionalUser
|
||||
# fields = ('tel_mandatory', 'user_solde', 'solde_negatif', 'max_solde',
|
||||
# 'min_online_payement', 'gpg_fingerprint',
|
||||
# 'all_can_create_club', 'self_adhesion', 'shell_default',
|
||||
# 'api_url')
|
||||
#
|
||||
#
|
||||
# class OptionalMachineSerializer(NamespacedHMSerializer):
|
||||
# class Meta:
|
||||
# model = preferences.OptionalMachine
|
||||
# fields = ('password_machine', 'max_lambdauser_interfaces',
|
||||
# 'max_lambdauser_aliases', 'ipv6_mode', 'create_machine',
|
||||
# 'ipv6', 'api_url')
|
||||
#
|
||||
#
|
||||
# class OptionalTopologieSerializer(NamespacedHMSerializer):
|
||||
# class Meta:
|
||||
# model = preferences.OptionalTopologie
|
||||
# fields = ('radius_general_policy', 'vlan_decision_ok',
|
||||
# 'vlan_decision_no', 'api_url')
|
||||
#
|
||||
#
|
||||
# class GeneralOptionSerializer(NamespacedHMSerializer):
|
||||
# class Meta:
|
||||
# model = preferences.GeneralOption
|
||||
# fields = ('general_message', 'search_display_page',
|
||||
# 'pagination_number', 'pagination_large_number',
|
||||
# 'req_expire_hrs', 'site_name', 'email_from', 'GTU_sum_up',
|
||||
# 'GTU', 'api_url')
|
||||
#
|
||||
#
|
||||
# class ServiceOptionSerializer(NamespacedHMSerializer):
|
||||
# class Meta:
|
||||
# model = preferences.ServiceOption
|
||||
# fields = ('name', 'url', 'description', 'image', 'api_url')
|
||||
#
|
||||
#
|
||||
# class AssoOptionSerializer(NamespacedHMSerializer):
|
||||
# class Meta:
|
||||
# model = preferences.AssoOption
|
||||
# fields = ('name', 'siret', 'adresse1', 'adresse2', 'contact',
|
||||
# 'telephone', 'pseudo', 'utilisateur_asso', 'payement',
|
||||
# 'payement_id', 'payement_pass', 'description', 'api_url')
|
||||
#
|
||||
#
|
||||
# class HomeOptionSerializer(NamespacedHMSerializer):
|
||||
# class Meta:
|
||||
# model = preferences.HomeOption
|
||||
# fields = ('facebook_url', 'twitter_url', 'twitter_account_name',
|
||||
# 'api_url')
|
||||
#
|
||||
#
|
||||
# class MailMessageOptionSerializer(NamespacedHMSerializer):
|
||||
# class Meta:
|
||||
# model = preferences.MailMessageOption
|
||||
# fields = ('welcome_mail_fr', 'welcome_mail_en', 'api_url')
|
||||
class OptionalUserSerializer(NamespacedHMSerializer):
|
||||
tel_mandatory = serializers.BooleanField(source='is_tel_mandatory')
|
||||
|
||||
class Meta:
|
||||
model = preferences.OptionalUser
|
||||
fields = ('tel_mandatory', 'user_solde', 'solde_negatif', 'max_solde',
|
||||
'min_online_payment', 'gpg_fingerprint',
|
||||
'all_can_create_club', 'self_adhesion', 'shell_default')
|
||||
|
||||
|
||||
class OptionalMachineSerializer(NamespacedHMSerializer):
|
||||
class Meta:
|
||||
model = preferences.OptionalMachine
|
||||
fields = ('password_machine', 'max_lambdauser_interfaces',
|
||||
'max_lambdauser_aliases', 'ipv6_mode', 'create_machine',
|
||||
'ipv6')
|
||||
|
||||
|
||||
class OptionalTopologieSerializer(NamespacedHMSerializer):
|
||||
class Meta:
|
||||
model = preferences.OptionalTopologie
|
||||
fields = ('radius_general_policy', 'vlan_decision_ok',
|
||||
'vlan_decision_nok')
|
||||
|
||||
|
||||
class GeneralOptionSerializer(NamespacedHMSerializer):
|
||||
class Meta:
|
||||
model = preferences.GeneralOption
|
||||
fields = ('general_message', 'search_display_page',
|
||||
'pagination_number', 'pagination_large_number',
|
||||
'req_expire_hrs', 'site_name', 'email_from', 'GTU_sum_up',
|
||||
'GTU')
|
||||
|
||||
|
||||
class ServiceSerializer(NamespacedHMSerializer):
|
||||
class Meta:
|
||||
model = preferences.Service
|
||||
fields = ('name', 'url', 'description', 'image', 'api_url')
|
||||
|
||||
|
||||
class AssoOptionSerializer(NamespacedHMSerializer):
|
||||
class Meta:
|
||||
model = preferences.AssoOption
|
||||
fields = ('name', 'siret', 'adresse1', 'adresse2', 'contact',
|
||||
'telephone', 'pseudo', 'utilisateur_asso', 'payment',
|
||||
'payment_id', 'payment_pass', 'description')
|
||||
|
||||
|
||||
class HomeOptionSerializer(NamespacedHMSerializer):
|
||||
class Meta:
|
||||
model = preferences.HomeOption
|
||||
fields = ('facebook_url', 'twitter_url', 'twitter_account_name')
|
||||
|
||||
|
||||
class MailMessageOptionSerializer(NamespacedHMSerializer):
|
||||
class Meta:
|
||||
model = preferences.MailMessageOption
|
||||
fields = ('welcome_mail_fr', 'welcome_mail_en')
|
||||
|
||||
|
||||
|
||||
|
|
22
api/urls.py
22
api/urls.py
|
@ -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/ouvertureports', views.OuverturePortViewSet)
|
||||
# PREFERENCES APP
|
||||
#router.register(r'preferences/optionaluser', views.OptionalUserSerializer)
|
||||
#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)
|
||||
router.register(r'preferences/service', views.ServiceViewSet),
|
||||
# TOPOLOGIE APP
|
||||
router.register(r'topologie/stack', views.StackViewSet)
|
||||
router.register(r'topologie/acesspoint', views.AccessPointViewSet)
|
||||
|
@ -91,10 +84,23 @@ router.register(r'services/regen', views.ServiceRegenViewSet, base_name='service
|
|||
|
||||
|
||||
urlpatterns = [
|
||||
# VIEWSETS
|
||||
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()),
|
||||
# DNS
|
||||
url(r'^dns/zones', views.DNSZonesView.as_view()),
|
||||
# MAILING
|
||||
url(r'^mailing/standard', views.StandardMailingView.as_view()),
|
||||
url(r'^mailing/club', views.ClubMailingView.as_view()),
|
||||
# TOKEN-AUTH
|
||||
url(r'^token-auth', views.ObtainExpiringAuthToken.as_view())
|
||||
]
|
||||
|
|
106
api/views.py
106
api/views.py
|
@ -178,45 +178,75 @@ class OuverturePortViewSet(viewsets.ReadOnlyModelViewSet):
|
|||
|
||||
|
||||
# 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):
|
||||
# queryset = preferences.OptionalUser.objects.all()
|
||||
# serializer_class = serializers.OptionalUserSerializer
|
||||
#
|
||||
#
|
||||
# class OptionalMachineViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
# queryset = preferences.OptionalMachine.objects.all()
|
||||
# serializer_class = serializers.OptionalMachineSerializer
|
||||
#
|
||||
#
|
||||
# class OptionalTopologieViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
# queryset = preferences.OptionalTopologie.objects.all()
|
||||
# serializer_class = serializers.OptionalTopologieSerializer
|
||||
#
|
||||
#
|
||||
# class GeneralOptionViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
# queryset = preferences.GeneralOption.objects.all()
|
||||
# serializer_class = serializers.GeneralOptionSerializer
|
||||
#
|
||||
#
|
||||
# class ServiceOptionViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
# queryset = preferences.ServiceOption.objects.all()
|
||||
# serializer_class = serializers.ServiceOptionSerializer
|
||||
#
|
||||
#
|
||||
# class AssoOptionViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
# queryset = preferences.AssoOption.objects.all()
|
||||
# serializer_class = serializers.AssoOptionSerializer
|
||||
#
|
||||
#
|
||||
# class HomeOptionViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
# queryset = preferences.HomeOption.objects.all()
|
||||
# serializer_class = serializers.HomeOptionSerializer
|
||||
#
|
||||
#
|
||||
# class MailMessageOptionViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
# queryset = preferences.MailMessageOption.objects.all()
|
||||
# serializer_class = serializers.MailMessageOptionSerializer
|
||||
class OptionalUserView(generics.RetrieveAPIView):
|
||||
permission_classes = (ACLPermission, )
|
||||
perms_map = {'GET' : [preferences.OptionalUser.can_view_all]}
|
||||
serializer_class = serializers.OptionalUserSerializer
|
||||
|
||||
def get_object(self):
|
||||
return preferences.OptionalUser.objects.first()
|
||||
|
||||
|
||||
class OptionalMachineView(generics.RetrieveAPIView):
|
||||
permission_classes = (ACLPermission, )
|
||||
perms_map = {'GET' : [preferences.OptionalMachine.can_view_all]}
|
||||
serializer_class = serializers.OptionalMachineSerializer
|
||||
|
||||
def get_object(self):
|
||||
return preferences.OptionalMachine.objects.first()
|
||||
|
||||
|
||||
class OptionalTopologieView(generics.RetrieveAPIView):
|
||||
permission_classes = (ACLPermission, )
|
||||
perms_map = {'GET' : [preferences.OptionalTopologie.can_view_all]}
|
||||
serializer_class = serializers.OptionalTopologieSerializer
|
||||
|
||||
def get_object(self):
|
||||
return preferences.OptionalTopologie.objects.first()
|
||||
|
||||
|
||||
class GeneralOptionView(generics.RetrieveAPIView):
|
||||
permission_classes = (ACLPermission, )
|
||||
perms_map = {'GET' : [preferences.GeneralOption.can_view_all]}
|
||||
serializer_class = serializers.GeneralOptionSerializer
|
||||
|
||||
def get_object(self):
|
||||
return preferences.GeneralOption.objects.first()
|
||||
|
||||
|
||||
class ServiceViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue