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

Include user reg to events in event list #3697

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lego/apps/events/serializers/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down