Skip to content

Instantly share code, notes, and snippets.

@jandd
Created May 24, 2019 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jandd/12317282704be0c0bc605899bef4e555 to your computer and use it in GitHub Desktop.
Save jandd/12317282704be0c0bc605899bef4e555 to your computer and use it in GitHub Desktop.
from event.models import Event
from django.core.mail import EmailMessage
import csv
import io
e = Event.objects.current_event()
email = EmailMessage(
"Speakerfeedback für {}".format(e.title),
"Im Anhang ist das Speaker feedback für den {}".format(e.title),
"webmaster@devday.de",
("user@example.org",))
for t in e.talk_set.filter(track__isnull=False):
filename="{}-{}.csv".format(t.published_speaker.slug, t.slug)
csvfile = io.StringIO()
csvwriter = csv.writer(csvfile, delimiter=";", quoting=csv.QUOTE_ALL)
for f in t.attendeefeedback_set.all():
csvwriter.writerow(["{} von 5".format(f.score), f.comment or "-"])
email.attach(filename, csvfile.getvalue(), "text/csv; charset=utf-8")
email.send()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment