mirror of
https://gitlab.crans.org/bde/nk20
synced 2024-11-26 18:37:12 +00:00
Add note models in API
This commit is contained in:
parent
5de93066db
commit
92fc92ba40
@ -7,11 +7,13 @@ from django.contrib.auth.models import User
|
||||
from rest_framework import routers, serializers, viewsets
|
||||
from member.serializers import ProfileViewSet, ClubViewSet, RoleViewSet, MembershipViewSet
|
||||
from activity.serializers import ActivityTypeViewSet, ActivityViewSet, GuestViewSet
|
||||
from note.serializers import NoteViewSet, NoteClubViewSet, NoteUserViewSet, NoteSpecialViewSet, \
|
||||
TransactionViewSet, TransactionTemplateViewSet, MembershipTransactionViewSet
|
||||
|
||||
class UserSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ['url', 'username', 'first_name', 'last_name', 'email', 'is_staff']
|
||||
fields = ('username', 'first_name', 'last_name', 'email', 'is_staff',)
|
||||
|
||||
class UserViewSet(viewsets.ModelViewSet):
|
||||
queryset = User.objects.all()
|
||||
@ -21,14 +23,23 @@ class UserViewSet(viewsets.ModelViewSet):
|
||||
router = routers.DefaultRouter()
|
||||
router.register(r'users', UserViewSet)
|
||||
|
||||
router.register(r'members/profiles', ProfileViewSet)
|
||||
router.register(r'members/clubs', ClubViewSet)
|
||||
router.register(r'members/roles', RoleViewSet)
|
||||
router.register(r'members/memberships', MembershipViewSet)
|
||||
router.register(r'members/profile', ProfileViewSet)
|
||||
router.register(r'members/club', ClubViewSet)
|
||||
router.register(r'members/role', RoleViewSet)
|
||||
router.register(r'members/membership', MembershipViewSet)
|
||||
|
||||
router.register(r'activity/activity_types', ActivityTypeViewSet)
|
||||
router.register(r'activity/activities', ActivityViewSet)
|
||||
router.register(r'activity/guests', GuestViewSet)
|
||||
router.register(r'activity/activity', ActivityViewSet)
|
||||
router.register(r'activity/type', ActivityTypeViewSet)
|
||||
router.register(r'activity/guest', GuestViewSet)
|
||||
|
||||
router.register(r'note/note', NoteViewSet)
|
||||
router.register(r'note/club', NoteClubViewSet)
|
||||
router.register(r'note/user', NoteUserViewSet)
|
||||
router.register(r'note/special', NoteSpecialViewSet)
|
||||
|
||||
router.register(r'note/transaction', TransactionViewSet)
|
||||
router.register(r'note/transaction/template', TransactionTemplateViewSet)
|
||||
router.register(r'note/transaction/membership', MembershipTransactionViewSet)
|
||||
|
||||
# Wire up our API using automatic URL routing.
|
||||
# Additionally, we include login URLs for the browsable API.
|
||||
|
83
apps/note/serializers.py
Normal file
83
apps/note/serializers.py
Normal file
@ -0,0 +1,83 @@
|
||||
# -*- mode: python; coding: utf-8 -*-
|
||||
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from .models.notes import Note, NoteClub, NoteSpecial, NoteUser
|
||||
from .models.transactions import TransactionTemplate, Transaction, MembershipTransaction
|
||||
from rest_framework import serializers, viewsets
|
||||
|
||||
class NoteSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = Note
|
||||
fields = ('balance', 'is_active', 'display_image', 'created_at',)
|
||||
|
||||
|
||||
class NoteViewSet(viewsets.ModelViewSet):
|
||||
queryset = Note.objects.all()
|
||||
serializer_class = NoteSerializer
|
||||
|
||||
|
||||
class NoteClubSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = NoteClub
|
||||
fields = ('balance', 'is_active', 'display_image', 'created_at', 'club',)
|
||||
|
||||
|
||||
class NoteClubViewSet(viewsets.ModelViewSet):
|
||||
queryset = NoteClub.objects.all()
|
||||
serializer_class = NoteClubSerializer
|
||||
|
||||
|
||||
class NoteSpecialSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = NoteSpecial
|
||||
fields = ('balance', 'is_active', 'display_image', 'created_at', 'club', 'special_type',)
|
||||
|
||||
|
||||
class NoteSpecialViewSet(viewsets.ModelViewSet):
|
||||
queryset = NoteSpecial.objects.all()
|
||||
serializer_class = NoteSpecialSerializer
|
||||
|
||||
|
||||
class NoteUserSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = NoteUser
|
||||
fields = ('balance', 'is_active', 'display_image', 'created_at', 'user',)
|
||||
|
||||
|
||||
class NoteUserViewSet(viewsets.ModelViewSet):
|
||||
queryset = NoteUser.objects.all()
|
||||
serializer_class = NoteUserSerializer
|
||||
|
||||
|
||||
class TransactionTemplateSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = TransactionTemplate
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class TransactionTemplateViewSet(viewsets.ModelViewSet):
|
||||
queryset = TransactionTemplate.objects.all()
|
||||
serializer_class = TransactionTemplateSerializer
|
||||
|
||||
|
||||
class TransactionSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = Transaction
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class TransactionViewSet(viewsets.ModelViewSet):
|
||||
queryset = Transaction.objects.all()
|
||||
serializer_class = TransactionSerializer
|
||||
|
||||
|
||||
class MembershipTransactionSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = MembershipTransaction
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class MembershipTransactionViewSet(viewsets.ModelViewSet):
|
||||
queryset = MembershipTransaction.objects.all()
|
||||
serializer_class = MembershipTransactionSerializer
|
Loading…
Reference in New Issue
Block a user