mirror of
https://gitlab.crans.org/bde/nk20
synced 2024-11-27 02:43:01 +00:00
Aliases were missing
This commit is contained in:
parent
d22350faf8
commit
f54e2ed145
@ -2,7 +2,7 @@
|
|||||||
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
from note.models.notes import Note, NoteClub, NoteSpecial, NoteUser
|
from note.models.notes import Note, NoteClub, NoteSpecial, NoteUser, Alias
|
||||||
from note.models.transactions import TransactionTemplate, Transaction, MembershipTransaction
|
from note.models.transactions import TransactionTemplate, Transaction, MembershipTransaction
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from rest_polymorphic.serializers import PolymorphicSerializer
|
from rest_polymorphic.serializers import PolymorphicSerializer
|
||||||
@ -50,6 +50,17 @@ class NoteUserSerializer(serializers.ModelSerializer):
|
|||||||
model = NoteUser
|
model = NoteUser
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
|
class AliasSerializer(serializers.ModelSerializer):
|
||||||
|
"""
|
||||||
|
REST API Serializer for Aliases.
|
||||||
|
The djangorestframework plugin will analyse the model `Alias` and parse all fields in the API.
|
||||||
|
"""
|
||||||
|
class Meta:
|
||||||
|
model = Alias
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
class NotePolymorphicSerializer(PolymorphicSerializer):
|
class NotePolymorphicSerializer(PolymorphicSerializer):
|
||||||
model_serializer_mapping = {
|
model_serializer_mapping = {
|
||||||
Note: NoteSerializer,
|
Note: NoteSerializer,
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
from .views import NoteViewSet, NotePolymorphicViewSet, NoteClubViewSet, NoteUserViewSet, NoteSpecialViewSet, \
|
from .views import NoteViewSet, NotePolymorphicViewSet, NoteClubViewSet, NoteUserViewSet, NoteSpecialViewSet, AliasViewSet, \
|
||||||
TransactionViewSet, TransactionTemplateViewSet, MembershipTransactionViewSet
|
TransactionViewSet, TransactionTemplateViewSet, MembershipTransactionViewSet
|
||||||
|
|
||||||
|
|
||||||
@ -10,7 +10,8 @@ def register_note_urls(router, path):
|
|||||||
"""
|
"""
|
||||||
Configure router for Note REST API.
|
Configure router for Note REST API.
|
||||||
"""
|
"""
|
||||||
router.register(path + '', NotePolymorphicViewSet)
|
router.register(path + '/note', NotePolymorphicViewSet)
|
||||||
|
router.register(path + '/alias', AliasViewSet)
|
||||||
|
|
||||||
router.register(path + '/transaction/transaction', TransactionViewSet)
|
router.register(path + '/transaction/transaction', TransactionViewSet)
|
||||||
router.register(path + '/transaction/template', TransactionTemplateViewSet)
|
router.register(path + '/transaction/template', TransactionTemplateViewSet)
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
from note.models.notes import Note, NoteClub, NoteSpecial, NoteUser
|
from note.models.notes import Note, NoteClub, NoteSpecial, NoteUser, Alias
|
||||||
from note.models.transactions import TransactionTemplate, Transaction, MembershipTransaction
|
from note.models.transactions import TransactionTemplate, Transaction, MembershipTransaction
|
||||||
from .serializers import NoteSerializer, NotePolymorphicSerializer, NoteClubSerializer, NoteSpecialSerializer, NoteUserSerializer, \
|
from .serializers import NoteSerializer, NotePolymorphicSerializer, NoteClubSerializer, NoteSpecialSerializer, NoteUserSerializer, AliasSerializer, \
|
||||||
TransactionTemplateSerializer, TransactionSerializer, MembershipTransactionSerializer
|
TransactionTemplateSerializer, TransactionSerializer, MembershipTransactionSerializer
|
||||||
from rest_framework import viewsets
|
from rest_framework import viewsets
|
||||||
|
|
||||||
@ -59,6 +59,16 @@ class NotePolymorphicViewSet(viewsets.ModelViewSet):
|
|||||||
serializer_class = NotePolymorphicSerializer
|
serializer_class = NotePolymorphicSerializer
|
||||||
|
|
||||||
|
|
||||||
|
class AliasViewSet(viewsets.ModelViewSet):
|
||||||
|
"""
|
||||||
|
REST API View set.
|
||||||
|
The djangorestframework plugin will get all `Alias` objects, serialize it to JSON with the given serializer,
|
||||||
|
then render it on /api/aliases/
|
||||||
|
"""
|
||||||
|
queryset = Alias.objects.all()
|
||||||
|
serializer_class = AliasSerializer
|
||||||
|
|
||||||
|
|
||||||
class TransactionTemplateViewSet(viewsets.ModelViewSet):
|
class TransactionTemplateViewSet(viewsets.ModelViewSet):
|
||||||
"""
|
"""
|
||||||
REST API View set.
|
REST API View set.
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
from django.conf.urls import url, include
|
from django.conf.urls import url, include
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from rest_framework import routers, serializers, viewsets
|
from rest_framework import routers, serializers, viewsets
|
||||||
|
|
||||||
|
from note.models import Alias
|
||||||
from .activity.urls import register_activity_urls
|
from .activity.urls import register_activity_urls
|
||||||
from .members.urls import register_members_urls
|
from .members.urls import register_members_urls
|
||||||
from .note.urls import register_note_urls
|
from .note.urls import register_note_urls
|
||||||
@ -16,7 +18,7 @@ class UserSerializer(serializers.ModelSerializer):
|
|||||||
"""
|
"""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = User
|
model = User
|
||||||
fields = ('username', 'first_name', 'last_name', 'email', 'is_staff',)
|
fields = '__all__'
|
||||||
|
|
||||||
class UserViewSet(viewsets.ModelViewSet):
|
class UserViewSet(viewsets.ModelViewSet):
|
||||||
"""
|
"""
|
||||||
@ -29,7 +31,7 @@ class UserViewSet(viewsets.ModelViewSet):
|
|||||||
|
|
||||||
# Routers provide an easy way of automatically determining the URL conf.
|
# Routers provide an easy way of automatically determining the URL conf.
|
||||||
router = routers.DefaultRouter()
|
router = routers.DefaultRouter()
|
||||||
router.register(r'users', UserViewSet)
|
router.register('user', UserViewSet)
|
||||||
|
|
||||||
# Routers for members app
|
# Routers for members app
|
||||||
register_members_urls(router, r'members')
|
register_members_urls(router, r'members')
|
||||||
|
Loading…
Reference in New Issue
Block a user