mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 11:23:10 +00:00
Clear api generation
This commit is contained in:
parent
bdfd15b853
commit
035f447fdd
6 changed files with 48 additions and 42 deletions
|
@ -64,23 +64,4 @@ class NamespacedHMSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ReminderUsersSerializer(UserSerializer):
|
|
||||||
"""Serialize the data about a mailing member.
|
|
||||||
"""
|
|
||||||
|
|
||||||
class Meta(UserSerializer.Meta):
|
|
||||||
fields = ("get_full_name", "get_mail")
|
|
||||||
|
|
||||||
|
|
||||||
class ReminderSerializer(serializers.ModelSerializer):
|
|
||||||
"""
|
|
||||||
Serialize the data about a reminder
|
|
||||||
"""
|
|
||||||
|
|
||||||
users_to_remind = ReminderUsersSerializer(many=True)
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
model = preferences.Reminder
|
|
||||||
fields = ("days", "message", "users_to_remind")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
28
api/urls.py
28
api/urls.py
|
@ -28,25 +28,24 @@ can be generated automatically.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from django.conf.urls import url, include
|
from django.conf.urls import url, include
|
||||||
|
from importlib import import_module
|
||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
from .routers import AllViewsRouter
|
from .routers import AllViewsRouter
|
||||||
from cotisations.api.urls import urls_viewset as urls_viewset_cotisations
|
from django.conf import settings
|
||||||
from cotisations.api.urls import urls_view as urls_view_cotisations
|
|
||||||
from machines.api.urls import urls_viewset as urls_viewset_machines
|
|
||||||
from machines.api.urls import urls_view as urls_view_machines
|
|
||||||
from preferences.api.urls import urls_viewset as urls_viewset_preferences
|
|
||||||
from preferences.api.urls import urls_view as urls_view_preferences
|
|
||||||
from topologie.api.urls import urls_viewset as urls_viewset_topologie
|
|
||||||
from topologie.api.urls import urls_view as urls_view_topologie
|
|
||||||
from users.api.urls import urls_viewset as urls_viewset_users
|
|
||||||
from users.api.urls import urls_view as urls_view_users
|
|
||||||
|
|
||||||
urls_viewset = urls_viewset_cotisations + urls_viewset_machines + urls_viewset_preferences + urls_viewset_topologie + urls_viewset_users
|
|
||||||
urls_view = urls_view_cotisations + urls_view_machines + urls_view_preferences + urls_view_topologie + urls_view_users
|
|
||||||
|
|
||||||
router = AllViewsRouter()
|
router = AllViewsRouter()
|
||||||
|
|
||||||
|
urls_viewset = []
|
||||||
|
urls_view = []
|
||||||
|
|
||||||
|
for app in settings.INSTALLED_APPS:
|
||||||
|
try:
|
||||||
|
module = import_module(".api.urls", package=app)
|
||||||
|
urls_viewset += getattr(module, "urls_viewset", [])
|
||||||
|
urls_view += getattr(module, "urls_view", [])
|
||||||
|
except ImportError:
|
||||||
|
continue
|
||||||
|
|
||||||
for _url, viewset, name in urls_viewset:
|
for _url, viewset, name in urls_viewset:
|
||||||
if name == None:
|
if name == None:
|
||||||
|
@ -57,8 +56,7 @@ for _url, viewset, name in urls_viewset:
|
||||||
for _url, view in urls_view:
|
for _url, view in urls_view:
|
||||||
router.register_view(_url, view)
|
router.register_view(_url, view)
|
||||||
|
|
||||||
# Reminder
|
|
||||||
router.register_view(r"reminder/get-users", views.ReminderView),
|
|
||||||
# TOKEN AUTHENTICATION
|
# TOKEN AUTHENTICATION
|
||||||
router.register_view(r"token-auth", views.ObtainExpiringAuthToken)
|
router.register_view(r"token-auth", views.ObtainExpiringAuthToken)
|
||||||
|
|
||||||
|
|
|
@ -48,13 +48,6 @@ from .permissions import ACLPermission
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ReminderView(generics.ListAPIView):
|
|
||||||
"""Output for users to remind an end of their subscription.
|
|
||||||
"""
|
|
||||||
|
|
||||||
queryset = preferences.Reminder.objects.all()
|
|
||||||
serializer_class = serializers.ReminderSerializer
|
|
||||||
|
|
||||||
class ObtainExpiringAuthToken(ObtainAuthToken):
|
class ObtainExpiringAuthToken(ObtainAuthToken):
|
||||||
"""Exposes a view to obtain a authentication token.
|
"""Exposes a view to obtain a authentication token.
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,9 @@
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
import cotisations.models as cotisations
|
import cotisations.models as cotisations
|
||||||
|
import preferences.models as preferences
|
||||||
from api.serializers import NamespacedHRField, NamespacedHIField, NamespacedHMSerializer
|
from api.serializers import NamespacedHRField, NamespacedHIField, NamespacedHMSerializer
|
||||||
|
from users.api.serializers import UserSerializer
|
||||||
|
|
||||||
|
|
||||||
class FactureSerializer(NamespacedHMSerializer):
|
class FactureSerializer(NamespacedHMSerializer):
|
||||||
|
@ -103,3 +105,23 @@ class CotisationSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = cotisations.Cotisation
|
model = cotisations.Cotisation
|
||||||
fields = ("vente", "type_cotisation", "date_start", "date_end", "api_url")
|
fields = ("vente", "type_cotisation", "date_start", "date_end", "api_url")
|
||||||
|
|
||||||
|
|
||||||
|
class ReminderUsersSerializer(UserSerializer):
|
||||||
|
"""Serialize the data about a mailing member.
|
||||||
|
"""
|
||||||
|
|
||||||
|
class Meta(UserSerializer.Meta):
|
||||||
|
fields = ("get_full_name", "get_mail")
|
||||||
|
|
||||||
|
|
||||||
|
class ReminderSerializer(serializers.ModelSerializer):
|
||||||
|
"""
|
||||||
|
Serialize the data about a reminder
|
||||||
|
"""
|
||||||
|
|
||||||
|
users_to_remind = ReminderUsersSerializer(many=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = preferences.Reminder
|
||||||
|
fields = ("days", "message", "users_to_remind")
|
|
@ -31,5 +31,8 @@ urls_viewset = [
|
||||||
]
|
]
|
||||||
|
|
||||||
urls_view = [
|
urls_view = [
|
||||||
# (r"reminder/get-users", views.ReminderView),
|
(r"cotisations/reminder-get-users", views.ReminderView),
|
||||||
|
|
||||||
|
# Deprecated
|
||||||
|
(r"reminder/get-users", views.ReminderView),
|
||||||
]
|
]
|
|
@ -23,6 +23,7 @@ from rest_framework import viewsets, generics
|
||||||
|
|
||||||
from . import serializers
|
from . import serializers
|
||||||
import cotisations.models as cotisations
|
import cotisations.models as cotisations
|
||||||
|
import preferences.models as preferences
|
||||||
|
|
||||||
class FactureViewSet(viewsets.ReadOnlyModelViewSet):
|
class FactureViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
"""Exposes list and details of `cotisations.models.Facture` objects.
|
"""Exposes list and details of `cotisations.models.Facture` objects.
|
||||||
|
@ -78,3 +79,11 @@ class CotisationViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
|
|
||||||
queryset = cotisations.Cotisation.objects.all()
|
queryset = cotisations.Cotisation.objects.all()
|
||||||
serializer_class = serializers.CotisationSerializer
|
serializer_class = serializers.CotisationSerializer
|
||||||
|
|
||||||
|
|
||||||
|
class ReminderView(generics.ListAPIView):
|
||||||
|
"""Output for users to remind an end of their subscription.
|
||||||
|
"""
|
||||||
|
|
||||||
|
queryset = preferences.Reminder.objects.all()
|
||||||
|
serializer_class = serializers.ReminderSerializer
|
Loading…
Reference in a new issue