Skip to content

Commit

Permalink
Merge pull request #3697 from webkom/include-user-reg-to-event-list
Browse files Browse the repository at this point in the history
  • Loading branch information
ivarnakken authored Dec 11, 2024
2 parents 6dbdcfd + 01bf627 commit c52c6f1
Showing 1 changed file with 7 additions and 0 deletions.
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

0 comments on commit c52c6f1

Please sign in to comment.