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