Modify json API for Carl
This commit is contained in:
parent
e9dd7f83a2
commit
adcfa45967
1 changed files with 14 additions and 4 deletions
18
vendor/symposion/schedule/views.py
vendored
18
vendor/symposion/schedule/views.py
vendored
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue