Commit a4f043ae authored by Bryan  BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

Attempt to solve encoding issue on filename of #102

parent 50821bf1
......@@ -2,6 +2,7 @@ import itertools
import json
import os
import tempfile
import unicodedata
import pandas as pd
from basetheme_bootstrap.user_preferences import get_user_preferences_for_user
......@@ -842,6 +843,17 @@ def data_source_download(request, pk):
return response
class ASCIIFileSystemStorage(storage.FileSystemStorage):
Convert unicode characters in name to ASCII characters.
def get_valid_name(self, name):
name = unicodedata.normalize('NFKD', name).encode('ascii', 'ignore')
return super(ASCIIFileSystemStorage, self).get_valid_name(name)
@method_decorator(login_required, name='dispatch')
class DataSourceWizard(wizard_views.NamedUrlSessionWizardView):
def get_upload_or_live_input(self):
......@@ -874,7 +886,7 @@ class DataSourceWizard(wizard_views.NamedUrlSessionWizardView):
"Upload": upload_data,
template_name = 'viralhostrangedb/wizard_form.html'
file_storage = storage.FileSystemStorage(location=os.path.join(tempfile.gettempdir(), 'viralhostrangedb_wizard'))
file_storage = ASCIIFileSystemStorage(location=os.path.join(tempfile.gettempdir(), 'viralhostrangedb_wizard'))
def get_context_data(self, form, step=None, **kwargs):
context = super().get_context_data(form=form, step=step, **kwargs)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment