Skip to content
Snippets Groups Projects
Commit 4e5c59f0 authored by Lucas Brandstaetter's avatar Lucas Brandstaetter Committed by HeJ
Browse files

Fix speaker list append

parent b2362410
No related branches found
No related tags found
No related merge requests found
...@@ -42,8 +42,8 @@ class ScheduleTest(TestCase): ...@@ -42,8 +42,8 @@ class ScheduleTest(TestCase):
self.token.save() self.token.save()
def _test_schedule_export(self, url_suffix: str, expected_content_type: str, content_parser): def _test_schedule_export(self, url_suffix: str, expected_content_type: str, content_parser):
url = reverse('api:conference-schedule') + url_suffix schedule_url = reverse('api:conference-schedule') + url_suffix
resp = self.client.get(url) resp = self.client.get(schedule_url)
self.assertEqual(200, resp.status_code) self.assertEqual(200, resp.status_code)
self.assertEqual(resp['Content-Type'], expected_content_type) self.assertEqual(resp['Content-Type'], expected_content_type)
content_str = resp.content.decode('utf-8') content_str = resp.content.decode('utf-8')
...@@ -68,9 +68,17 @@ class ScheduleTest(TestCase): ...@@ -68,9 +68,17 @@ class ScheduleTest(TestCase):
schedule_duration=timedelta(minutes=42), schedule_duration=timedelta(minutes=42),
) )
ev1.save() ev1.save()
event_url = reverse('api:event-schedule', kwargs={'pk': ev1.pk})
# check that event is in the output # check that event is in the output
resp = self.client.get(url) resp = self.client.get(schedule_url)
self.assertEqual(200, resp.status_code)
content_str = resp.content.decode('utf-8')
content_parser(content_str)
self.assertIn(ev1.name, content_str)
if url_suffix == '.json':
resp = self.client.get(event_url)
self.assertEqual(200, resp.status_code) self.assertEqual(200, resp.status_code)
content_str = resp.content.decode('utf-8') content_str = resp.content.decode('utf-8')
content_parser(content_str) content_parser(content_str)
...@@ -99,7 +107,7 @@ class ScheduleTest(TestCase): ...@@ -99,7 +107,7 @@ class ScheduleTest(TestCase):
ev2b.save() ev2b.save()
# check that none of the new events are in the output # check that none of the new events are in the output
resp = self.client.get(url) resp = self.client.get(schedule_url)
self.assertEqual(200, resp.status_code) self.assertEqual(200, resp.status_code)
content_str = resp.content.decode('utf-8') content_str = resp.content.decode('utf-8')
content_parser(content_str) content_parser(content_str)
...@@ -107,6 +115,40 @@ class ScheduleTest(TestCase): ...@@ -107,6 +115,40 @@ class ScheduleTest(TestCase):
self.assertNotIn(ev2a.name, content_str) self.assertNotIn(ev2a.name, content_str)
self.assertNotIn(ev2b.name, content_str) self.assertNotIn(ev2b.name, content_str)
# Add addintional data to event 1 to append the persons
ev1.additional_data = {
'id': 12334,
'url': 'https://fahrplan.events.ccc.de/congress/2023/fahrplan/events/12334.html',
'slug': 'Vogc-12334-eroffnung',
'type': 'lecture',
'track': 'CCC',
'persons': [
{
'id': 987654,
'guid': 'aaaaaaaa-0000-000d-d00d-1d1d1d1d1d1d',
'name': 'arthur',
'links': [],
'biography': 'Test speaker',
'public_name': 'arthur',
}
],
}
ev1.save()
# check that event is in the output
resp = self.client.get(schedule_url)
self.assertEqual(200, resp.status_code)
content_str = resp.content.decode('utf-8')
content_parser(content_str)
self.assertIn(ev1.name, content_str)
if url_suffix == '.json':
resp = self.client.get(event_url)
self.assertEqual(200, resp.status_code)
content_str = resp.content.decode('utf-8')
content_parser(content_str)
self.assertIn(ev1.name, content_str)
def test_export_json(self): def test_export_json(self):
self._test_schedule_export('.json', 'application/json', json.loads) self._test_schedule_export('.json', 'application/json', json.loads)
......
...@@ -227,9 +227,7 @@ class Event(TaggedItemMixin, BackendMixin, models.Model): ...@@ -227,9 +227,7 @@ class Event(TaggedItemMixin, BackendMixin, models.Model):
@property @property
def public_speakers(self) -> list: 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 = ( persons = [participant.participant for participant in self.participants.filter(is_public=True, role=EventParticipant.Role.SPEAKER)]
self.participants.filter(is_public=True, role=EventParticipant.Role.SPEAKER).select_related('participant').order_by('participant__display_name')
)
if len(persons) == 0 and self.kind == Event.Kind.SELF_ORGANIZED and self.owner: if len(persons) == 0 and self.kind == Event.Kind.SELF_ORGANIZED and self.owner:
persons.add(self.owner) persons.add(self.owner)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment