Add track to schedule JSON

Include the track of the slow in the schedule JSON so the miniconf can be identified.
This commit is contained in:
Joel Addison 2018-01-18 19:15:59 +11:00
parent ae33da0de4
commit 135c5d2da3

View file

@ -215,14 +215,17 @@ def schedule_json(request):
protocol = request.META.get('HTTP_X_FORWARDED_PROTO', 'http') protocol = request.META.get('HTTP_X_FORWARDED_PROTO', 'http')
data = [] data = []
for slot in slots: for slot in slots:
rooms = list(slot.rooms)
slot_data = { slot_data = {
"room": ", ".join(room["name"] for room in slot.rooms.values()), "room": ", ".join(room.name for room in rooms),
"rooms": [room["name"] for room in slot.rooms.values()], "rooms": [room.name for room in rooms],
"start": slot.start_datetime.isoformat(), "start": slot.start_datetime.isoformat(),
"end": slot.end_datetime.isoformat(), "end": slot.end_datetime.isoformat(),
"duration": slot.length_in_minutes, "duration": slot.length_in_minutes,
"kind": slot.kind.label, "kind": slot.kind.label,
"section": slot.day.schedule.section.slug, "section": slot.day.schedule.section.slug,
"section_name": slot.day.schedule.section.name,
"track": None,
"conf_key": slot.pk, "conf_key": slot.pk,
# TODO: models should be changed. # TODO: models should be changed.
# these are model features from other conferences that have forked symposion # these are model features from other conferences that have forked symposion
@ -237,6 +240,12 @@ def schedule_json(request):
if slot.content.unpublish and not request.user.is_staff: if slot.content.unpublish and not request.user.is_staff:
continue continue
track_name = None
if len(rooms) == 1:
track = rooms[0].track_set.filter(day=slot.day).first()
if track:
track_name = track.name
slot_data.update({ slot_data.update({
"name": slot.content.title, "name": slot.content.title,
"authors": [s.name for s in slot.content.speakers()], "authors": [s.name for s in slot.content.speakers()],
@ -250,7 +259,8 @@ def schedule_json(request):
reverse("schedule_presentation_detail", args=[slot.content.pk]) reverse("schedule_presentation_detail", args=[slot.content.pk])
), ),
"cancelled": slot.content.cancelled, "cancelled": slot.content.cancelled,
"released": slot.content.proposal.recording_release "released": slot.content.proposal.recording_release,
"track": track_name,
}) })
if not slot.content.speaker.twitter_username == '': if not slot.content.speaker.twitter_username == '':
slot_data["twitter_id"] = slot.content.speaker.twitter_username slot_data["twitter_id"] = slot.content.speaker.twitter_username