Repository: webkom/lego

Issue:
Meetings contains the report property at the list endpoint



Discussion:

Resolving patch:
diff --git a/lego/apps/meetings/serializers.py b/lego/apps/meetings/serializers.py
--- a/lego/apps/meetings/serializers.py
+++ b/lego/apps/meetings/serializers.py
@@ -45,7 +45,7 @@ class MeetingBulkInvite(serializers.Serializer):
     )
 
 
-class MeetingSerializer(BasisModelSerializer):
+class MeetingDetailSerializer(BasisModelSerializer):
     invitations = MeetingInvitationSerializer(many=True, read_only=True)
     report = ContentSerializerField()
     report_author = PublicUserField(queryset=User.objects.all(), allow_null=True, required=False)
@@ -63,3 +63,14 @@ def create(self, validated_data):
         owner = validated_data['current_user']
         meeting.invite_user(owner, owner)
         return meeting
+
+
+class MeetingListSerializer(BasisModelSerializer):
+    report_author = PublicUserField(queryset=User.objects.all(), allow_null=True, required=False)
+    created_by = PublicUserField(read_only=True)
+
+    class Meta:
+        model = Meeting
+        fields = (
+            'id', 'created_by', 'title', 'location', 'start_time', 'end_time', 'report_author'
+        )
diff --git a/lego/apps/meetings/views.py b/lego/apps/meetings/views.py
--- a/lego/apps/meetings/views.py
+++ b/lego/apps/meetings/views.py
@@ -6,8 +6,8 @@
 from lego.apps.meetings.filters import MeetingFilterSet
 from lego.apps.meetings.models import Meeting, MeetingInvitation
 from lego.apps.meetings.serializers import (
-    MeetingBulkInvite, MeetingGroupInvite, MeetingInvitationSerializer,
-    MeetingInvitationUpdateSerializer, MeetingSerializer, MeetingUserInvite
+    MeetingBulkInvite, MeetingDetailSerializer, MeetingGroupInvite, MeetingInvitationSerializer,
+    MeetingInvitationUpdateSerializer, MeetingListSerializer, MeetingUserInvite
 )
 from lego.apps.permissions.api.views import AllowedPermissionsMixin
 from lego.apps.permissions.utils import get_permission_handler
@@ -16,7 +16,7 @@
 class MeetingViewSet(AllowedPermissionsMixin, viewsets.ModelViewSet):
 
     filter_class = MeetingFilterSet
-    serializer_class = MeetingSerializer
+    serializer_class = MeetingDetailSerializer
 
     def get_queryset(self):
         permission_handler = get_permission_handler(Meeting)
@@ -30,6 +30,11 @@ def get_ordering(self):
             return ordering
         return 'start_time'
 
+    def get_serializer_class(self):
+        if self.action == 'list':
+            return MeetingListSerializer
+        return super().get_serializer_class()
+
     @decorators.detail_route(methods=['POST'], serializer_class=MeetingUserInvite)
     def invite_user(self, request, *args, **kwargs):
         meeting = self.get_object()
diff --git a/lego/apps/notifications/serializers.py b/lego/apps/notifications/serializers.py
--- a/lego/apps/notifications/serializers.py
+++ b/lego/apps/notifications/serializers.py
@@ -1,7 +1,7 @@
 from rest_framework import serializers
 
 from lego.apps.events.serializers.events import EventReadSerializer
-from lego.apps.meetings.serializers import MeetingSerializer
+from lego.apps.meetings.serializers import MeetingDetailSerializer
 from lego.apps.users.serializers.abakus_groups import PublicAbakusGroupSerializer
 from lego.apps.users.serializers.users import PublicUserSerializer
 from lego.utils.serializers import BasisModelSerializer
@@ -31,7 +31,7 @@ class AnnouncementListSerializer(BasisModelSerializer):
     users = PublicUserSerializer(many=True, read_only=True)
     groups = PublicAbakusGroupSerializer(many=True, read_only=True)
     events = EventReadSerializer(many=True, read_only=True)
-    meetings = MeetingSerializer(many=True, read_only=True)
+    meetings = MeetingDetailSerializer(many=True, read_only=True)
 
     class Meta:
         model = Announcement


Test patch: