Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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"]
12 changes: 9 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ services:
depends_on:
- db
ports:
- 8000:8000
- 8001:8000
networks:
- wagtailstreamforms-net
db:
image: postgres:16.0
environment:
Expand All @@ -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
6 changes: 3 additions & 3 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
6 changes: 3 additions & 3 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -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),
]
22 changes: 22 additions & 0 deletions wagtailstreamforms/models/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down