mirror of
https://gitlab.crans.org/bde/nk20
synced 2024-11-30 04:13:01 +00:00
Add one missing model to the API
This commit is contained in:
parent
0f1d662d25
commit
38ad870939
@ -5,7 +5,7 @@ from rest_framework import serializers
|
|||||||
from rest_polymorphic.serializers import PolymorphicSerializer
|
from rest_polymorphic.serializers import PolymorphicSerializer
|
||||||
|
|
||||||
from ..models.notes import Note, NoteClub, NoteSpecial, NoteUser, Alias
|
from ..models.notes import Note, NoteClub, NoteSpecial, NoteUser, Alias
|
||||||
from ..models.transactions import TransactionTemplate, Transaction, MembershipTransaction
|
from ..models.transactions import TransactionTemplate, Transaction, MembershipTransaction, TemplateCategory
|
||||||
|
|
||||||
|
|
||||||
class NoteSerializer(serializers.ModelSerializer):
|
class NoteSerializer(serializers.ModelSerializer):
|
||||||
@ -78,6 +78,17 @@ class NotePolymorphicSerializer(PolymorphicSerializer):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class TemplateCategorySerializer(serializers.ModelSerializer):
|
||||||
|
"""
|
||||||
|
REST API Serializer for Transaction templates.
|
||||||
|
The djangorestframework plugin will analyse the model `TemplateCategory` and parse all fields in the API.
|
||||||
|
"""
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = TemplateCategory
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
class TransactionTemplateSerializer(serializers.ModelSerializer):
|
class TransactionTemplateSerializer(serializers.ModelSerializer):
|
||||||
"""
|
"""
|
||||||
REST API Serializer for Transaction templates.
|
REST API Serializer for Transaction templates.
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
from .views import NotePolymorphicViewSet, AliasViewSet, \
|
from .views import NotePolymorphicViewSet, AliasViewSet, \
|
||||||
TransactionViewSet, TransactionTemplateViewSet, MembershipTransactionViewSet
|
TemplateCategoryViewSet, TransactionViewSet, TransactionTemplateViewSet, MembershipTransactionViewSet
|
||||||
|
|
||||||
|
|
||||||
def register_note_urls(router, path):
|
def register_note_urls(router, path):
|
||||||
@ -12,6 +12,7 @@ def register_note_urls(router, path):
|
|||||||
router.register(path + '/note', NotePolymorphicViewSet)
|
router.register(path + '/note', NotePolymorphicViewSet)
|
||||||
router.register(path + '/alias', AliasViewSet)
|
router.register(path + '/alias', AliasViewSet)
|
||||||
|
|
||||||
|
router.register(path + '/transaction/category', TemplateCategoryViewSet)
|
||||||
router.register(path + '/transaction/transaction', TransactionViewSet)
|
router.register(path + '/transaction/transaction', TransactionViewSet)
|
||||||
router.register(path + '/transaction/template', TransactionTemplateViewSet)
|
router.register(path + '/transaction/template', TransactionTemplateViewSet)
|
||||||
router.register(path + '/transaction/membership', MembershipTransactionViewSet)
|
router.register(path + '/transaction/membership', MembershipTransactionViewSet)
|
||||||
|
@ -6,9 +6,9 @@ from rest_framework import viewsets
|
|||||||
|
|
||||||
from .serializers import NoteSerializer, NotePolymorphicSerializer, NoteClubSerializer, NoteSpecialSerializer, \
|
from .serializers import NoteSerializer, NotePolymorphicSerializer, NoteClubSerializer, NoteSpecialSerializer, \
|
||||||
NoteUserSerializer, AliasSerializer, \
|
NoteUserSerializer, AliasSerializer, \
|
||||||
TransactionTemplateSerializer, TransactionSerializer, MembershipTransactionSerializer
|
TemplateCategorySerializer, TransactionTemplateSerializer, TransactionSerializer, MembershipTransactionSerializer
|
||||||
from ..models.notes import Note, NoteClub, NoteSpecial, NoteUser, Alias
|
from ..models.notes import Note, NoteClub, NoteSpecial, NoteUser, Alias
|
||||||
from ..models.transactions import TransactionTemplate, Transaction, MembershipTransaction
|
from ..models.transactions import TransactionTemplate, Transaction, MembershipTransaction, TemplateCategory
|
||||||
|
|
||||||
|
|
||||||
class NoteViewSet(viewsets.ModelViewSet):
|
class NoteViewSet(viewsets.ModelViewSet):
|
||||||
@ -131,6 +131,16 @@ class AliasViewSet(viewsets.ModelViewSet):
|
|||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
|
|
||||||
|
class TemplateCategoryViewSet(viewsets.ModelViewSet):
|
||||||
|
"""
|
||||||
|
REST API View set.
|
||||||
|
The djangorestframework plugin will get all `TemplateCategory` objects, serialize it to JSON with the given serializer,
|
||||||
|
then render it on /api/note/transaction/category/
|
||||||
|
"""
|
||||||
|
queryset = TemplateCategory.objects.all()
|
||||||
|
serializer_class = TemplateCategorySerializer
|
||||||
|
|
||||||
|
|
||||||
class TransactionTemplateViewSet(viewsets.ModelViewSet):
|
class TransactionTemplateViewSet(viewsets.ModelViewSet):
|
||||||
"""
|
"""
|
||||||
REST API View set.
|
REST API View set.
|
||||||
|
Loading…
Reference in New Issue
Block a user