Skip to content

Commit

Permalink
FIXUP
Browse files Browse the repository at this point in the history
  • Loading branch information
dezhin committed Jul 27, 2024
1 parent 701f6a9 commit 22bbdc0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
6 changes: 3 additions & 3 deletions nextgisweb/feature_attachment/api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import mimetypes
import re
from io import BytesIO
from itertools import count
from mimetypes import guess_extension
from tempfile import NamedTemporaryFile
from typing import List, Optional
from urllib.parse import quote_plus
Expand Down Expand Up @@ -83,7 +83,7 @@ def download(
fobj = FileObj.filter_by(id=fileobj_id).one()
response = UnsafeFileResponse(fobj.filename(), content_type=mime_type, request=request)
if name is None:
name = ""
name = f"unnamed{aid}{guess_extension(mime_type) or '.bin'}"
response.content_disposition = f"filename*=utf-8''{quote_plus(name)}"
return response

Expand Down Expand Up @@ -191,7 +191,7 @@ def export(resource, request):

name = obj.name
if name is None or name.strip() == "":
extension = mimetypes.guess_extension(obj.mime_type)
extension = guess_extension(obj.mime_type) or ".bin"
name = f"{att_idx:010d}{extension}"

if name in feature_anames:
Expand Down
12 changes: 6 additions & 6 deletions nextgisweb/feature_attachment/locale/ru.po
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ msgid "File name"
msgstr "Имя файла"

#: nodepkg/attachment-editor/AttachmentEditor.tsx:172
#: nodepkg/attachment-table/AttachmentTable.tsx:66
#: nodepkg/attachment-table/AttachmentTable.tsx:63
msgid "Size"
msgstr "Размер"

#: nodepkg/attachment-editor/AttachmentEditor.tsx:178
#: nodepkg/attachment-table/AttachmentTable.tsx:81
#: nodepkg/attachment-table/AttachmentTable.tsx:78
msgid "Description"
msgstr "Описание"

Expand Down Expand Up @@ -120,11 +120,11 @@ msgstr "Экспорт"
msgid "Import"
msgstr "Импорт"

#: nodepkg/attachment-table/AttachmentTable.tsx:48
msgid "Empty filename"
msgstr "Пустое имя файла"
#: nodepkg/attachment-table/AttachmentTable.tsx:55
msgid "Unnamed"
msgstr "Безымянный"

#: nodepkg/attachment-table/AttachmentTable.tsx:75
#: nodepkg/attachment-table/AttachmentTable.tsx:72
msgid "MIME type"
msgstr "Тип MIME"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,15 @@ export function AttachmentTable({
className: "name",
title: gettext("File name"),
render: (name: string, attachment: FeatureAttachment) => {
if (!name) {
name = "<" + gettext("Empty filename") + ">";
}
const href = routeURL("feature_attachment.download", {
id: resourceId,
fid: featureId,
aid: attachment.id,
});

return (
<a href={href} target="_blank" rel="noreferrer">
{name}
<a href={href} target="_blank">
{name || <i>{gettext("Unnamed")}</i>}
</a>
);
},
Expand Down Expand Up @@ -123,6 +120,7 @@ export function AttachmentTable({
showHeader={!isSmall}
size="small"
tableLayout="auto"
bordered
/>
)}
</div>
Expand Down

0 comments on commit 22bbdc0

Please sign in to comment.