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

Merge branch 'updating-dependencies' into 'master'

Updating dependencies

Closes #236

See merge request !82
parents b8040730 877b3223
......@@ -229,6 +229,8 @@ pages:
publish_demo:
only:
- master
stage: deploy
needs: ["build"]
script:
......
persistent_volume/*.sqlite3
*/settings.ini
\ No newline at end of file
*/settings.ini
.venv/
\ No newline at end of file
FROM python:3.6
FROM python:3.9
ENV PYTHONUNBUFFERED 1
EXPOSE 8086
......@@ -13,7 +13,7 @@ RUN apt-get update && \
apache2 \
apache2-dev \
libapache2-mod-xsendfile \
apache2-utils \
libapache2-mod-wsgi-py3 \
python3-dev \
locales \
&& rm -rf /var/lib/apt/lists/*
......@@ -48,7 +48,8 @@ RUN mkdir /code && \
WORKDIR /code
COPY requirements.txt /code/
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
COPY ./resources/*-entrypoint.sh /
RUN chmod a+x /*-entrypoint.sh
......
```
docker build . -t test
docker build . -t test_vhrdb
docker run -v $(pwd)/persistent_volume:/code/persistent_volume -e "USE_SQLITE_AS_DB=True" -e "ALLOWED_HOSTS=localhost" -e "SECRET_KEY=*" -e "DEBUG=True" -e "STATIC_URL=/static" -e "MEDIA_URL=/media" -e "PROJECT_NAME=viralhostrange" -p 8086:8086 test
docker run -v $(pwd)/persistent_volume:/code/persistent_volume -e "USE_SQLITE_AS_DB=True" -e "ALLOWED_HOSTS=localhost" -e "SECRET_KEY=*" -e "DEBUG=True" -e "STATIC_URL=/static" -e "MEDIA_URL=/media" -e "PROJECT_NAME=viralhostrange" -p 8086:8086 test_vhrdb
```
```
......
Django==2.2.*
Django<4.0
psycopg2
psycopg2-binary
mod_wsgi
pandas<=0.25
pandas<=1.3.5
jinja2
openpyxl
django-crispy-forms
......@@ -10,11 +10,11 @@ python-decouple
django-rest-framework
drf-dynamic-fields
coverage
git+https://gitlab.pasteur.fr/bbrancot/django-basetheme-bootstrap.git@v0.2.52
git+https://gitlab.pasteur.fr/bbrancot/django-basetheme-bootstrap.git@v0.2.74
django-extensions
django-formtools
docutils
scikit-learn<=0.22
scikit-learn<=1.0.2
django-colorfield
pyexcel-ezodf
biopython
LoadModule wsgi_module /usr/local/lib/python3.6/site-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so
Listen 8086
WSGIRestrictEmbedded On
LogLevel info
......@@ -14,7 +13,7 @@ ErrorLog "|/usr/bin/rotatelogs /code/persistent_volume/apache.%Y-%m-%d-%H_%M_%S.
DocumentRoot /var/www/html
WSGIScriptAlias / /code/${PROJECT_NAME}/wsgi.py process-group=${PROJECT_NAME}
WSGIDaemonProcess ${PROJECT_NAME} python-path=/code:/usr/local/lib/python3.6/site-packages
WSGIDaemonProcess ${PROJECT_NAME} python-path=/code:/usr/local/lib/python3.9/site-packages
WSGIProcessGroup ${PROJECT_NAME}
Alias ${STATIC_URL}/ /code/.static/
......@@ -28,6 +27,7 @@ ErrorLog "|/usr/bin/rotatelogs /code/persistent_volume/apache.%Y-%m-%d-%H_%M_%S.
WSGIApplicationGroup %{GLOBAL}
WSGIScriptReloading On
Require all granted
LimitRequestBody 5242880
</Directory>
<Directory /code/.static>
......
......@@ -291,5 +291,6 @@ BACKUP_MIN_WEEKS_TO_KEEP = int(18 * 52 / 12)
# Django tunning for this project
################################################################################
DATA_UPLOAD_MAX_NUMBER_FIELDS = 10000
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
################################################################################
from basetheme_bootstrap.admin import ViewOnSiteModelAdmin, UserPreferencesAdmin
from basetheme_bootstrap.user_preferences import get_user_preference_class
from basetheme_bootstrap.user_preferences_utils import get_user_preference_class
from django.contrib import admin
from django.contrib import messages
from django.contrib.auth import get_permission_codename
......
......@@ -14,7 +14,7 @@ from typing import Union, List
import ezodf
import pandas as pd
from Bio import Entrez
from basetheme_bootstrap.user_preferences import get_user_preferences_for_user
from basetheme_bootstrap.user_preferences_utils import get_user_preferences_for_user
from django.conf import settings
from django.contrib import messages
from django.contrib.admin import models as admin_models
......@@ -321,7 +321,7 @@ def __parse_file(file, importation_observer: ImportationObserver = None, sheet_n
for id_col, cell in enumerate(sub_row):
cell = cell.strip()
if header is None or not has_seen_data and id_col == 1 and sub_row[0] == "":
if cell is not "" and not cell.startswith("Unnamed: "):
if cell != "" and not cell.startswith("Unnamed: "):
header = row
start_at = id_col - 1 + start_at
break
......
......@@ -6,7 +6,7 @@ import re
import string
import pandas as pd
from basetheme_bootstrap.user_preferences import get_user_preferences_for_user
from basetheme_bootstrap.user_preferences_utils import get_user_preferences_for_user
from crispy_forms import helper as crispy_forms_helper
from crispy_forms import layout as crispy_forms_layout
from crispy_forms.helper import FormHelper
......
import os
from basetheme_bootstrap.user_preferences import get_user_preference_class, get_user_preferences_for_user
from basetheme_bootstrap.user_preferences_utils import get_user_preference_class, get_user_preferences_for_user
from django.contrib.admin import AdminSite
from django.contrib.admin import models as admin_models
from django.contrib.auth import get_user_model, get_permission_codename
......
......@@ -5,7 +5,7 @@ import random
import shutil
import string
from basetheme_bootstrap.user_preferences import get_user_preferences_for_user
from basetheme_bootstrap.user_preferences_utils import get_user_preferences_for_user
from django.conf import settings
from django.contrib.auth import get_user_model
from django.core import mail, management
......
......@@ -7,7 +7,7 @@ logger = logging.getLogger(__name__)
import os
from basetheme_bootstrap.user_preferences import get_user_preferences_for_user
from basetheme_bootstrap.user_preferences_utils import get_user_preferences_for_user
from django.contrib.auth import get_user_model
from django.db.models import Min, Max
from django.db.models import Q
......
......@@ -1168,13 +1168,13 @@ class SearchTestCase(ViewTestCase):
url = reverse('viralhostrangedb-api:search')
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertIn("err", json.loads(response.content, encoding='utf8'))
self.assertIn("err", json.loads(response.content))
def test_works_no_auth(self):
url = reverse('viralhostrangedb-api:search') + "?search=privateprivateprivate"
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
response = json.loads(response.content, encoding='utf8')
response = json.loads(response.content)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
self.assertEqual(response["data_source"]["count"], 0)
......@@ -1184,7 +1184,7 @@ class SearchTestCase(ViewTestCase):
self.client.force_login(self.user)
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
response = json.loads(response.content, encoding='utf8')
response = json.loads(response.content)
self.assertGreater(response["data_source"]["count"], 0)
def test_works_ui_help(self):
......@@ -1192,7 +1192,7 @@ class SearchTestCase(ViewTestCase):
self.client.force_login(self.user)
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
response = json.loads(response.content, encoding='utf8')
response = json.loads(response.content)
self.assertGreater(response["data_source"]["count"], 0)
def test_privacy_cross_auth(self):
......@@ -1200,7 +1200,7 @@ class SearchTestCase(ViewTestCase):
self.client.force_login(self.toto)
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
response = json.loads(response.content, encoding='utf8')
response = json.loads(response.content)
self.assertEqual(response["data_source"]["count"], 0)
def test_advanced(self):
......@@ -1209,36 +1209,36 @@ class SearchTestCase(ViewTestCase):
self.client.force_login(self.toto)
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
response = json.loads(response.content, encoding='utf8')
response = json.loads(response.content)
self.assertEqual(response["data_source"]["count"], 1)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
self.client.logout()
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 0)
url = reverse('viralhostrangedb-api:search') + "?search=" + ds.virus_set.first().name
self.client.force_login(self.toto)
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
response = json.loads(response.content, encoding='utf8')
response = json.loads(response.content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 1)
self.assertEqual(response["host"]["count"], 0)
self.client.logout()
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["virus"]["count"], 0)
url = reverse('viralhostrangedb-api:search') + "?search=" + ds.host_set.first().name
self.client.force_login(self.toto)
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
response = json.loads(response.content, encoding='utf8')
response = json.loads(response.content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 1)
self.client.logout()
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["host"]["count"], 0)
def test_only_identifier_virus(self):
......@@ -1247,13 +1247,13 @@ class SearchTestCase(ViewTestCase):
self.r1.save()
url = reverse('viralhostrangedb-api:search') + "?search=" + search
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 1)
self.assertEqual(response["host"]["count"], 0)
url = reverse('viralhostrangedb-api:search') + "?search=" + search + "&only_virus_ncbi_id=on"
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
......@@ -1262,7 +1262,7 @@ class SearchTestCase(ViewTestCase):
self.r1.save()
url = reverse('viralhostrangedb-api:search') + "?search=" + search + "&only_virus_ncbi_id=on"
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
......@@ -1271,7 +1271,7 @@ class SearchTestCase(ViewTestCase):
self.r1.save()
url = reverse('viralhostrangedb-api:search') + "?search=" + search + "&only_virus_ncbi_id=on"
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 1)
self.assertEqual(response["host"]["count"], 0)
......@@ -1282,13 +1282,13 @@ class SearchTestCase(ViewTestCase):
self.C1.save()
url = reverse('viralhostrangedb-api:search') + "?search=" + search
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 1)
url = reverse('viralhostrangedb-api:search') + "?search=" + search + "&only_host_ncbi_id=on"
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
......@@ -1297,7 +1297,7 @@ class SearchTestCase(ViewTestCase):
self.C1.save()
url = reverse('viralhostrangedb-api:search') + "?search=" + search + "&only_host_ncbi_id=on"
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
......@@ -1306,7 +1306,7 @@ class SearchTestCase(ViewTestCase):
self.C1.save()
url = reverse('viralhostrangedb-api:search') + "?search=" + search + "&only_host_ncbi_id=on"
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 1)
......@@ -1317,13 +1317,13 @@ class SearchTestCase(ViewTestCase):
self.private_data_source_of_toto_with_no_virus_or_host_shared.name + "\""
url = base_url
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 1)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
url = base_url + "&only_host_ncbi_id=on"
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
......@@ -1332,7 +1332,7 @@ class SearchTestCase(ViewTestCase):
self.Cx.save()
url = base_url + "&only_host_ncbi_id=on"
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
......@@ -1341,13 +1341,13 @@ class SearchTestCase(ViewTestCase):
self.Cx.save()
url = base_url + "&only_host_ncbi_id=on"
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 1)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
url = base_url + "&only_host_ncbi_id=on" + "&only_virus_ncbi_id=on"
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
......@@ -1356,7 +1356,7 @@ class SearchTestCase(ViewTestCase):
self.rx.save()
url = base_url + "&only_host_ncbi_id=on" + "&only_virus_ncbi_id=on"
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
......@@ -1365,7 +1365,7 @@ class SearchTestCase(ViewTestCase):
self.rx.save()
url = base_url + "&only_host_ncbi_id=on" + "&only_virus_ncbi_id=on"
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 1)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
......@@ -1378,13 +1378,13 @@ class SearchTestCase(ViewTestCase):
self.r2.her_identifier = her
self.r2.save()
url = reverse('viralhostrangedb-api:search') + "?search=%i" % her
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertSetEqual(set([o["id"] for o in response["virus"]["sample"]]), {self.r1.id, self.r2.id})
url = reverse('viralhostrangedb-api:search') + "?search=her:%i" % her
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertSetEqual(set([o["id"] for o in response["virus"]["sample"]]), {self.r2.id})
url = reverse('viralhostrangedb-api:search') + "?search=her:ZZ"
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
......@@ -1396,16 +1396,16 @@ class SearchTestCase(ViewTestCase):
# I could have use unidecode but I did not
url = reverse('viralhostrangedb-api:search') + "?search=%s" % "Herelle"
self.assertEqual(json.loads(self.client.get(url).content, encoding='utf8')["data_source"]["count"], 0)
self.assertEqual(json.loads(self.client.get(url).content)["data_source"]["count"], 0)
models.DataSource.objects.filter(pk=self.public_data_source_of_user.pk).update(description=text)
self.assertEqual(json.loads(self.client.get(url).content, encoding='utf8')["data_source"]["count"], 1)
self.assertEqual(json.loads(self.client.get(url).content)["data_source"]["count"], 1)
models.DataSource.objects.filter(pk=self.public_data_source_of_user.pk).update(name=text)
self.assertEqual(json.loads(self.client.get(url).content, encoding='utf8')["data_source"]["count"], 1)
self.assertEqual(json.loads(self.client.get(url).content)["data_source"]["count"], 1)
models.DataSource.objects.filter(pk=self.public_data_source_with_ids_of_toto.pk).update(description=text)
self.assertEqual(json.loads(self.client.get(url).content, encoding='utf8')["data_source"]["count"], 2)
self.assertEqual(json.loads(self.client.get(url).content)["data_source"]["count"], 2)
def test_data_source_searched(self):
base_url = reverse('viralhostrangedb-api:search') + "?search="
......@@ -1416,7 +1416,7 @@ class SearchTestCase(ViewTestCase):
self.public_data_source_of_user.owner.last_name[3:-3],
self.public_data_source_of_user.owner.first_name[:-3],
]:
response = json.loads(self.client.get(base_url + searched).content, encoding='utf8')
response = json.loads(self.client.get(base_url + searched).content)
self.assertEqual(
response['data_source']['sample'][0]['provider'],
self.user.last_name.upper() + " " + self.user.first_name.title()
......@@ -1431,7 +1431,7 @@ class SearchTestCase(ViewTestCase):
self.public_data_source_of_user.provider_first_name[2:],
self.public_data_source_of_user.provider_last_name[2:],
]:
response = json.loads(self.client.get(base_url + searched).content, encoding='utf8')
response = json.loads(self.client.get(base_url + searched).content)
self.assertEqual(
response['data_source']['sample'][0]['provider'],
self.public_data_source_of_user.provider_last_name.upper() + " " +
......@@ -1445,7 +1445,7 @@ class SearchTestCase(ViewTestCase):
self.public_data_source_of_user.owner.first_name,
self.public_data_source_of_user.owner.last_name[3:-3],
]:
response = json.loads(self.client.get(base_url + searched).content, encoding='utf8')
response = json.loads(self.client.get(base_url + searched).content)
pks = {d['id'] for d in response['data_source']['sample']}
self.assertNotIn(self.public_data_source_of_user.pk, pks)
......@@ -1456,7 +1456,7 @@ class SearchTestCase(ViewTestCase):
d.save()
base_url = reverse('viralhostrangedb-api:search') + "?search=azerty&str_max_length=%i"
for str_max_length in [10, 50, 100, 200]:
response = json.loads(self.client.get(base_url % str_max_length).content, encoding='utf8')
response = json.loads(self.client.get(base_url % str_max_length).content)
for d in response["data_source"]["sample"]:
self.assertLessEqual(len(d["description"]), str_max_length)
self.assertTrue(models.DataSource.objects.filter(name=d["name"], id=d["id"]).exists())
......@@ -1607,7 +1607,7 @@ class GreekLettersTest(TestCase):
]:
response = self.client.get(url + urllib.parse.urlencode(dict(search=s)))
self.assertEqual(response.status_code, 200)
response = json.loads(response.content, encoding='utf8')
response = json.loads(response.content)
self.assertEqual(response["virus"]["count"], cpt, "For %s expected %i" % (s, cpt))
self.assertEqual(response["host"]["count"], 0)
self.assertEqual(response["data_source"]["count"], 0)
......@@ -1620,7 +1620,7 @@ class GreekLettersTest(TestCase):
("ξ", "xi"),
]:
response = self.client.get(url + "&search=" + name)
response = json.loads(response.content, encoding='utf8')
response = json.loads(response.content)
self.assertIn(letter, response["query"]["alternative_searched_texts"])
......@@ -1672,7 +1672,7 @@ class SearchSpaceSplitTest(TestCase):
]:
response = self.client.get(url + "&search=" + s)
self.assertEqual(response.status_code, 200)
response = json.loads(response.content, encoding='utf8')
response = json.loads(response.content)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
self.assertEqual(response["data_source"]["count"], cpt, "For <i>%s</i> expected %i" % (s, cpt))
......@@ -1689,7 +1689,7 @@ class SearchSpaceSplitTest(TestCase):
]:
response = self.client.get(url + urllib.parse.urlencode(dict(search=s)))
self.assertEqual(response.status_code, 200)
response = json.loads(response.content, encoding='utf8')
response = json.loads(response.content)
self.assertEqual(response["virus"]["count"], cpt, "For <i>%s</i> expected %i" % (s, cpt))
self.assertEqual(response["host"]["count"], 0)
self.assertEqual(response["data_source"]["count"], 0)
......@@ -1770,7 +1770,7 @@ class SearchMatchCountTest(TestCase):
d["sorting"] = sorting
if kind:
d["kind"] = kind
return json.loads(self.client.get(self.url + urllib.parse.urlencode(d)).content, encoding='utf8')
return json.loads(self.client.get(self.url + urllib.parse.urlencode(d)).content)
def test_sorting_pk(self):
# don't care of the number of hit, just return them, by pk probably
......@@ -1912,7 +1912,7 @@ class SearchMatchCountTest(TestCase):
d["sorting"] = sorting
response = self.client.get(self.url + urllib.parse.urlencode(d))
self.assertEqual(response.status_code, 200)
response = json.loads(response.content, encoding='utf8')
response = json.loads(response.content)
if 'app_error_code' in response:
ids = []
else:
......
......@@ -1102,7 +1102,7 @@ class DataSourceMappingEditTestCase(ViewTestCase):
form_data = {}
self.assertRaises(ValidationError, self.client.post, url, form_data)
self.assertEqual(self.client.post(url, form_data).status_code, 200, "Stay on the page as the form is invalid")
self.assertFalse(self.public_data_source_of_user.is_mapping_done)
......
......@@ -6,7 +6,7 @@ from tempfile import NamedTemporaryFile
from urllib import parse
import pandas as pd
from basetheme_bootstrap.user_preferences import get_user_preferences_for_user
from basetheme_bootstrap.user_preferences_utils import get_user_preferences_for_user
from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.auth.models import AnonymousUser
......
......@@ -10,7 +10,7 @@ import tempfile
import pandas as pd
from basetheme_bootstrap.templatetags.sstatic import sstatic
from basetheme_bootstrap.user_preferences import get_user_preferences_for_user
from basetheme_bootstrap.user_preferences_utils import get_user_preferences_for_user
from django.conf import settings
from django.contrib import messages
from django.contrib.admin.models import LogEntry
......@@ -1101,9 +1101,9 @@ def download_responses(request):
row_header = [o.explicit_name for o in virus]
if host_infection_ratio_shift == 1:
row_header.insert(0, _("Infection ratio"))
row_header.insert(0, ugettext("Infection ratio"))
if virus_infection_ratio_shift == 1:
col_header.insert(0, _("Infection ratio"))
col_header.insert(0, ugettext("Infection ratio"))
# get at which position each host is, mandatory if data are sparse
col_pos = dict([(pk, i) for i, pk in enumerate(
......@@ -1287,8 +1287,8 @@ def host_or_virus_download(request, is_host, instance):
data = []
if infection_ratio_shift == 1:
col_header.insert(0, _("Infection ratio"))
row_header.insert(0, _("Infection ratio"))
col_header.insert(0, ugettext("Infection ratio"))
row_header.insert(0, ugettext("Infection ratio"))
data.append([""] * len(col_header))
# get at which position each col is
......
......@@ -182,6 +182,9 @@ class Round(Func):
arity = 2
arg_joiner = '::numeric, '
def __init__(self, *expressions, **extra):
super().__init__(*expressions, output_field=FloatField(), **extra)
def as_sqlite(self, compiler, connection, **extra_context):
return super().as_sqlite(compiler, connection, arg_joiner=", ", **extra_context)