Compare commits

...

2 Commits

Author SHA1 Message Date
Emmy D'Anello 29d9432ca2
Order passages by position rather than id
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-06 23:34:06 +02:00
Emmy D'Anello 0181a1392d
Guess the CSV delimiter when uploading a notation sheet
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-04-06 23:08:35 +02:00
2 changed files with 10 additions and 2 deletions

View File

@ -262,7 +262,15 @@ class UploadNotesForm(forms.Form):
except UnicodeDecodeError:
# This is not UTF-8, grrrr
content = data.decode('latin1')
csvfile = csv.reader(StringIO(content))
for delimiter in [',', ';', '\t', '|']:
if content.split('\n')[0].count(delimiter) > 1:
break
else:
self.add_error('file',
_("Unable to detect the CSV delimiter. Please use a comma-separated file."))
return cleaned_data
csvfile = csv.reader(StringIO(content), delimiter=delimiter)
self.process(csvfile, cleaned_data)
except UnicodeDecodeError:
self.add_error('file', _("This file contains non-UTF-8 and non-ISO-8859-1 content. "

View File

@ -863,7 +863,7 @@ class PoolDetailView(LoginRequiredMixin, DetailView):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["passages"] = PassageTable(self.object.passages.order_by('id').all())
context["passages"] = PassageTable(self.object.passages.order_by('position').all())
if self.object.results_available or self.request.user.registration.is_volunteer:
# Hide notes before the end of the turn