from django.shortcuts import get_object_or_404, render
from django.utils import timezone
from django.views.decorators.http import require_POST
from django.shortcuts import get_object_or_404, render
from django.utils import timezone
from django.views.decorators.http import require_POST
from stage2.forms import AttachmentForm, MarkForm
from stage2.models import Participant, Assignment, Answer, Attachment, Mark
from stage2.forms import AttachmentForm, MarkForm
from stage2.models import Participant, Assignment, Answer, Attachment, Mark
def attachment_download(attachment):
response = HttpResponse(content_type='application/force-download')
response.write(attachment.file.read())
def attachment_download(attachment):
response = HttpResponse(content_type='application/force-download')
response.write(attachment.file.read())
- base, ext = attachment.filename().rsplit('.', 1)
- response['Content-Disposition'] = 'attachment; filename="%s.%s"' % (base[:10].replace('\n', ''), ext)
+ # workaround to this: https://code.djangoproject.com/ticket/20889
+ response['Content-Disposition'] = 'attachment; filename="%s"' % unidecode(attachment.filename().replace('\n', ' '))