mirror of https://gitlab.crans.org/bde/nk20
Add some doc
This commit is contained in:
parent
92fc92ba40
commit
c28884114c
|
@ -6,33 +6,60 @@ from .models import ActivityType, Activity, Guest
|
||||||
from rest_framework import serializers, viewsets
|
from rest_framework import serializers, viewsets
|
||||||
|
|
||||||
class ActivityTypeSerializer(serializers.HyperlinkedModelSerializer):
|
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:
|
class Meta:
|
||||||
model = ActivityType
|
model = ActivityType
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
class ActivityTypeViewSet(viewsets.ModelViewSet):
|
class ActivityTypeViewSet(viewsets.ModelViewSet):
|
||||||
|
"""
|
||||||
|
REST API View set.
|
||||||
|
The djangorestframework plugin will get all `ActivityType` objects, serialize it to JSON with the given serializer,
|
||||||
|
then render it on /api/activity/type/
|
||||||
|
"""
|
||||||
queryset = ActivityType.objects.all()
|
queryset = ActivityType.objects.all()
|
||||||
serializer_class = ActivityTypeSerializer
|
serializer_class = ActivityTypeSerializer
|
||||||
|
|
||||||
|
|
||||||
class ActivitySerializer(serializers.HyperlinkedModelSerializer):
|
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:
|
class Meta:
|
||||||
model = Activity
|
model = Activity
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
class ActivityViewSet(viewsets.ModelViewSet):
|
class ActivityViewSet(viewsets.ModelViewSet):
|
||||||
|
"""
|
||||||
|
REST API View set.
|
||||||
|
The djangorestframework plugin will get all `Activity` objects, serialize it to JSON with the given serializer,
|
||||||
|
then render it on /api/activity/activity/
|
||||||
|
"""
|
||||||
queryset = Activity.objects.all()
|
queryset = Activity.objects.all()
|
||||||
serializer_class = ActivitySerializer
|
serializer_class = ActivitySerializer
|
||||||
|
|
||||||
|
|
||||||
class GuestSerializer(serializers.HyperlinkedModelSerializer):
|
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:
|
class Meta:
|
||||||
model = Guest
|
model = Guest
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
class GuestViewSet(viewsets.ModelViewSet):
|
class GuestViewSet(viewsets.ModelViewSet):
|
||||||
|
"""
|
||||||
|
REST API View set.
|
||||||
|
The djangorestframework plugin will get all `Guest` objects, serialize it to JSON with the given serializer,
|
||||||
|
then render it on /api/activity/guest/
|
||||||
|
"""
|
||||||
queryset = Guest.objects.all()
|
queryset = Guest.objects.all()
|
||||||
serializer_class = GuestSerializer
|
serializer_class = GuestSerializer
|
||||||
|
|
|
@ -11,11 +11,20 @@ from note.serializers import NoteViewSet, NoteClubViewSet, NoteUserViewSet, Note
|
||||||
TransactionViewSet, TransactionTemplateViewSet, MembershipTransactionViewSet
|
TransactionViewSet, TransactionTemplateViewSet, MembershipTransactionViewSet
|
||||||
|
|
||||||
class UserSerializer(serializers.HyperlinkedModelSerializer):
|
class UserSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
"""
|
||||||
|
REST API Serializer for Users.
|
||||||
|
The djangorestframework plugin will analyse the model `User` and parse all fields in the API.
|
||||||
|
"""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = User
|
model = User
|
||||||
fields = ('username', 'first_name', 'last_name', 'email', 'is_staff',)
|
fields = ('username', 'first_name', 'last_name', 'email', 'is_staff',)
|
||||||
|
|
||||||
class UserViewSet(viewsets.ModelViewSet):
|
class UserViewSet(viewsets.ModelViewSet):
|
||||||
|
"""
|
||||||
|
REST API View set.
|
||||||
|
The djangorestframework plugin will get all `User` objects, serialize it to JSON with the given serializer,
|
||||||
|
then render it on /api/users/
|
||||||
|
"""
|
||||||
queryset = User.objects.all()
|
queryset = User.objects.all()
|
||||||
serializer_class = UserSerializer
|
serializer_class = UserSerializer
|
||||||
|
|
||||||
|
@ -23,21 +32,24 @@ class UserViewSet(viewsets.ModelViewSet):
|
||||||
router = routers.DefaultRouter()
|
router = routers.DefaultRouter()
|
||||||
router.register(r'users', UserViewSet)
|
router.register(r'users', UserViewSet)
|
||||||
|
|
||||||
|
# Routers for members app
|
||||||
router.register(r'members/profile', ProfileViewSet)
|
router.register(r'members/profile', ProfileViewSet)
|
||||||
router.register(r'members/club', ClubViewSet)
|
router.register(r'members/club', ClubViewSet)
|
||||||
router.register(r'members/role', RoleViewSet)
|
router.register(r'members/role', RoleViewSet)
|
||||||
router.register(r'members/membership', MembershipViewSet)
|
router.register(r'members/membership', MembershipViewSet)
|
||||||
|
|
||||||
|
# Routers for activity app
|
||||||
router.register(r'activity/activity', ActivityViewSet)
|
router.register(r'activity/activity', ActivityViewSet)
|
||||||
router.register(r'activity/type', ActivityTypeViewSet)
|
router.register(r'activity/type', ActivityTypeViewSet)
|
||||||
router.register(r'activity/guest', GuestViewSet)
|
router.register(r'activity/guest', GuestViewSet)
|
||||||
|
|
||||||
|
# Routers for note app
|
||||||
router.register(r'note/note', NoteViewSet)
|
router.register(r'note/note', NoteViewSet)
|
||||||
router.register(r'note/club', NoteClubViewSet)
|
router.register(r'note/club', NoteClubViewSet)
|
||||||
router.register(r'note/user', NoteUserViewSet)
|
router.register(r'note/user', NoteUserViewSet)
|
||||||
router.register(r'note/special', NoteSpecialViewSet)
|
router.register(r'note/special', NoteSpecialViewSet)
|
||||||
|
|
||||||
router.register(r'note/transaction', TransactionViewSet)
|
router.register(r'note/transaction/transaction', TransactionViewSet)
|
||||||
router.register(r'note/transaction/template', TransactionTemplateViewSet)
|
router.register(r'note/transaction/template', TransactionTemplateViewSet)
|
||||||
router.register(r'note/transaction/membership', MembershipTransactionViewSet)
|
router.register(r'note/transaction/membership', MembershipTransactionViewSet)
|
||||||
|
|
||||||
|
|
|
@ -6,45 +6,81 @@ from .models import Profile, Club, Role, Membership
|
||||||
from rest_framework import serializers, viewsets
|
from rest_framework import serializers, viewsets
|
||||||
|
|
||||||
class ProfileSerializer(serializers.HyperlinkedModelSerializer):
|
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:
|
class Meta:
|
||||||
model = Profile
|
model = Profile
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
class ProfileViewSet(viewsets.ModelViewSet):
|
class ProfileViewSet(viewsets.ModelViewSet):
|
||||||
|
"""
|
||||||
|
REST API View set.
|
||||||
|
The djangorestframework plugin will get all `Profile` objects, serialize it to JSON with the given serializer,
|
||||||
|
then render it on /api/members/profile/
|
||||||
|
"""
|
||||||
queryset = Profile.objects.all()
|
queryset = Profile.objects.all()
|
||||||
serializer_class = ProfileSerializer
|
serializer_class = ProfileSerializer
|
||||||
|
|
||||||
|
|
||||||
class ClubSerializer(serializers.HyperlinkedModelSerializer):
|
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:
|
class Meta:
|
||||||
model = Club
|
model = Club
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
class ClubViewSet(viewsets.ModelViewSet):
|
class ClubViewSet(viewsets.ModelViewSet):
|
||||||
|
"""
|
||||||
|
REST API View set.
|
||||||
|
The djangorestframework plugin will get all `Club` objects, serialize it to JSON with the given serializer,
|
||||||
|
then render it on /api/members/club/
|
||||||
|
"""
|
||||||
queryset = Club.objects.all()
|
queryset = Club.objects.all()
|
||||||
serializer_class = ClubSerializer
|
serializer_class = ClubSerializer
|
||||||
|
|
||||||
|
|
||||||
class RoleSerializer(serializers.HyperlinkedModelSerializer):
|
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:
|
class Meta:
|
||||||
model = Role
|
model = Role
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
class RoleViewSet(viewsets.ModelViewSet):
|
class RoleViewSet(viewsets.ModelViewSet):
|
||||||
|
"""
|
||||||
|
REST API View set.
|
||||||
|
The djangorestframework plugin will get all `Role` objects, serialize it to JSON with the given serializer,
|
||||||
|
then render it on /api/members/role/
|
||||||
|
"""
|
||||||
queryset = Role.objects.all()
|
queryset = Role.objects.all()
|
||||||
serializer_class = RoleSerializer
|
serializer_class = RoleSerializer
|
||||||
|
|
||||||
|
|
||||||
class MembershipSerializer(serializers.HyperlinkedModelSerializer):
|
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:
|
class Meta:
|
||||||
model = Membership
|
model = Membership
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
class MembershipViewSet(viewsets.ModelViewSet):
|
class MembershipViewSet(viewsets.ModelViewSet):
|
||||||
|
"""
|
||||||
|
REST API View set.
|
||||||
|
The djangorestframework plugin will get all `Membership` objects, serialize it to JSON with the given serializer,
|
||||||
|
then render it on /api/members/membership/
|
||||||
|
"""
|
||||||
queryset = Membership.objects.all()
|
queryset = Membership.objects.all()
|
||||||
serializer_class = MembershipSerializer
|
serializer_class = MembershipSerializer
|
||||||
|
|
||||||
|
|
|
@ -7,77 +7,140 @@ from .models.transactions import TransactionTemplate, Transaction, MembershipTra
|
||||||
from rest_framework import serializers, viewsets
|
from rest_framework import serializers, viewsets
|
||||||
|
|
||||||
class NoteSerializer(serializers.HyperlinkedModelSerializer):
|
class NoteSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
"""
|
||||||
|
REST API Serializer for Notes.
|
||||||
|
The djangorestframework plugin will analyse the model `Note` and parse all fields in the API.
|
||||||
|
"""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Note
|
model = Note
|
||||||
fields = ('balance', 'is_active', 'display_image', 'created_at',)
|
fields = ('balance', 'is_active', 'display_image', 'created_at',)
|
||||||
|
|
||||||
|
|
||||||
class NoteViewSet(viewsets.ModelViewSet):
|
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()
|
queryset = Note.objects.all()
|
||||||
serializer_class = NoteSerializer
|
serializer_class = NoteSerializer
|
||||||
|
|
||||||
|
|
||||||
class NoteClubSerializer(serializers.HyperlinkedModelSerializer):
|
class NoteClubSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
"""
|
||||||
|
REST API Serializer for Club's notes.
|
||||||
|
The djangorestframework plugin will analyse the model `NoteClub` and parse all fields in the API.
|
||||||
|
"""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = NoteClub
|
model = NoteClub
|
||||||
fields = ('balance', 'is_active', 'display_image', 'created_at', 'club',)
|
fields = ('balance', 'is_active', 'display_image', 'created_at', 'club',)
|
||||||
|
|
||||||
|
|
||||||
class NoteClubViewSet(viewsets.ModelViewSet):
|
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()
|
queryset = NoteClub.objects.all()
|
||||||
serializer_class = NoteClubSerializer
|
serializer_class = NoteClubSerializer
|
||||||
|
|
||||||
|
|
||||||
class NoteSpecialSerializer(serializers.HyperlinkedModelSerializer):
|
class NoteSpecialSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
"""
|
||||||
|
REST API Serializer for special notes.
|
||||||
|
The djangorestframework plugin will analyse the model `NoteSpecial` and parse all fields in the API.
|
||||||
|
"""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = NoteSpecial
|
model = NoteSpecial
|
||||||
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):
|
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()
|
queryset = NoteSpecial.objects.all()
|
||||||
serializer_class = NoteSpecialSerializer
|
serializer_class = NoteSpecialSerializer
|
||||||
|
|
||||||
|
|
||||||
class NoteUserSerializer(serializers.HyperlinkedModelSerializer):
|
class NoteUserSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
"""
|
||||||
|
REST API Serializer for User's notes.
|
||||||
|
The djangorestframework plugin will analyse the model `NoteUser` and parse all fields in the API.
|
||||||
|
"""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = NoteUser
|
model = NoteUser
|
||||||
fields = ('balance', 'is_active', 'display_image', 'created_at', 'user',)
|
fields = ('balance', 'is_active', 'display_image', 'created_at', 'user',)
|
||||||
|
|
||||||
|
|
||||||
class NoteUserViewSet(viewsets.ModelViewSet):
|
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()
|
queryset = NoteUser.objects.all()
|
||||||
serializer_class = NoteUserSerializer
|
serializer_class = NoteUserSerializer
|
||||||
|
|
||||||
|
|
||||||
class TransactionTemplateSerializer(serializers.HyperlinkedModelSerializer):
|
class TransactionTemplateSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
"""
|
||||||
|
REST API Serializer for Transaction templates.
|
||||||
|
The djangorestframework plugin will analyse the model `TransactionTemplate` and parse all fields in the API.
|
||||||
|
"""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = TransactionTemplate
|
model = TransactionTemplate
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
class TransactionTemplateViewSet(viewsets.ModelViewSet):
|
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()
|
queryset = TransactionTemplate.objects.all()
|
||||||
serializer_class = TransactionTemplateSerializer
|
serializer_class = TransactionTemplateSerializer
|
||||||
|
|
||||||
|
|
||||||
class TransactionSerializer(serializers.HyperlinkedModelSerializer):
|
class TransactionSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
"""
|
||||||
|
REST API Serializer for Transactions.
|
||||||
|
The djangorestframework plugin will analyse the model `Transaction` and parse all fields in the API.
|
||||||
|
"""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Transaction
|
model = Transaction
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
class TransactionViewSet(viewsets.ModelViewSet):
|
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()
|
queryset = Transaction.objects.all()
|
||||||
serializer_class = TransactionSerializer
|
serializer_class = TransactionSerializer
|
||||||
|
|
||||||
|
|
||||||
class MembershipTransactionSerializer(serializers.HyperlinkedModelSerializer):
|
class MembershipTransactionSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
"""
|
||||||
|
REST API Serializer for Membership transactions.
|
||||||
|
The djangorestframework plugin will analyse the model `MembershipTransaction` and parse all fields in the API.
|
||||||
|
"""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = MembershipTransaction
|
model = MembershipTransaction
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
class MembershipTransactionViewSet(viewsets.ModelViewSet):
|
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()
|
queryset = MembershipTransaction.objects.all()
|
||||||
serializer_class = MembershipTransactionSerializer
|
serializer_class = MembershipTransactionSerializer
|
||||||
|
|
Loading…
Reference in New Issue