Skip to content
Snippets Groups Projects
Commit 0acc2e47 authored by Lucas Brandstaetter's avatar Lucas Brandstaetter
Browse files

Fix event speaker lists in schedule api

parent 67d1554d
Branches
Tags
No related merge requests found
...@@ -148,17 +148,16 @@ class ScheduleEncoder(json.JSONEncoder): ...@@ -148,17 +148,16 @@ class ScheduleEncoder(json.JSONEncoder):
def collect_persons(self, event): def collect_persons(self, event):
persons = [] persons = []
# 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'): if hasattr(event, 'speakers'):
# event is a QuerySet and already fetched speakers # event is a QuerySet and already fetched speakers
persons = list(event.speakers) persons = [speaker.participant for speaker in event.speakers]
else: else:
# direct event lookup -> fetch persons via public_speakers # direct event lookup -> fetch persons via public_speakers
persons = list(event.public_speakers) persons = event.public_speakers
# TODO remove this workaround once imported speakers are stored as participants
if event.additional_data and 'persons' in event.additional_data and len(event.additional_data['persons']) > 0:
persons += event.additional_data['persons']
return [self.encode_person(person) for person in persons] return [self.encode_person(person) for person in persons]
......
...@@ -223,11 +223,12 @@ class Event(TaggedItemMixin, BackendMixin, models.Model): ...@@ -223,11 +223,12 @@ class Event(TaggedItemMixin, BackendMixin, models.Model):
return hub_absolute('plainui:event', event_slug=self.slug, i18n=False) return hub_absolute('plainui:event', event_slug=self.slug, i18n=False)
@property @property
def public_speakers(self): def public_speakers(self) -> list:
"""Returns a list of all public speakers of this event.""" """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) persons.add(self.owner)
return persons return persons
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment