Created
May 24, 2019 11:06
-
-
Save jandd/12317282704be0c0bc605899bef4e555 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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