diff --git a/Dockerfile b/Dockerfile index 5ecb4460..fa8035f8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,17 @@ FROM python:3.13-slim-bookworm COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ -# Copy the application code to the container: -RUN mkdir /code/ +# Set the working directory WORKDIR /code/ -ADD . /code/ -# Install all build deps: +# Copy dependency definition files and install dependencies first for better caching +COPY pyproject.toml uv.lock* ./ +RUN uv sync --frozen + +# Copy the rest of the application code +COPY . . + +# Install system-level build dependencies RUN set -ex \ && apt-get update \ && apt-get install -y --no-install-recommends \ @@ -16,21 +21,21 @@ RUN set -ex \ libpq-dev \ make \ postgresql-client \ - || (cat /var/log/apt/term.log || true) \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -RUN uv sync --frozen - -# expose port +# Expose the application port EXPOSE 8000 -# Docker entrypoint: +# Set environment variables for the entrypoint script +# and add the virtual environment to the PATH. This is the key fix. ENV DJANGO_MANAGEPY_MIGRATE=on \ DJANGO_MANAGEPY_COLLECTSTATIC=on \ - DJANGO_MANAGEPY_UPDATEINDEX=on + DJANGO_MANAGEPY_UPDATEINDEX=on \ + PATH="/code/.venv/bin:$PATH" +# Set the entrypoint ENTRYPOINT ["/code/docker-entrypoint.sh"] -# Start python runserver: -CMD ["uv", "run", "python", "manage.py", "runserver", "0.0.0.0:8000"] +# Set the default command to run the development server +CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"] diff --git a/docker-compose.yml b/docker-compose.yml index 751887c8..3f2e81ba 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,7 +18,9 @@ services: depends_on: - db ports: - - 8000:8000 + - 8001:8000 + networks: + - wagtailstreamforms-net db: image: postgres:16.0 environment: @@ -28,5 +30,9 @@ services: - PGDATA=/var/lib/postgresql/data/pgdata volumes: - ./.postgres:/var/lib/postgresql/data/pgdata - ports: - - 5432:5432 + networks: + - wagtailstreamforms-net + +networks: + wagtailstreamforms-net: + driver: bridge diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 3ea49615..f360ae73 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -10,15 +10,15 @@ done; echo 'Connected to db...'; if [ "x$DJANGO_MANAGEPY_MIGRATE" = 'xon' ]; then - python manage.py migrate --noinput + uv run python manage.py migrate --noinput fi if [ "x$DJANGO_MANAGEPY_COLLECTSTATIC" = 'xon' ]; then - python manage.py collectstatic --noinput + uv run python manage.py collectstatic --noinput fi if [ "x$DJANGO_MANAGEPY_UPDATEINDEX" = 'xon' ]; then - python manage.py update_index + uv run python manage.py update_index fi exec "$@" \ No newline at end of file diff --git a/uv.lock b/uv.lock index 612cdd8f..bcc7f01d 100644 --- a/uv.lock +++ b/uv.lock @@ -933,7 +933,7 @@ wheels = [ [[package]] name = "wagtailstreamforms" -version = "5.0.0" +version = "5.2.0" source = { editable = "." } dependencies = [ { name = "django-recaptcha" }, @@ -960,8 +960,8 @@ requires-dist = [ { name = "psycopg", specifier = ">=3.2.9" }, { name = "tox", specifier = ">=4.26.0" }, { name = "unidecode", specifier = ">=0.4.14,<2.0" }, - { name = "wagtail", specifier = ">=4.1,<7.0" }, - { name = "wagtail-generic-chooser", specifier = ">=0.5.0,<0.7" }, + { name = "wagtail", specifier = ">=6.0,<8.0" }, + { name = "wagtail-generic-chooser", specifier = ">=0.5.0" }, { name = "wagtail-modeladmin", specifier = ">=2.2.0" }, ] diff --git a/wagtailstreamforms/migrations/0004_form_error_title_form_success_title.py b/wagtailstreamforms/migrations/0004_form_error_title_form_success_title.py new file mode 100644 index 00000000..3f68e243 --- /dev/null +++ b/wagtailstreamforms/migrations/0004_form_error_title_form_success_title.py @@ -0,0 +1,35 @@ +# Generated by Django 4.2.20 on 2025-08-09 21:48 + +from django.db import migrations, connection + +def add_custom_form_fields(apps, schema_editor): + """ + Adds the success_title and error_title columns to the Form table + only if they do not already exist. + """ + Form = apps.get_model('wagtailstreamforms', 'Form') + table_name = Form._meta.db_table + + with connection.cursor() as cursor: + # Use a list to store columns to check and add + columns_to_add = { + 'error_title': "VARCHAR(64) DEFAULT 'Achtung! Bitte korrigieren Sie die Formfehler' NULL", + 'success_title': "VARCHAR(64) DEFAULT 'Vielen Dank für Ihren Beitrag' NULL" + } + + # Get existing columns for the table + existing_columns = [col.name for col in connection.introspection.get_table_description(cursor, table_name)] + + for column_name, column_definition in columns_to_add.items(): + if column_name not in existing_columns: + cursor.execute(f"ALTER TABLE {table_name} ADD COLUMN {column_name} {column_definition}") + +class Migration(migrations.Migration): + + dependencies = [ + ('wagtailstreamforms', '0003_alter_form_fields'), + ] + + operations = [ + migrations.RunPython(add_custom_form_fields, migrations.RunPython.noop), + ] diff --git a/wagtailstreamforms/models/form.py b/wagtailstreamforms/models/form.py index fa7358e9..ffde5974 100644 --- a/wagtailstreamforms/models/form.py +++ b/wagtailstreamforms/models/form.py @@ -47,6 +47,17 @@ class AbstractForm(models.Model): submit_button_text = models.CharField( _("Submit button text"), max_length=100, default="Submit" ) + # MIG - This is a custom field used to display title on modal https://app.clickup.com/t/1tdvqwe + success_title = models.CharField( + _("Success Title"), + null=True, + blank=False, + max_length=64, + default=_("Vielen Dank für Ihren Beitrag"), + help_text=_( + "An optional success title to show when the form has validation errors" + ), + ) success_message = models.CharField( _("Success message"), blank=True, @@ -55,6 +66,17 @@ class AbstractForm(models.Model): "An optional success message to show when the form has been successfully submitted" ), ) + # MIG - This is a custom field used to display title on modal https://app.clickup.com/t/1tdvqwe + error_title = models.CharField( + _("Error Title"), + null=True, + blank=False, + max_length=64, + default=_("Achtung! Bitte korrigieren Sie die Formfehler"), + help_text=_( + "An optional error title to show when the form has validation errors" + ), + ) error_message = models.CharField( _("Error message"), blank=True,