mirror of
https://gitlab.crans.org/bde/nk20
synced 2024-11-26 18:37:12 +00:00
Clean code
This commit is contained in:
parent
c28884114c
commit
5633f0123d
35
apps/api/activity/serializers.py
Normal file
35
apps/api/activity/serializers.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
# -*- mode: python; coding: utf-8 -*-
|
||||||
|
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
from activity.models import ActivityType, Activity, Guest
|
||||||
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
class ActivityTypeSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
"""
|
||||||
|
REST API Serializer for Activity types.
|
||||||
|
The djangorestframework plugin will analyse the model `ActivityType` and parse all fields in the API.
|
||||||
|
"""
|
||||||
|
class Meta:
|
||||||
|
model = ActivityType
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
|
class ActivitySerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
"""
|
||||||
|
REST API Serializer for Activities.
|
||||||
|
The djangorestframework plugin will analyse the model `Activity` and parse all fields in the API.
|
||||||
|
"""
|
||||||
|
class Meta:
|
||||||
|
model = Activity
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
|
class GuestSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
"""
|
||||||
|
REST API Serializer for Guests.
|
||||||
|
The djangorestframework plugin will analyse the model `Guest` and parse all fields in the API.
|
||||||
|
"""
|
||||||
|
class Meta:
|
||||||
|
model = Guest
|
||||||
|
fields = '__all__'
|
14
apps/api/activity/urls.py
Normal file
14
apps/api/activity/urls.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# -*- mode: python; coding: utf-8 -*-
|
||||||
|
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
from .views import ActivityTypeViewSet, ActivityViewSet, GuestViewSet
|
||||||
|
|
||||||
|
|
||||||
|
def register_activity_urls(router, path):
|
||||||
|
"""
|
||||||
|
Configure router for Activity REST API.
|
||||||
|
"""
|
||||||
|
router.register(path + r'activity', ActivityViewSet)
|
||||||
|
router.register(path + r'type', ActivityTypeViewSet)
|
||||||
|
router.register(path + r'guest', GuestViewSet)
|
@ -2,18 +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 .models import ActivityType, Activity, Guest
|
from activity.models import ActivityType, Activity, Guest
|
||||||
from rest_framework import serializers, viewsets
|
from .serializers import ActivityTypeSerializer, ActivitySerializer, GuestSerializer
|
||||||
|
from rest_framework import viewsets
|
||||||
class ActivityTypeSerializer(serializers.HyperlinkedModelSerializer):
|
|
||||||
"""
|
|
||||||
REST API Serializer for Activity types.
|
|
||||||
The djangorestframework plugin will analyse the model `ActivityType` and parse all fields in the API.
|
|
||||||
"""
|
|
||||||
class Meta:
|
|
||||||
model = ActivityType
|
|
||||||
fields = '__all__'
|
|
||||||
|
|
||||||
|
|
||||||
class ActivityTypeViewSet(viewsets.ModelViewSet):
|
class ActivityTypeViewSet(viewsets.ModelViewSet):
|
||||||
"""
|
"""
|
||||||
@ -25,16 +16,6 @@ class ActivityTypeViewSet(viewsets.ModelViewSet):
|
|||||||
serializer_class = ActivityTypeSerializer
|
serializer_class = ActivityTypeSerializer
|
||||||
|
|
||||||
|
|
||||||
class ActivitySerializer(serializers.HyperlinkedModelSerializer):
|
|
||||||
"""
|
|
||||||
REST API Serializer for Activities.
|
|
||||||
The djangorestframework plugin will analyse the model `Activity` and parse all fields in the API.
|
|
||||||
"""
|
|
||||||
class Meta:
|
|
||||||
model = Activity
|
|
||||||
fields = '__all__'
|
|
||||||
|
|
||||||
|
|
||||||
class ActivityViewSet(viewsets.ModelViewSet):
|
class ActivityViewSet(viewsets.ModelViewSet):
|
||||||
"""
|
"""
|
||||||
REST API View set.
|
REST API View set.
|
||||||
@ -45,16 +26,6 @@ class ActivityViewSet(viewsets.ModelViewSet):
|
|||||||
serializer_class = ActivitySerializer
|
serializer_class = ActivitySerializer
|
||||||
|
|
||||||
|
|
||||||
class GuestSerializer(serializers.HyperlinkedModelSerializer):
|
|
||||||
"""
|
|
||||||
REST API Serializer for Guests.
|
|
||||||
The djangorestframework plugin will analyse the model `Guest` and parse all fields in the API.
|
|
||||||
"""
|
|
||||||
class Meta:
|
|
||||||
model = Guest
|
|
||||||
fields = '__all__'
|
|
||||||
|
|
||||||
|
|
||||||
class GuestViewSet(viewsets.ModelViewSet):
|
class GuestViewSet(viewsets.ModelViewSet):
|
||||||
"""
|
"""
|
||||||
REST API View set.
|
REST API View set.
|
||||||
@ -62,4 +33,4 @@ class GuestViewSet(viewsets.ModelViewSet):
|
|||||||
then render it on /api/activity/guest/
|
then render it on /api/activity/guest/
|
||||||
"""
|
"""
|
||||||
queryset = Guest.objects.all()
|
queryset = Guest.objects.all()
|
||||||
serializer_class = GuestSerializer
|
serializer_class = GuestSerializer
|
46
apps/api/members/serializers.py
Normal file
46
apps/api/members/serializers.py
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
# -*- mode: python; coding: utf-8 -*-
|
||||||
|
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
from member.models import Profile, Club, Role, Membership
|
||||||
|
from rest_framework import serializers, viewsets
|
||||||
|
|
||||||
|
|
||||||
|
class ProfileSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
"""
|
||||||
|
REST API Serializer for Profiles.
|
||||||
|
The djangorestframework plugin will analyse the model `Profile` and parse all fields in the API.
|
||||||
|
"""
|
||||||
|
class Meta:
|
||||||
|
model = Profile
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
|
class ClubSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
"""
|
||||||
|
REST API Serializer for Clubs.
|
||||||
|
The djangorestframework plugin will analyse the model `Club` and parse all fields in the API.
|
||||||
|
"""
|
||||||
|
class Meta:
|
||||||
|
model = Club
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
|
class RoleSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
"""
|
||||||
|
REST API Serializer for Roles.
|
||||||
|
The djangorestframework plugin will analyse the model `Role` and parse all fields in the API.
|
||||||
|
"""
|
||||||
|
class Meta:
|
||||||
|
model = Role
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
|
class MembershipSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
"""
|
||||||
|
REST API Serializer for Memberships.
|
||||||
|
The djangorestframework plugin will analyse the model `Memberships` and parse all fields in the API.
|
||||||
|
"""
|
||||||
|
class Meta:
|
||||||
|
model = Membership
|
||||||
|
fields = '__all__'
|
15
apps/api/members/urls.py
Normal file
15
apps/api/members/urls.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# -*- mode: python; coding: utf-8 -*-
|
||||||
|
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
from .views import ProfileViewSet, ClubViewSet, RoleViewSet, MembershipViewSet
|
||||||
|
|
||||||
|
|
||||||
|
def register_members_urls(router, path):
|
||||||
|
"""
|
||||||
|
Configure router for Member REST API.
|
||||||
|
"""
|
||||||
|
router.register(path + r'profile', ProfileViewSet)
|
||||||
|
router.register(path + r'club', ClubViewSet)
|
||||||
|
router.register(path + r'role', RoleViewSet)
|
||||||
|
router.register(path + r'membership', MembershipViewSet)
|
@ -2,17 +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 .models import Profile, Club, Role, Membership
|
from member.models import Profile, Club, Role, Membership
|
||||||
from rest_framework import serializers, viewsets
|
from .serializers import ProfileSerializer, ClubSerializer, RoleSerializer, MembershipSerializer
|
||||||
|
from rest_framework import viewsets
|
||||||
class ProfileSerializer(serializers.HyperlinkedModelSerializer):
|
|
||||||
"""
|
|
||||||
REST API Serializer for Profiles.
|
|
||||||
The djangorestframework plugin will analyse the model `Profile` and parse all fields in the API.
|
|
||||||
"""
|
|
||||||
class Meta:
|
|
||||||
model = Profile
|
|
||||||
fields = '__all__'
|
|
||||||
|
|
||||||
|
|
||||||
class ProfileViewSet(viewsets.ModelViewSet):
|
class ProfileViewSet(viewsets.ModelViewSet):
|
||||||
@ -25,16 +17,6 @@ class ProfileViewSet(viewsets.ModelViewSet):
|
|||||||
serializer_class = ProfileSerializer
|
serializer_class = ProfileSerializer
|
||||||
|
|
||||||
|
|
||||||
class ClubSerializer(serializers.HyperlinkedModelSerializer):
|
|
||||||
"""
|
|
||||||
REST API Serializer for Clubs.
|
|
||||||
The djangorestframework plugin will analyse the model `Club` and parse all fields in the API.
|
|
||||||
"""
|
|
||||||
class Meta:
|
|
||||||
model = Club
|
|
||||||
fields = '__all__'
|
|
||||||
|
|
||||||
|
|
||||||
class ClubViewSet(viewsets.ModelViewSet):
|
class ClubViewSet(viewsets.ModelViewSet):
|
||||||
"""
|
"""
|
||||||
REST API View set.
|
REST API View set.
|
||||||
@ -45,16 +27,6 @@ class ClubViewSet(viewsets.ModelViewSet):
|
|||||||
serializer_class = ClubSerializer
|
serializer_class = ClubSerializer
|
||||||
|
|
||||||
|
|
||||||
class RoleSerializer(serializers.HyperlinkedModelSerializer):
|
|
||||||
"""
|
|
||||||
REST API Serializer for Roles.
|
|
||||||
The djangorestframework plugin will analyse the model `Role` and parse all fields in the API.
|
|
||||||
"""
|
|
||||||
class Meta:
|
|
||||||
model = Role
|
|
||||||
fields = '__all__'
|
|
||||||
|
|
||||||
|
|
||||||
class RoleViewSet(viewsets.ModelViewSet):
|
class RoleViewSet(viewsets.ModelViewSet):
|
||||||
"""
|
"""
|
||||||
REST API View set.
|
REST API View set.
|
||||||
@ -65,16 +37,6 @@ class RoleViewSet(viewsets.ModelViewSet):
|
|||||||
serializer_class = RoleSerializer
|
serializer_class = RoleSerializer
|
||||||
|
|
||||||
|
|
||||||
class MembershipSerializer(serializers.HyperlinkedModelSerializer):
|
|
||||||
"""
|
|
||||||
REST API Serializer for Memberships.
|
|
||||||
The djangorestframework plugin will analyse the model `Memberships` and parse all fields in the API.
|
|
||||||
"""
|
|
||||||
class Meta:
|
|
||||||
model = Membership
|
|
||||||
fields = '__all__'
|
|
||||||
|
|
||||||
|
|
||||||
class MembershipViewSet(viewsets.ModelViewSet):
|
class MembershipViewSet(viewsets.ModelViewSet):
|
||||||
"""
|
"""
|
||||||
REST API View set.
|
REST API View set.
|
||||||
@ -83,4 +45,3 @@ class MembershipViewSet(viewsets.ModelViewSet):
|
|||||||
"""
|
"""
|
||||||
queryset = Membership.objects.all()
|
queryset = Membership.objects.all()
|
||||||
serializer_class = MembershipSerializer
|
serializer_class = MembershipSerializer
|
||||||
|
|
@ -2,9 +2,10 @@
|
|||||||
# 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 .models.notes import Note, NoteClub, NoteSpecial, NoteUser
|
from note.models.notes import Note, NoteClub, NoteSpecial, NoteUser
|
||||||
from .models.transactions import TransactionTemplate, Transaction, MembershipTransaction
|
from note.models.transactions import TransactionTemplate, Transaction, MembershipTransaction
|
||||||
from rest_framework import serializers, viewsets
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
|
||||||
class NoteSerializer(serializers.HyperlinkedModelSerializer):
|
class NoteSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
"""
|
"""
|
||||||
@ -16,16 +17,6 @@ class NoteSerializer(serializers.HyperlinkedModelSerializer):
|
|||||||
fields = ('balance', 'is_active', 'display_image', 'created_at',)
|
fields = ('balance', 'is_active', 'display_image', 'created_at',)
|
||||||
|
|
||||||
|
|
||||||
class NoteViewSet(viewsets.ModelViewSet):
|
|
||||||
"""
|
|
||||||
REST API View set.
|
|
||||||
The djangorestframework plugin will get all `Note` objects, serialize it to JSON with the given serializer,
|
|
||||||
then render it on /api/note/note/
|
|
||||||
"""
|
|
||||||
queryset = Note.objects.all()
|
|
||||||
serializer_class = NoteSerializer
|
|
||||||
|
|
||||||
|
|
||||||
class NoteClubSerializer(serializers.HyperlinkedModelSerializer):
|
class NoteClubSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
"""
|
"""
|
||||||
REST API Serializer for Club's notes.
|
REST API Serializer for Club's notes.
|
||||||
@ -56,16 +47,6 @@ class NoteSpecialSerializer(serializers.HyperlinkedModelSerializer):
|
|||||||
fields = ('balance', 'is_active', 'display_image', 'created_at', 'club', 'special_type',)
|
fields = ('balance', 'is_active', 'display_image', 'created_at', 'club', 'special_type',)
|
||||||
|
|
||||||
|
|
||||||
class NoteSpecialViewSet(viewsets.ModelViewSet):
|
|
||||||
"""
|
|
||||||
REST API View set.
|
|
||||||
The djangorestframework plugin will get all `NoteSpecial` objects, serialize it to JSON with the given serializer,
|
|
||||||
then render it on /api/note/special/
|
|
||||||
"""
|
|
||||||
queryset = NoteSpecial.objects.all()
|
|
||||||
serializer_class = NoteSpecialSerializer
|
|
||||||
|
|
||||||
|
|
||||||
class NoteUserSerializer(serializers.HyperlinkedModelSerializer):
|
class NoteUserSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
"""
|
"""
|
||||||
REST API Serializer for User's notes.
|
REST API Serializer for User's notes.
|
||||||
@ -76,16 +57,6 @@ class NoteUserSerializer(serializers.HyperlinkedModelSerializer):
|
|||||||
fields = ('balance', 'is_active', 'display_image', 'created_at', 'user',)
|
fields = ('balance', 'is_active', 'display_image', 'created_at', 'user',)
|
||||||
|
|
||||||
|
|
||||||
class NoteUserViewSet(viewsets.ModelViewSet):
|
|
||||||
"""
|
|
||||||
REST API View set.
|
|
||||||
The djangorestframework plugin will get all `NoteUser` objects, serialize it to JSON with the given serializer,
|
|
||||||
then render it on /api/note/user/
|
|
||||||
"""
|
|
||||||
queryset = NoteUser.objects.all()
|
|
||||||
serializer_class = NoteUserSerializer
|
|
||||||
|
|
||||||
|
|
||||||
class TransactionTemplateSerializer(serializers.HyperlinkedModelSerializer):
|
class TransactionTemplateSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
"""
|
"""
|
||||||
REST API Serializer for Transaction templates.
|
REST API Serializer for Transaction templates.
|
||||||
@ -96,16 +67,6 @@ class TransactionTemplateSerializer(serializers.HyperlinkedModelSerializer):
|
|||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
class TransactionTemplateViewSet(viewsets.ModelViewSet):
|
|
||||||
"""
|
|
||||||
REST API View set.
|
|
||||||
The djangorestframework plugin will get all `TransactionTemplate` objects, serialize it to JSON with the given serializer,
|
|
||||||
then render it on /api/note/transaction/template/
|
|
||||||
"""
|
|
||||||
queryset = TransactionTemplate.objects.all()
|
|
||||||
serializer_class = TransactionTemplateSerializer
|
|
||||||
|
|
||||||
|
|
||||||
class TransactionSerializer(serializers.HyperlinkedModelSerializer):
|
class TransactionSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
"""
|
"""
|
||||||
REST API Serializer for Transactions.
|
REST API Serializer for Transactions.
|
||||||
@ -116,16 +77,6 @@ class TransactionSerializer(serializers.HyperlinkedModelSerializer):
|
|||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
class TransactionViewSet(viewsets.ModelViewSet):
|
|
||||||
"""
|
|
||||||
REST API View set.
|
|
||||||
The djangorestframework plugin will get all `Transaction` objects, serialize it to JSON with the given serializer,
|
|
||||||
then render it on /api/note/transaction/transaction/
|
|
||||||
"""
|
|
||||||
queryset = Transaction.objects.all()
|
|
||||||
serializer_class = TransactionSerializer
|
|
||||||
|
|
||||||
|
|
||||||
class MembershipTransactionSerializer(serializers.HyperlinkedModelSerializer):
|
class MembershipTransactionSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
"""
|
"""
|
||||||
REST API Serializer for Membership transactions.
|
REST API Serializer for Membership transactions.
|
||||||
@ -134,13 +85,3 @@ class MembershipTransactionSerializer(serializers.HyperlinkedModelSerializer):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = MembershipTransaction
|
model = MembershipTransaction
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
class MembershipTransactionViewSet(viewsets.ModelViewSet):
|
|
||||||
"""
|
|
||||||
REST API View set.
|
|
||||||
The djangorestframework plugin will get all `MembershipTransaction` objects, serialize it to JSON with the given serializer,
|
|
||||||
then render it on /api/note/transaction/membership/
|
|
||||||
"""
|
|
||||||
queryset = MembershipTransaction.objects.all()
|
|
||||||
serializer_class = MembershipTransactionSerializer
|
|
20
apps/api/note/urls.py
Normal file
20
apps/api/note/urls.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# -*- mode: python; coding: utf-8 -*-
|
||||||
|
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
from .views import NoteViewSet, NoteClubViewSet, NoteUserViewSet, NoteSpecialViewSet, \
|
||||||
|
TransactionViewSet, TransactionTemplateViewSet, MembershipTransactionViewSet
|
||||||
|
|
||||||
|
|
||||||
|
def register_note_urls(router, path):
|
||||||
|
"""
|
||||||
|
Configure router for Note REST API.
|
||||||
|
"""
|
||||||
|
router.register(path + r'note', NoteViewSet)
|
||||||
|
router.register(path + r'club', NoteClubViewSet)
|
||||||
|
router.register(path + r'user', NoteUserViewSet)
|
||||||
|
router.register(path + r'special', NoteSpecialViewSet)
|
||||||
|
|
||||||
|
router.register(path + r'transaction/transaction', TransactionViewSet)
|
||||||
|
router.register(path + r'transaction/template', TransactionTemplateViewSet)
|
||||||
|
router.register(path + r'transaction/membership', MembershipTransactionViewSet)
|
79
apps/api/note/views.py
Normal file
79
apps/api/note/views.py
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
# -*- mode: python; coding: utf-8 -*-
|
||||||
|
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
from note.models.notes import Note, NoteClub, NoteSpecial, NoteUser
|
||||||
|
from note.models.transactions import TransactionTemplate, Transaction, MembershipTransaction
|
||||||
|
from .serializers import NoteSerializer, NoteClubSerializer, NoteSpecialSerializer, NoteUserSerializer, \
|
||||||
|
TransactionTemplateSerializer, TransactionSerializer, MembershipTransactionSerializer
|
||||||
|
from rest_framework import viewsets
|
||||||
|
|
||||||
|
|
||||||
|
class NoteViewSet(viewsets.ModelViewSet):
|
||||||
|
"""
|
||||||
|
REST API View set.
|
||||||
|
The djangorestframework plugin will get all `Note` objects, serialize it to JSON with the given serializer,
|
||||||
|
then render it on /api/note/note/
|
||||||
|
"""
|
||||||
|
queryset = Note.objects.all()
|
||||||
|
serializer_class = NoteSerializer
|
||||||
|
|
||||||
|
|
||||||
|
class NoteClubViewSet(viewsets.ModelViewSet):
|
||||||
|
"""
|
||||||
|
REST API View set.
|
||||||
|
The djangorestframework plugin will get all `NoteClub` objects, serialize it to JSON with the given serializer,
|
||||||
|
then render it on /api/note/club/
|
||||||
|
"""
|
||||||
|
queryset = NoteClub.objects.all()
|
||||||
|
serializer_class = NoteClubSerializer
|
||||||
|
|
||||||
|
|
||||||
|
class NoteSpecialViewSet(viewsets.ModelViewSet):
|
||||||
|
"""
|
||||||
|
REST API View set.
|
||||||
|
The djangorestframework plugin will get all `NoteSpecial` objects, serialize it to JSON with the given serializer,
|
||||||
|
then render it on /api/note/special/
|
||||||
|
"""
|
||||||
|
queryset = NoteSpecial.objects.all()
|
||||||
|
serializer_class = NoteSpecialSerializer
|
||||||
|
|
||||||
|
|
||||||
|
class NoteUserViewSet(viewsets.ModelViewSet):
|
||||||
|
"""
|
||||||
|
REST API View set.
|
||||||
|
The djangorestframework plugin will get all `NoteUser` objects, serialize it to JSON with the given serializer,
|
||||||
|
then render it on /api/note/user/
|
||||||
|
"""
|
||||||
|
queryset = NoteUser.objects.all()
|
||||||
|
serializer_class = NoteUserSerializer
|
||||||
|
|
||||||
|
|
||||||
|
class TransactionTemplateViewSet(viewsets.ModelViewSet):
|
||||||
|
"""
|
||||||
|
REST API View set.
|
||||||
|
The djangorestframework plugin will get all `TransactionTemplate` objects, serialize it to JSON with the given serializer,
|
||||||
|
then render it on /api/note/transaction/template/
|
||||||
|
"""
|
||||||
|
queryset = TransactionTemplate.objects.all()
|
||||||
|
serializer_class = TransactionTemplateSerializer
|
||||||
|
|
||||||
|
|
||||||
|
class TransactionViewSet(viewsets.ModelViewSet):
|
||||||
|
"""
|
||||||
|
REST API View set.
|
||||||
|
The djangorestframework plugin will get all `Transaction` objects, serialize it to JSON with the given serializer,
|
||||||
|
then render it on /api/note/transaction/transaction/
|
||||||
|
"""
|
||||||
|
queryset = Transaction.objects.all()
|
||||||
|
serializer_class = TransactionSerializer
|
||||||
|
|
||||||
|
|
||||||
|
class MembershipTransactionViewSet(viewsets.ModelViewSet):
|
||||||
|
"""
|
||||||
|
REST API View set.
|
||||||
|
The djangorestframework plugin will get all `MembershipTransaction` objects, serialize it to JSON with the given serializer,
|
||||||
|
then render it on /api/note/transaction/membership/
|
||||||
|
"""
|
||||||
|
queryset = MembershipTransaction.objects.all()
|
||||||
|
serializer_class = MembershipTransactionSerializer
|
@ -5,10 +5,9 @@
|
|||||||
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 member.serializers import ProfileViewSet, ClubViewSet, RoleViewSet, MembershipViewSet
|
from .activity.urls import register_activity_urls
|
||||||
from activity.serializers import ActivityTypeViewSet, ActivityViewSet, GuestViewSet
|
from .members.urls import register_members_urls
|
||||||
from note.serializers import NoteViewSet, NoteClubViewSet, NoteUserViewSet, NoteSpecialViewSet, \
|
from .note.urls import register_note_urls
|
||||||
TransactionViewSet, TransactionTemplateViewSet, MembershipTransactionViewSet
|
|
||||||
|
|
||||||
class UserSerializer(serializers.HyperlinkedModelSerializer):
|
class UserSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
"""
|
"""
|
||||||
@ -33,25 +32,13 @@ router = routers.DefaultRouter()
|
|||||||
router.register(r'users', UserViewSet)
|
router.register(r'users', UserViewSet)
|
||||||
|
|
||||||
# Routers for members app
|
# Routers for members app
|
||||||
router.register(r'members/profile', ProfileViewSet)
|
register_members_urls(router, r'members/')
|
||||||
router.register(r'members/club', ClubViewSet)
|
|
||||||
router.register(r'members/role', RoleViewSet)
|
|
||||||
router.register(r'members/membership', MembershipViewSet)
|
|
||||||
|
|
||||||
# Routers for activity app
|
# Routers for activity app
|
||||||
router.register(r'activity/activity', ActivityViewSet)
|
register_activity_urls(router, r'activity/')
|
||||||
router.register(r'activity/type', ActivityTypeViewSet)
|
|
||||||
router.register(r'activity/guest', GuestViewSet)
|
|
||||||
|
|
||||||
# Routers for note app
|
# Routers for note app
|
||||||
router.register(r'note/note', NoteViewSet)
|
register_note_urls(router, r'note/')
|
||||||
router.register(r'note/club', NoteClubViewSet)
|
|
||||||
router.register(r'note/user', NoteUserViewSet)
|
|
||||||
router.register(r'note/special', NoteSpecialViewSet)
|
|
||||||
|
|
||||||
router.register(r'note/transaction/transaction', TransactionViewSet)
|
|
||||||
router.register(r'note/transaction/template', TransactionTemplateViewSet)
|
|
||||||
router.register(r'note/transaction/membership', MembershipTransactionViewSet)
|
|
||||||
|
|
||||||
# Wire up our API using automatic URL routing.
|
# Wire up our API using automatic URL routing.
|
||||||
# Additionally, we include login URLs for the browsable API.
|
# Additionally, we include login URLs for the browsable API.
|
||||||
|
Loading…
Reference in New Issue
Block a user