Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions geonode/documents/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#########################################################################

import os
import json
import logging
import traceback
Expand All @@ -29,6 +29,7 @@
from django.http import HttpResponse, HttpResponseRedirect, Http404
from django.template import loader
from django.utils.translation import ugettext as _
from django.utils.text import slugify
from django.contrib.auth.decorators import login_required
from django.conf import settings
from django.urls import reverse
Expand Down Expand Up @@ -192,7 +193,8 @@ def document_download(request, docid):
'401.html', context={
'error_message': _("You are not allowed to view this document.")}, request=request), status=401)
register_event(request, EventType.EVENT_DOWNLOAD, document)
return DownloadResponse(document.doc_file)
filename = slugify(os.path.splitext(os.path.basename(document.title))[0])
return DownloadResponse(document.doc_file, basename=f"{filename}.{document.extension}")


class DocumentUploadView(CreateView):
Expand Down