Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Individual reactions #3520

Merged
merged 4 commits into from
Nov 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions lego/apps/meetings/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from lego.apps.content.fields import ContentSerializerField
from lego.apps.meetings import constants
from lego.apps.meetings.models import Meeting, MeetingInvitation
from lego.apps.reactions.models import Reaction
from lego.apps.users.fields import PublicUserField
from lego.apps.users.models import AbakusGroup, User
from lego.apps.users.serializers.users import PublicUserSerializer
Expand Down Expand Up @@ -36,6 +37,15 @@ class Meta:
fields = ("status",)


class ReactionsSerializer(serializers.ModelSerializer):
author = PublicUserSerializer(read_only=True, source="created_by")

class Meta:
model = Reaction
fields = ("id", "emoji", "author")
read_only = True


class MeetingGroupInvite(serializers.Serializer):
group = PrimaryKeyRelatedFieldNoPKOpt(queryset=AbakusGroup.objects.all())

Expand Down Expand Up @@ -63,6 +73,7 @@ class MeetingDetailSerializer(BasisModelSerializer):
comments = CommentSerializer(read_only=True, many=True)
content_target = CharField(read_only=True)
reactions_grouped = serializers.SerializerMethodField()
reactions = ReactionsSerializer(many=True, read_only=True)

def get_reactions_grouped(self, obj):
user = self.context["request"].user
Expand All @@ -85,6 +96,7 @@ class Meta:
"content_target",
"mazemap_poi",
"reactions_grouped",
"reactions",
)
read_only = True

Expand Down