diff --git a/src/api/schedule.py b/src/api/schedule.py index 224c5b7dfa93dc204c57913cf5427a2133dccbd9..56457468d591e2782195fae711039741212364fe 100644 --- a/src/api/schedule.py +++ b/src/api/schedule.py @@ -148,17 +148,16 @@ class ScheduleEncoder(json.JSONEncoder): def collect_persons(self, event): persons = [] + if hasattr(event, 'speakers'): + # event is a QuerySet and already fetched speakers + persons = [speaker.participant for speaker in event.speakers] + else: + # direct event lookup -> fetch persons via public_speakers + persons = event.public_speakers + # TODO remove this workaround once imported speakers are stored as participants - # and have links and biography=description if event.additional_data and 'persons' in event.additional_data and len(event.additional_data['persons']) > 0: - persons = event.additional_data['persons'] - else: - if hasattr(event, 'speakers'): - # event is a QuerySet and already fetched speakers - persons = list(event.speakers) - else: - # direct event lookup -> fetch persons via public_speakers - persons = list(event.public_speakers) + persons += event.additional_data['persons'] return [self.encode_person(person) for person in persons] diff --git a/src/core/models/events.py b/src/core/models/events.py index 875993211d2a201b2c695f9355cfe049cd889dba..c95b67a066bb3ba94f3a343172566c33133d14fc 100644 --- a/src/core/models/events.py +++ b/src/core/models/events.py @@ -223,11 +223,12 @@ class Event(TaggedItemMixin, BackendMixin, models.Model): return hub_absolute('plainui:event', event_slug=self.slug, i18n=False) @property - def public_speakers(self): + def public_speakers(self) -> list: """Returns a list of all public speakers of this event.""" - persons = self.participants.filter(is_public=True, role=EventParticipant.Role.SPEAKER).select_related('participant') + persons = self.participants.filter(is_public=True, role=EventParticipant.Role.SPEAKER).values_list('participant', flat=True) - if self.kind == Event.Kind.SELF_ORGANIZED and self.owner: + # If there is no speaker for an SoS, the owner is automatically added. + if self.kind == Event.Kind.SELF_ORGANIZED and not persons and self.owner: persons.add(self.owner) return persons