diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 51d9232..643f064 100755 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.9" + python-version: "3.12" #cache: pip #cache-dependency-path: | # requirements/base.txt diff --git a/.gitignore b/.gitignore index a3cd991..5bdb313 100644 --- a/.gitignore +++ b/.gitignore @@ -173,4 +173,7 @@ cython_debug/ # End of https://www.toptal.com/developers/gitignore/api/django -llama3/llama-3.2/* \ No newline at end of file +llama3/llama-3.2/* + +# Local vendor dir for one-off translation scripts (deep-translator) +.vendor_trans/ \ No newline at end of file diff --git a/compose/local/django/Dockerfile b/compose/local/django/Dockerfile index 4fe37f1..c82c59f 100755 --- a/compose/local/django/Dockerfile +++ b/compose/local/django/Dockerfile @@ -1,4 +1,4 @@ -ARG PYTHON_VERSION=3.11-bullseye +ARG PYTHON_VERSION=3.12-bookworm # define an alias for the specfic python version used in this file. FROM python:${PYTHON_VERSION} AS python @@ -20,11 +20,8 @@ RUN apt-get update && apt-get install --no-install-recommends -y \ libopenblas-dev \ libomp-dev -# Instalar gcc-10 y g++-10 en Debian Bullseye RUN apt-get update && \ - apt-get install -y gcc-10 g++-10 ninja-build cmake && \ - update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 50 && \ - update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 50 && \ + apt-get install -y ninja-build cmake && \ apt-get clean && rm -rf /var/lib/apt/lists/* # Actualizar pip, setuptools y wheel antes de instalar dependencias @@ -55,7 +52,11 @@ ENV BUILD_ENV ${BUILD_ENVIRONMENT} WORKDIR ${APP_HOME} -RUN sed -i 's/main/main contrib non-free/' /etc/apt/sources.list +RUN if [ -f /etc/apt/sources.list ]; then \ + sed -i 's/main/main contrib non-free/' /etc/apt/sources.list; \ + elif [ -f /etc/apt/sources.list.d/debian.sources ]; then \ + sed -i 's/Components: main/Components: main contrib non-free non-free-firmware/' /etc/apt/sources.list.d/debian.sources; \ + fi # Install required system dependencies RUN apt-get update && apt-get install --no-install-recommends -y \ diff --git a/compose/production/django/Dockerfile b/compose/production/django/Dockerfile index 34b6e6f..a1c9472 100755 --- a/compose/production/django/Dockerfile +++ b/compose/production/django/Dockerfile @@ -1,4 +1,4 @@ -ARG PYTHON_VERSION=3.11-bullseye +ARG PYTHON_VERSION=3.12-bookworm # define an alias for the specfic python version used in this file. FROM python:${PYTHON_VERSION} as python @@ -44,7 +44,11 @@ WORKDIR ${APP_HOME} RUN addgroup --system django \ && adduser --system --ingroup django django -RUN sed -i 's/main/main contrib non-free/' /etc/apt/sources.list +RUN if [ -f /etc/apt/sources.list ]; then \ + sed -i 's/main/main contrib non-free/' /etc/apt/sources.list; \ + elif [ -f /etc/apt/sources.list.d/debian.sources ]; then \ + sed -i 's/Components: main/Components: main contrib non-free non-free-firmware/' /etc/apt/sources.list.d/debian.sources; \ + fi # Install required system dependencies RUN apt-get update && apt-get install --no-install-recommends -y \ diff --git a/compose/production/django/Dockerfile.llama b/compose/production/django/Dockerfile.llama index 8ad536d..83c1c49 100755 --- a/compose/production/django/Dockerfile.llama +++ b/compose/production/django/Dockerfile.llama @@ -1,4 +1,4 @@ -ARG PYTHON_VERSION=3.11-bullseye +ARG PYTHON_VERSION=3.12-bookworm # define an alias for the specfic python version used in this file. FROM python:${PYTHON_VERSION} as python @@ -50,7 +50,11 @@ WORKDIR ${APP_HOME} RUN addgroup --system django \ && adduser --system --ingroup django django -RUN sed -i 's/main/main contrib non-free/' /etc/apt/sources.list +RUN if [ -f /etc/apt/sources.list ]; then \ + sed -i 's/main/main contrib non-free/' /etc/apt/sources.list; \ + elif [ -f /etc/apt/sources.list.d/debian.sources ]; then \ + sed -i 's/Components: main/Components: main contrib non-free non-free-firmware/' /etc/apt/sources.list.d/debian.sources; \ + fi # Install required system dependencies RUN apt-get update && apt-get install --no-install-recommends -y \ diff --git a/config/settings/base.py b/config/settings/base.py index f4b30c6..a207502 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -62,6 +62,7 @@ "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", + "django.contrib.postgres", "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", diff --git a/config/settings/local.py b/config/settings/local.py index ac26ea4..9844113 100644 --- a/config/settings/local.py +++ b/config/settings/local.py @@ -21,6 +21,10 @@ # SECURITY WARNING: define the correct hosts in production! ALLOWED_HOSTS = ["*"] +CSRF_TRUSTED_ORIGINS = env.list( + "DJANGO_CSRF_TRUSTED_ORIGINS", + default=["https://tools-hml.scielo.org"], +) EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" diff --git a/config/settings/production.py b/config/settings/production.py index 459938d..9c3910f 100644 --- a/config/settings/production.py +++ b/config/settings/production.py @@ -15,6 +15,8 @@ SECRET_KEY = env("DJANGO_SECRET_KEY") # https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts ALLOWED_HOSTS = env.list("DJANGO_ALLOWED_HOSTS", default=["example.com"]) +# https://docs.djangoproject.com/en/dev/ref/settings/#csrf-trusted-origins +CSRF_TRUSTED_ORIGINS = env.list("DJANGO_CSRF_TRUSTED_ORIGINS", default=[]) # DATABASES # ------------------------------------------------------------------------------ diff --git a/markup_doc/wagtail_hooks.py b/markup_doc/wagtail_hooks.py index a4812f8..356c10b 100644 --- a/markup_doc/wagtail_hooks.py +++ b/markup_doc/wagtail_hooks.py @@ -1,8 +1,14 @@ +from django.db import transaction from django.http import HttpResponseRedirect -from django.utils.translation import gettext_lazy as _ from django.template.response import TemplateResponse +from django.templatetags.static import static +from django.urls import path +from django.utils.html import format_html +from django.utils.translation import gettext_lazy as _ +from wagtail import hooks +from wagtail.admin import messages from wagtail_modeladmin.options import ModelAdmin - +from wagtail.snippets.models import register_snippet from wagtail.snippets.views.snippets import ( CreateView, EditView, @@ -20,13 +26,9 @@ ProcessStatus ) -from markup_doc.tasks import get_labels, task_sync_journals_from_api -from wagtail.admin import messages - -from wagtail.snippets.models import register_snippet -from django.db import transaction - +from markup_doc import views from markup_doc.sync_api import sync_collection_from_api +from markup_doc.tasks import get_labels, task_sync_journals_from_api, update_xml diff --git a/requirements/base.txt b/requirements/base.txt index ae76283..f48d0f1 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -1,3 +1,4 @@ +setuptools>=68.2.2,<82 whitenoise==6.6.0 # https://github.com/evansd/whitenoise redis==5.0.1 # https://github.com/redis/redis-py celery==5.3.6 # pyup: < 6.0 # https://github.com/celery/celery @@ -6,22 +7,19 @@ hiredis==2.2.3 # https://github.com/redis/hiredis-py # Django # ------------------------------------------------------------------------------ -django==5.0.8 -django-environ==0.11.2 -djangorestframework==3.15.2 -djangorestframework-simplejwt==5.3.1 # https://django-rest-framework-simplejwt.readthedocs.io/en/latest/ -django-celery-beat==2.6.0 # https://github.com/celery/django-celery-beat -django_celery_results==2.5.1 -django-compressor==4.4 # https://github.com/django-compressor/django-compressor +django==6.0.5 +django-environ==0.13.0 +djangorestframework==3.17.1 +djangorestframework-simplejwt==5.5.1 # https://django-rest-framework-simplejwt.readthedocs.io/en/latest/ +django-celery-beat==2.9.0 # https://github.com/celery/django-celery-beat +django_celery_results==2.6.0 +django-compressor==4.6.0 # https://github.com/django-compressor/django-compressor # Wagtail # ------------------------------------------------------------------------------ -wagtail==6.3 -wagtail-modeladmin==2.1.0 -wagtail-django-recaptcha==2.1.1 -wagtailmenus==3.1.9 -wagtail-localize==1.8.2 -wagtail-autocomplete==0.11.0 +wagtail==7.4 +wagtail-modeladmin==2.3.0 +wagtail-autocomplete==0.12.0 # lxml # ------------------------------------------------------------------------------ @@ -55,8 +53,3 @@ python-docx==1.1.2 # huggingface-hub # ------------------------------------------------------------------------------ huggingface_hub==0.26.1 # https://pypi.org/project/huggingface-hub/ - -# Python Bindings for llama.cpp -# ------------------------------------------------------------------------------ -llama-cpp-python==0.3.14 # https://llama-cpp-python.readthedocs.io/en/latest/ - diff --git a/requirements/production.txt b/requirements/production.txt index a7f3fed..3bde9f4 100644 --- a/requirements/production.txt +++ b/requirements/production.txt @@ -10,7 +10,7 @@ sentry-sdk[django]==2.5.1 # https://github.com/getsentry/sentry-python # Django # ------------------------------------------------------------------------------ django-anymail # https://github.com/anymail/django-anymail -setuptools>=68.2.2 # not directly required, pinned by Snyk to avoid a vulnerability +setuptools>=68.2.2,<82 # Elastic-APM # https://pypi.org/project/elastic-apm/