From 01bf6273d1489550267c7f88b63d4a78f970a90c Mon Sep 17 00:00:00 2001 From: Ivar Nakken Date: Wed, 11 Dec 2024 13:49:49 +0100 Subject: [PATCH] Include user reg to events in event list --- lego/apps/events/serializers/events.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lego/apps/events/serializers/events.py b/lego/apps/events/serializers/events.py index c7f3aa59a..dc62cf616 100644 --- a/lego/apps/events/serializers/events.py +++ b/lego/apps/events/serializers/events.py @@ -84,6 +84,7 @@ class EventReadSerializer( is_admitted = IsAdmittedField() registration_count = RegistrationCountField() total_capacity = TotalCapacityField() + user_reg = serializers.SerializerMethodField() responsible_users = PublicUserField( queryset=User.objects.all(), allow_null=False, @@ -116,9 +117,15 @@ class Meta: "is_priced", "responsible_users", "is_foreign_language", + "user_reg", ) + ObjectPermissionsSerializerMixin.Meta.fields read_only = True + def get_user_reg(self, event): + if hasattr(event, "user_reg") and event.user_reg: + return RegistrationReadSerializer(event.user_reg[0]).data + return None + class EventReadDetailedSerializer( TagSerializerMixin, BasisModelSerializer, ObjectPermissionsSerializerMixin