From 02fe21c7232f63921f255e12a6e7908dd45236db Mon Sep 17 00:00:00 2001 From: Jens Date: Tue, 20 Aug 2024 19:55:00 +0200 Subject: [PATCH 1/2] add CZ to Worldtravel seed --- .../management/commands/worldtravel-seed.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/backend/server/worldtravel/management/commands/worldtravel-seed.py b/backend/server/worldtravel/management/commands/worldtravel-seed.py index 4a2eab08..6741f6aa 100644 --- a/backend/server/worldtravel/management/commands/worldtravel-seed.py +++ b/backend/server/worldtravel/management/commands/worldtravel-seed.py @@ -67,6 +67,7 @@ def handle(self, *args, **options): ('Switzerland', 'ch', 'EU'), ('Italy', 'it', 'EU'), ('Iceland', 'is', 'EU'), + ('Czech Republic', 'cz', 'EU'), ] regions = [ @@ -523,6 +524,20 @@ def handle(self, *args, **options): ('IS-6', 'Norðurland eystra', 'is'), ('IS-7', 'Austurland', 'is'), ('IS-8', 'Suðurland', 'is'), + ('CZ-10', 'Prague', 'cz'), + ('CZ-20', 'Středočeský kraj', 'cz'), + ('CZ-31', 'Jihočeský kraj', 'cz'), + ('CZ-32', 'Plzeňský kraj', 'cz'), + ('CZ-41', 'Karlovarský kraj', 'cz'), + ('CZ-42', 'Ústecký kraj', 'cz'), + ('CZ-51', 'Liberecký kraj', 'cz'), + ('CZ-52', 'Královéhradecký kraj', 'cz'), + ('CZ-53', 'Pardubický kraj', 'cz'), + ('CZ-63', 'Kraj Vysočina', 'cz'), + ('CZ-64', 'Jihomoravský kraj', 'cz'), + ('CZ-71', 'Olomoucký kraj', 'cz'), + ('CZ-72', 'Zlínský kraj', 'cz'), + ('CZ-80', 'Moravskoslezský kraj', 'cz'), ] From df1fda4ce67fd47b6733e7bfcbf4672bd62c4a73 Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Tue, 20 Aug 2024 14:37:18 -0400 Subject: [PATCH 2/2] Add CZ and CRON for worldtravel seed --- backend/Dockerfile | 19 ++++++++++++++++--- .../management/commands/worldtravel-seed.py | 1 - 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index a093cdfd..faa018a6 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -13,7 +13,7 @@ WORKDIR /code # Install system dependencies RUN apt-get update \ - && apt-get install -y git postgresql-client \ + && apt-get install -y git postgresql-client cron \ && apt-get clean # Install Python dependencies @@ -24,9 +24,22 @@ RUN pip install -r requirements.txt # Copy the Django project code into the Docker image COPY ./server /code/ -RUN python3 manage.py collectstatic --verbosity 2 +# Collect static files +RUN python3 manage.py collectstatic --noinput --verbosity 2 + +# Setup cron to run python3 manage.py worldtravel-seed every day at 00:00 +RUN echo "0 0 * * * python3 /code/manage.py worldtravel-seed --force >> /var/log/cron.log 2>&1" > /etc/cron.d/worldtravel-seed + +# Give execution rights on the cron job +RUN chmod 0644 /etc/cron.d/worldtravel-seed + +# Apply cron job +RUN crontab /etc/cron.d/worldtravel-seed + +# Ensure cron is started in the foreground when the container starts +CMD ["cron", "-f"] # Set the entrypoint script COPY ./entrypoint.sh /code/entrypoint.sh RUN chmod +x /code/entrypoint.sh -ENTRYPOINT ["/code/entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["/code/entrypoint.sh"] diff --git a/backend/server/worldtravel/management/commands/worldtravel-seed.py b/backend/server/worldtravel/management/commands/worldtravel-seed.py index 6741f6aa..82fde9bd 100644 --- a/backend/server/worldtravel/management/commands/worldtravel-seed.py +++ b/backend/server/worldtravel/management/commands/worldtravel-seed.py @@ -524,7 +524,6 @@ def handle(self, *args, **options): ('IS-6', 'Norðurland eystra', 'is'), ('IS-7', 'Austurland', 'is'), ('IS-8', 'Suðurland', 'is'), - ('CZ-10', 'Prague', 'cz'), ('CZ-20', 'Středočeský kraj', 'cz'), ('CZ-31', 'Jihočeský kraj', 'cz'), ('CZ-32', 'Plzeňský kraj', 'cz'),