diff --git a/apps/api/activity/views.py b/apps/api/activity/views.py index af2f0fe1..de6b8979 100644 --- a/apps/api/activity/views.py +++ b/apps/api/activity/views.py @@ -2,9 +2,11 @@ # Copyright (C) 2018-2020 by BDE ENS Paris-Saclay # SPDX-License-Identifier: GPL-3.0-or-later +from rest_framework import viewsets + from activity.models import ActivityType, Activity, Guest from .serializers import ActivityTypeSerializer, ActivitySerializer, GuestSerializer -from rest_framework import viewsets + class ActivityTypeViewSet(viewsets.ModelViewSet): """ @@ -33,4 +35,4 @@ class GuestViewSet(viewsets.ModelViewSet): then render it on /api/activity/guest/ """ queryset = Guest.objects.all() - serializer_class = GuestSerializer \ No newline at end of file + serializer_class = GuestSerializer diff --git a/apps/api/members/views.py b/apps/api/members/views.py index 9755151e..06b95dcc 100644 --- a/apps/api/members/views.py +++ b/apps/api/members/views.py @@ -2,9 +2,10 @@ # Copyright (C) 2018-2020 by BDE ENS Paris-Saclay # SPDX-License-Identifier: GPL-3.0-or-later +from rest_framework import viewsets + from member.models import Profile, Club, Role, Membership from .serializers import ProfileSerializer, ClubSerializer, RoleSerializer, MembershipSerializer -from rest_framework import viewsets class ProfileViewSet(viewsets.ModelViewSet): diff --git a/apps/api/note/urls.py b/apps/api/note/urls.py index 0c25785d..4ef14e28 100644 --- a/apps/api/note/urls.py +++ b/apps/api/note/urls.py @@ -2,8 +2,8 @@ # Copyright (C) 2018-2020 by BDE ENS Paris-Saclay # SPDX-License-Identifier: GPL-3.0-or-later -from .views import NoteViewSet, NotePolymorphicViewSet, NoteClubViewSet, NoteUserViewSet, NoteSpecialViewSet, AliasViewSet, \ - TransactionViewSet, TransactionTemplateViewSet, MembershipTransactionViewSet +from .views import NotePolymorphicViewSet, AliasViewSet, \ + TransactionViewSet, TransactionTemplateViewSet, MembershipTransactionViewSet def register_note_urls(router, path): diff --git a/apps/api/note/views.py b/apps/api/note/views.py index 63ab08e5..07bc9fd2 100644 --- a/apps/api/note/views.py +++ b/apps/api/note/views.py @@ -3,11 +3,13 @@ # SPDX-License-Identifier: GPL-3.0-or-later from django.db.models import Q +from rest_framework import viewsets + from note.models.notes import Note, NoteClub, NoteSpecial, NoteUser, Alias from note.models.transactions import TransactionTemplate, Transaction, MembershipTransaction -from .serializers import NoteSerializer, NotePolymorphicSerializer, NoteClubSerializer, NoteSpecialSerializer, NoteUserSerializer, AliasSerializer, \ - TransactionTemplateSerializer, TransactionSerializer, MembershipTransactionSerializer -from rest_framework import viewsets +from .serializers import NoteSerializer, NotePolymorphicSerializer, NoteClubSerializer, NoteSpecialSerializer, \ + NoteUserSerializer, AliasSerializer, \ + TransactionTemplateSerializer, TransactionSerializer, MembershipTransactionSerializer class NoteViewSet(viewsets.ModelViewSet): diff --git a/apps/api/urls.py b/apps/api/urls.py index 60758050..9c64abed 100644 --- a/apps/api/urls.py +++ b/apps/api/urls.py @@ -10,15 +10,18 @@ from .activity.urls import register_activity_urls from .members.urls import register_members_urls from .note.urls import register_note_urls + class UserSerializer(serializers.ModelSerializer): """ REST API Serializer for Users. The djangorestframework plugin will analyse the model `User` and parse all fields in the API. """ + class Meta: model = User exclude = ('password', 'groups', 'user_permissions',) + class UserViewSet(viewsets.ModelViewSet): """ REST API View set. @@ -28,6 +31,7 @@ class UserViewSet(viewsets.ModelViewSet): queryset = User.objects.all() serializer_class = UserSerializer + # Routers provide an easy way of automatically determining the URL conf. router = routers.DefaultRouter() router.register('user', UserViewSet) @@ -46,4 +50,4 @@ register_note_urls(router, 'note') urlpatterns = [ url('^', include(router.urls)), url('^api-auth/', include('rest_framework.urls', namespace='rest_framework')) -] \ No newline at end of file +] diff --git a/requirements.txt b/requirements.txt index 3be0a4d2..d103764e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -23,4 +23,4 @@ requests==2.22.0 requests-oauthlib==1.2.0 six==1.12.0 sqlparse==0.3.0 -urllib3==1.25.3 \ No newline at end of file +urllib3==1.25.3