fnp
/
redakcja.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b13038d
)
xml upload: handle utf-8 properly
author
Radek Czajka
<radoslaw.czajka@nowoczesnapolska.org.pl>
Mon, 23 Aug 2010 09:34:40 +0000
(11:34 +0200)
committer
Radek Czajka
<radoslaw.czajka@nowoczesnapolska.org.pl>
Mon, 23 Aug 2010 09:34:40 +0000
(11:34 +0200)
apps/wiki/locale/pl/LC_MESSAGES/django.mo
patch
|
blob
|
history
apps/wiki/locale/pl/LC_MESSAGES/django.po
patch
|
blob
|
history
apps/wiki/templates/wiki/document_upload.html
patch
|
blob
|
history
apps/wiki/views.py
patch
|
blob
|
history
diff --git
a/apps/wiki/locale/pl/LC_MESSAGES/django.mo
b/apps/wiki/locale/pl/LC_MESSAGES/django.mo
index
d89c935
..
0e5d4a7
100644
(file)
Binary files a/apps/wiki/locale/pl/LC_MESSAGES/django.mo and b/apps/wiki/locale/pl/LC_MESSAGES/django.mo differ
diff --git
a/apps/wiki/locale/pl/LC_MESSAGES/django.po
b/apps/wiki/locale/pl/LC_MESSAGES/django.po
index
b818527
..
4eb2c76
100644
(file)
--- a/
apps/wiki/locale/pl/LC_MESSAGES/django.po
+++ b/
apps/wiki/locale/pl/LC_MESSAGES/django.po
@@
-7,10
+7,11
@@
msgid ""
msgstr ""
"Project-Id-Version: Platforma Redakcyjna\n"
"Report-Msgid-Bugs-To: \n"
msgstr ""
"Project-Id-Version: Platforma Redakcyjna\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2010-08-
16 16
:22+0200\n"
+"POT-Creation-Date: 2010-08-
23 11
:22+0200\n"
"PO-Revision-Date: 2010-08-16 16:24+0100\n"
"Last-Translator: Radek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>\n"
"PO-Revision-Date: 2010-08-16 16:24+0100\n"
"Last-Translator: Radek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>\n"
-"Language-Team: Fundacja Nowoczesna Polska <fundacja@nowoczesnapolska.org.pl>\n"
+"Language-Team: Fundacja Nowoczesna Polska <fundacja@nowoczesnapolska.org."
+"pl>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
@@
-117,7
+118,11
@@
msgstr "Nazwa taka sama jak dla pliku %s"
msgid "Title already used in repository."
msgstr "Plik o tej nazwie już istnieje w repozytorium."
msgid "Title already used in repository."
msgstr "Plik o tej nazwie już istnieje w repozytorium."
-#: views.py:339
+#: views.py:173
+msgid "File should be UTF-8 encoded."
+msgstr "Plik powinien mieć kodowanie UTF-8."
+
+#: views.py:344
msgid "Tag added"
msgstr "Dodano tag"
msgid "Tag added"
msgstr "Dodano tag"
@@
-175,15
+180,20
@@
msgid "Bulk documents upload"
msgstr "Hurtowe dodawanie dokumentów"
#: templates/wiki/document_upload.html:12
msgstr "Hurtowe dodawanie dokumentów"
#: templates/wiki/document_upload.html:12
-msgid "Please submit a ZIP with XML files. Files not ending with <code>.xml</code> will be ignored."
-msgstr "Proszę wskazać archiwum ZIP z plikami XML. Pliki nie kończące się na <code>.xml</code> zostaną zignorowane."
+msgid ""
+"Please submit a ZIP with UTF-8 encoded XML files. Files not ending with "
+"<code>.xml</code> will be ignored."
+msgstr ""
+"Proszę wskazać archiwum ZIP z plikami XML w kodowaniu UTF-8. Pliki nie kończące się na <code>."
+"xml</code> zostaną zignorowane."
#: templates/wiki/document_upload.html:17
msgid "Upload"
msgstr "Dodaj"
#: templates/wiki/document_upload.html:24
#: templates/wiki/document_upload.html:17
msgid "Upload"
msgstr "Dodaj"
#: templates/wiki/document_upload.html:24
-msgid "There have been some errors. No files have been added to the repository."
+msgid ""
+"There have been some errors. No files have been added to the repository."
msgstr "Wystąpiły błędy. Żadne pliki nie zostały dodane do repozytorium."
#: templates/wiki/document_upload.html:25
msgstr "Wystąpiły błędy. Żadne pliki nie zostały dodane do repozytorium."
#: templates/wiki/document_upload.html:25
@@
-330,4
+340,3
@@
msgstr "Wstaw znak specjalny"
#: templates/wiki/tabs/wysiwyg_editor_item.html:3
msgid "Visual editor"
msgstr "Edytor wizualny"
#: templates/wiki/tabs/wysiwyg_editor_item.html:3
msgid "Visual editor"
msgstr "Edytor wizualny"
-
diff --git
a/apps/wiki/templates/wiki/document_upload.html
b/apps/wiki/templates/wiki/document_upload.html
index
f1e37f7
..
d4c89d3
100644
(file)
--- a/
apps/wiki/templates/wiki/document_upload.html
+++ b/
apps/wiki/templates/wiki/document_upload.html
@@
-9,7
+9,7
@@
<h2>{% trans "Bulk documents upload" %}</h2>
<p>
<h2>{% trans "Bulk documents upload" %}</h2>
<p>
-{% trans "Please submit a ZIP with XML files. Files not ending with <code>.xml</code> will be ignored." %}
+{% trans "Please submit a ZIP with
UTF-8 encoded
XML files. Files not ending with <code>.xml</code> will be ignored." %}
</p>
<form enctype="multipart/form-data" method="POST" action="">
</p>
<form enctype="multipart/form-data" method="POST" action="">
diff --git
a/apps/wiki/views.py
b/apps/wiki/views.py
index
1bc4061
..
319cdba
100644
(file)
--- a/
apps/wiki/views.py
+++ b/
apps/wiki/views.py
@@
-166,13
+166,18
@@
def upload(request):
elif title in existing:
error_list.append((filename, title, _('Title already used in repository.')))
else:
elif title in existing:
error_list.append((filename, title, _('Title already used in repository.')))
else:
- ok_list.append((filename, title))
+ try:
+ zip.read(filename).decode('utf-8') # test read
+ ok_list.append((filename, title))
+ except UnicodeDecodeError:
+ error_list.append((filename, title, _('File should be UTF-8 encoded.')))
titles[title] = filename
titles[title] = filename
+
if not error_list:
for filename, title in ok_list:
storage.create_document(
name=title,
if not error_list:
for filename, title in ok_list:
storage.create_document(
name=title,
- text=zip.read(filename)
+ text=zip.read(filename)
.decode('utf-8')
)
return direct_to_template(request, "wiki/document_upload.html", extra_context={
)
return direct_to_template(request, "wiki/document_upload.html", extra_context={