1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-02-25 18:26:30 +00:00

Compare commits

...

15 Commits

Author SHA1 Message Date
Emmy D'Anello
cf561c4584
Linting
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-01-13 19:50:16 +01:00
Emmy D'Anello
e2679cf5e8
Add Haystack index name in env vars
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-01-13 19:33:31 +01:00
Emmy D'Anello
122edeef48
Fix purposed problem verbose name
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-01-13 19:32:39 +01:00
Emmy D'Anello
4ff9f44eae
Don't need to rebuild the ES index periodically, do it only once
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-01-13 19:31:15 +01:00
Emmy D'Anello
5d13d9bc16
Fix basic search tests
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-01-13 19:24:55 +01:00
Emmy D'Anello
121e1da37d
Add py312 tox env
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-01-13 19:00:46 +01:00
Emmy D'Anello
8222f3b781
Adapt search tests since the simple backend is not so permissive as ElasticSearch
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-01-13 18:47:17 +01:00
Emmy D'Anello
dc56396012
Use elasticsearch only in production
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-01-13 18:32:30 +01:00
Emmy D'Anello
f1d2acdc25
Remove whoosh in profit for Elasticsearch
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-01-13 18:28:45 +01:00
Emmy D'Anello
50e95ad3f2
Install Git in Gitlab CI
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-01-13 17:31:31 +01:00
Emmy D'Anello
7848a90d5d
Fix gunicorn and psycopg2-binary versions
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-01-13 17:30:07 +01:00
Emmy D'Anello
f08cb229ca
Use early version for Django Haystack for Django 5.0 support
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-01-13 17:27:58 +01:00
Emmy D'Anello
b0fbb406f6
Add Python 3.12 test in Gitlab CI
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-01-13 17:24:36 +01:00
Emmy D'Anello
0f2f34175c
Upgrade Django to 5.0, update dependencies
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-01-13 17:21:55 +01:00
Emmy D'Anello
6226f06d97
Update Python to 3.12
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-01-13 17:09:45 +01:00
11 changed files with 98 additions and 62 deletions

View File

@ -2,22 +2,24 @@ stages:
- test
- quality-assurance
py310:
stage: test
image: python:3.10-alpine
before_script:
- apk add --no-cache libmagic
- pip install tox --no-cache-dir
script: tox -e py310
py311:
stage: test
image: python:3.11-alpine
before_script:
- apk add --no-cache libmagic
- apk add --no-cache git # Useful for django-haystack, remove when the newer versions are in PyPI
- pip install tox --no-cache-dir
script: tox -e py311
py312:
stage: test
image: python:3.12-alpine
before_script:
- apk add --no-cache libmagic
- apk add --no-cache git # Useful for django-haystack, remove when the newer versions are in PyPI
- pip install tox --no-cache-dir
script: tox -e py312
linters:
stage: quality-assurance
image: python:3-alpine

View File

@ -1,4 +1,4 @@
FROM python:3.11-alpine
FROM python:3.12-alpine
ENV PYTHONUNBUFFERED 1
ENV DJANGO_ALLOW_ASYNC_UNSAFE 1
@ -13,8 +13,6 @@ COPY requirements.txt /code/requirements.txt
COPY docs/requirements.txt /code/docs/requirements.txt
RUN pip install -r requirements.txt --no-cache-dir
RUN pip install -r docs/requirements.txt --no-cache-dir
# FIXME Remove this line when all dependencies will be ready
RUN pip install "Django>=4.2,<5.0"
COPY . /code/

View File

@ -0,0 +1,31 @@
# Generated by Django 5.0.1 on 2024-01-13 16:21
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("draw", "0001_initial"),
]
operations = [
migrations.AlterField(
model_name="teamdraw",
name="purposed",
field=models.PositiveSmallIntegerField(
choices=[
(1, "Problem #1"),
(2, "Problem #2"),
(3, "Problem #3"),
(4, "Problem #4"),
(5, "Problem #5"),
(6, "Problem #6"),
(7, "Problem #7"),
(8, "Problem #8"),
],
default=None,
null=True,
verbose_name="purposed problem",
),
),
]

View File

@ -4,6 +4,7 @@ crond -l 0
python manage.py migrate
python manage.py loaddata initial
python manage.py update_index
nginx

View File

@ -17,6 +17,7 @@ from django.utils.translation import gettext_lazy as _
from registration.models import VolunteerRegistration
from tfjm.lists import get_sympa_client
def get_motivation_letter_filename(instance, filename):
return f"authorization/motivation_letters/motivation_letter_{instance.trigram}"

View File

