Lash up presentations report for naming videos
This commit is contained in:
parent
97beb8b131
commit
503b9b164e
2 changed files with 42 additions and 0 deletions
2
vendor/symposion/symposion/speakers/urls.py
vendored
2
vendor/symposion/symposion/speakers/urls.py
vendored
|
@ -1,6 +1,7 @@
|
||||||
from django.conf.urls import url
|
from django.conf.urls import url
|
||||||
|
|
||||||
from .views import (
|
from .views import (
|
||||||
|
presentations_report,
|
||||||
speaker_create,
|
speaker_create,
|
||||||
speaker_create_token,
|
speaker_create_token,
|
||||||
speaker_edit,
|
speaker_edit,
|
||||||
|
@ -18,4 +19,5 @@ urlpatterns = [
|
||||||
url(r"^staff/create/(\d+)/$", speaker_create_staff, name="speaker_create_staff"),
|
url(r"^staff/create/(\d+)/$", speaker_create_staff, name="speaker_create_staff"),
|
||||||
url(r"^talks-report/$", speaker_talks_report, name="speaker_talks_report"),
|
url(r"^talks-report/$", speaker_talks_report, name="speaker_talks_report"),
|
||||||
url(r"^track-report/$", speaker_track_report, name="speaker_track_report"),
|
url(r"^track-report/$", speaker_track_report, name="speaker_track_report"),
|
||||||
|
url(r"^presentations-report/$", presentations_report, name="presentations_report"),
|
||||||
]
|
]
|
||||||
|
|
40
vendor/symposion/symposion/speakers/views.py
vendored
40
vendor/symposion/symposion/speakers/views.py
vendored
|
@ -191,3 +191,43 @@ def speaker_talks_report(request):
|
||||||
for row in cursor.fetchall():
|
for row in cursor.fetchall():
|
||||||
writer.writerow(row)
|
writer.writerow(row)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@user_passes_test(lambda u: u.is_staff)
|
||||||
|
def presentations_report(request):
|
||||||
|
query = """
|
||||||
|
SELECT day.date,
|
||||||
|
room.name AS room,
|
||||||
|
start,
|
||||||
|
"end",
|
||||||
|
slot.name AS slot,
|
||||||
|
p.title,
|
||||||
|
s.name AS "primary speaker",
|
||||||
|
STRING_AGG(s2.name, ', ') AS "additional speakers"
|
||||||
|
FROM symposion_schedule_presentation p
|
||||||
|
INNER JOIN symposion_speakers_speaker s ON p.speaker_id = s.id
|
||||||
|
LEFT OUTER JOIN symposion_schedule_presentation_additional_speakers a ON p.id = a.presentation_id
|
||||||
|
LEFT OUTER JOIN symposion_speakers_speaker s2 ON a.speaker_id = s2.id
|
||||||
|
INNER JOIN symposion_schedule_slot slot ON p.slot_id = slot.id
|
||||||
|
INNER JOIN symposion_schedule_day day ON slot.day_id = day.id
|
||||||
|
INNER JOIN symposion_schedule_slotroom sr ON slot.id = sr.slot_id
|
||||||
|
INNER JOIN symposion_schedule_room room ON sr.room_id = room.id
|
||||||
|
GROUP BY p.id,
|
||||||
|
s.id,
|
||||||
|
slot.id,
|
||||||
|
day.id,
|
||||||
|
room.id
|
||||||
|
"""
|
||||||
|
response = HttpResponse(content_type='text/csv')
|
||||||
|
filename = 'presentations_report-{}.csv'.format(
|
||||||
|
datetime.datetime.now().strftime('%Y-%m-%d'),
|
||||||
|
)
|
||||||
|
response['Content-Disposition'] = f'attachment; filename={filename}'
|
||||||
|
writer = csv.writer(response)
|
||||||
|
with connection.cursor() as cursor:
|
||||||
|
cursor.execute(query)
|
||||||
|
writer.writerow([i[0] for i in cursor.description])
|
||||||
|
for row in cursor.fetchall():
|
||||||
|
writer.writerow(row)
|
||||||
|
return response
|
||||||
|
|
Loading…
Reference in a new issue