diff --git a/vendor/symposion/schedule/views.py b/vendor/symposion/schedule/views.py index f4e0501f..13a9c708 100644 --- a/vendor/symposion/schedule/views.py +++ b/vendor/symposion/schedule/views.py @@ -19,6 +19,7 @@ from symposion.schedule.forms import SlotEditForm, ScheduleSectionForm from symposion.schedule.models import Schedule, Day, Slot, Presentation, Session, SessionRole from symposion.schedule.timetable import TimeTable from symposion.conference.models import Conference +from pinaxcon.templatetags.lca2018_tags import speaker_photo def fetch_schedule(slug): @@ -206,6 +207,18 @@ def schedule_presentation_detail(request, pk): return render(request, "symposion/schedule/presentation_detail.html", ctx) +def has_contact_perm(user): + return user.has_perm('symposion_speakers.can_view_contact_details') or user.is_staff + + +def make_speaker_dict(user, speaker): + return { + 'name': speaker.name, + 'twitter': speaker.twitter_username, + 'contact': speaker.email if has_contact_perm(user) else 'redacted', + 'picture_url': speaker_photo(None, speaker, 120) + } + def schedule_json(request): slots = Slot.objects.filter( day__schedule__published=True, @@ -248,10 +261,7 @@ def schedule_json(request): slot_data.update({ "name": slot.content.title, - "authors": [s.name for s in slot.content.speakers()], - "contact": [ - s.email for s in slot.content.speakers() - ] if request.user.has_perm('symposion_speakers.can_view_contact_details') or request.user.is_staff else ["redacted"], + "authors": [make_speaker_dict(request.user, s) for s in slot.content.speakers()], "abstract": slot.content.abstract, "conf_url": "%s://%s%s" % ( protocol,