|
@ -114,4 +114,36 @@ def SeznamExportView(request, seznam): |
|
|
content_type="text/plain" |
|
|
content_type="text/plain" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
def exportSeznamuPrednasekNeHodnoceni(req, seznam): |
|
|
|
|
|
# UGLY CODE. Jen byla potřeba pro garanta přednášek tabulka, tak vznikla :-P |
|
|
|
|
|
|
|
|
|
|
|
seznam = get_object_or_404(Seznam, id=seznam) |
|
|
|
|
|
|
|
|
|
|
|
from django.http import HttpResponse |
|
|
|
|
|
|
|
|
|
|
|
# Kód jsem zkopíroval přímo z tutoriálu |
|
|
|
|
|
# https://docs.djangoproject.com/en/4.0/howto/outputting-csv/ |
|
|
|
|
|
# Jo, je to špatná verze djanga. whatever. |
|
|
|
|
|
response = HttpResponse( |
|
|
|
|
|
content_type='text/csv', |
|
|
|
|
|
headers={'Content-Disposition': 'attachment; filename="seznam.csv"'}, |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
writer = csv.writer(response) |
|
|
|
|
|
|
|
|
|
|
|
attrs = ( |
|
|
|
|
|
'id', |
|
|
|
|
|
'org', |
|
|
|
|
|
'nazev', |
|
|
|
|
|
'anotace', |
|
|
|
|
|
'klicova', |
|
|
|
|
|
'obor', |
|
|
|
|
|
'obtiznost', |
|
|
|
|
|
'popis', |
|
|
|
|
|
) |
|
|
|
|
|
for predn in Prednaska.objects.filter(seznamy=seznam): |
|
|
|
|
|
row = [getattr(predn, attr) for attr in attrs] |
|
|
|
|
|
writer.writerow(row) |
|
|
|
|
|
|
|
|
|
|
|
return response |
|
|
|
|
|
|
|
|