@ -7,7 +7,6 @@ from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.models import Site
from django.core.files.uploadedfile import SimpleUploadedFile
from django.core.management import call_command
from django.test import TestCase
from django.urls import reverse
from django.utils.encoding import force_bytes
@ -413,18 +412,18 @@ class TestRegistration(TestCase):
"""
Try to search some things.
"""
call_command("rebuild_index", "--noinput", "-v", 0)
response = self.client.get(reverse("haystack_search") + "?q=" + self.user.email)
response = self.client.get(reverse("haystack_search") + "?q=" + self.user.email + "&models=auth.user")
self.assertEqual(response.status_code, 200)
self.assertTrue(response.context["object_list"])
response = self.client.get(reverse("haystack_search") + "?q=" +
str(self.coach.registration.professional_activity))
str(self.coach.registration.professional_activity)
+ "&models=registration.CoachRegistration")
self.assertEqual(response.status_code, 200)
self.assertTrue(response.context["object_list"])
response = self.client.get(reverse("haystack_search") + "?q=" +
self.student.registration.get_student_class_display())
self.student.registration.school + "&models=registration.StudentRegistration")
self.assertEqual(response.status_code, 200)
self.assertTrue(response.context["object_list"])

View File

@ -1,26 +1,26 @@
channels[daphne]~=4.0.0
channels-redis~=4.0.0
crispy-bootstrap5~=0.7
Django>=4.1,<5.0
django-crispy-forms~=1.14
django-extensions~=3.2
django-filter~=22.1
django-haystack~=3.2
django-mailer~=2.2
django-phonenumber-field~=7.0
django-polymorphic~=3.1
django-tables2~=2.4
djangorestframework~=3.14
django-rest-polymorphic~=0.1
gunicorn~=20.1
channels-redis~=4.2.0
crispy-bootstrap5~=2023.10
Django>=5.0,<6.0
django-crispy-forms~=2.1
django-extensions~=3.2.3
django-filter~=23.5
elasticsearch~=7.17.9
git+https://github.com/django-haystack/django-haystack.git#v3.3b1
django-mailer~=2.3.1
django-phonenumber-field~=7.3.0
django-polymorphic~=3.1.0
django-tables2~=2.7.0
djangorestframework~=3.14.0
django-rest-polymorphic~=0.1.10
gunicorn~=21.2.0
odfpy~=1.4.1
phonenumbers~=8.12.57
psycopg2-binary~=2.9.5
pypdf~=3.4
ipython~=8.11.0
python-magic~=0.4.26
requests~=2.28.1
phonenumbers~=8.13.27
psycopg2-binary~=2.9.9
pypdf~=3.17.4
ipython~=8.20.0
python-magic~=0.4.27
requests~=2.31.0
sympasoap~=1.1
uvicorn~=0.17
websockets~=10.4
whoosh~=2.7
uvicorn~=0.25.0
websockets~=12.0

View File

@ -4,9 +4,6 @@
* * * * * cd /code && python manage.py retry_deferred -c 1
0 0 * * * cd /code && python manage.py purge_mail_log 7 -c 1
# Rebuild search index
0 * * * * cd /code && python manage.py update_index -v 0
# Recreate sympa lists
*/2 * * * * cd /code && python manage.py fix_sympa_lists &> /dev/null

View File

@ -203,13 +203,10 @@ DJANGO_TABLES2_TEMPLATE = 'django_tables2/bootstrap5.html'
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
'PATH': os.path.join(os.path.dirname(__file__), 'whoosh_index'),
'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
}
}
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
_db_type = os.getenv('DJANGO_DB_TYPE', 'sqlite').lower()
if _db_type == 'mysql' or _db_type.startswith('postgres') or _db_type == 'psql': # pragma: no cover

View File

@ -39,3 +39,13 @@ CHANNEL_LAYERS = {
},
},
}
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.elasticsearch7_backend.Elasticsearch7SearchEngine',
'URL': 'http://elasticsearch:9200/',
'INDEX_NAME': os.getenv('HAYSTACK_INDEX_NAME', 'inscription-tfjm'),
}
}
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'

32
tox.ini
View File

@ -1,7 +1,7 @@
[tox]
envlist =
py310
py311
py312
linters
skipsdist = True
@ -11,22 +11,22 @@ sitepackages = False
deps =
coverage
channels[daphne]~=4.0.0
crispy-bootstrap5~=0.7
Django>=4.2,<5.0
django-crispy-forms~=1.14
django-filter~=22.1
django-haystack~=3.2
django-phonenumber-field~=7.0
django-polymorphic~=3.1
django-tables2~=2.4
djangorestframework~=3.14
django-rest-polymorphic~=0.1
crispy-bootstrap5~=2023.10
Django>=5.0,<6.0
django-crispy-forms~=2.1
django-filter~=23.5
git+https://github.com/django-haystack/django-haystack.git#v3.3b1
django-phonenumber-field~=7.3.0
django-polymorphic~=3.1.0
django-tables2~=2.7.0
djangorestframework~=3.14.0
django-rest-polymorphic~=0.1.10
odfpy~=1.4.1
phonenumbers~=8.12.57
pypdf~=3.4
python-magic~=0.4.26
requests~=2.28.1
whoosh~=2.7
phonenumbers~=8.13.27
pypdf~=3.17.4
python-magic~=0.4.27
requests~=2.31.0
commands =
coverage run --source=api,draw,logs,participation,registration,tfjm ./manage.py test api/ draw/ logs/ participation/ registration/ tfjm/
coverage report -m