Skip to content

Commit

Permalink
update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
finnus committed Nov 10, 2023
1 parent e91d5d2 commit 90e626a
Show file tree
Hide file tree
Showing 8 changed files with 793 additions and 819 deletions.
1 change: 1 addition & 0 deletions compose/production/django/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ FROM debian:buster-slim AS runtime
RUN apt-get update \
# dependencies for building Python packages
&& apt-get install -y build-essential \
&& apt-get install -y apt-transport-https \
&& apt-get install -y git \
# psycopg2 dependencies
&& apt-get install -y libpq-dev \
Expand Down
7 changes: 3 additions & 4 deletions compose/production/postgres/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
FROM postgres:11.3

RUN apt-get update
RUN apt-get install -y postgresql-11-postgis-3
FROM postgis/postgis:14-3.3

COPY ./compose/production/postgres/maintenance /usr/local/bin/maintenance
RUN chmod +x /usr/local/bin/maintenance/*
RUN mv /usr/local/bin/maintenance/* /usr/local/bin \
&& rmdir /usr/local/bin/maintenance

COPY ./compose/production/postgres/initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh
20 changes: 20 additions & 0 deletions compose/production/postgres/initdb-postgis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh

set -e

# Perform all actions as $POSTGRES_USER
export PGUSER="$POSTGRES_USER"

# Create the 'template_postgis' template db
"${psql[@]}" <<- 'EOSQL'
CREATE DATABASE template_postgis IS_TEMPLATE true;
EOSQL

# Load PostGIS into both template_database and $POSTGRES_DB
for DB in template_postgis "$POSTGRES_DB"; do
echo "Loading PostGIS extensions into $DB"
"${psql[@]}" --dbname="$DB" <<-'EOSQL'
CREATE EXTENSION IF NOT EXISTS postgis;
CREATE EXTENSION IF NOT EXISTS postgis_raster;
EOSQL
done
2 changes: 1 addition & 1 deletion config/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
default="ClhEXXXwqBz5brFRauptYEGYzzKWK132COScW7DxBqGY6BLeh9lGYKUb3HIC9UZY",
)
# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
ALLOWED_HOSTS = ["localhost", "0.0.0.0", "127.0.0.1"]
ALLOWED_HOSTS = ["localhost", "0.0.0.0", "127.0.0.1", "172.18.0.3"]

# CACHES
# ------------------------------------------------------------------------------
Expand Down
23 changes: 23 additions & 0 deletions egon/static/js/results.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* globals activateChoropleth, deactivateChoropleth */

const layerSwitches = document.querySelectorAll(".choropleth");

layerSwitches.forEach(layerSwitch => {
layerSwitch.addEventListener("change", function() {
if (this.checked) {
layerSwitches.forEach(otherSwitch => {
if (otherSwitch.id !== layerSwitch.id) {
otherSwitch.checked = false;
deactivateChoropleth(null, otherSwitch.id);
map.setLayoutProperty(otherSwitch.dataset.geomLayer, "visibility", "none");

}
});
map.setLayoutProperty(layerSwitch.dataset.geomLayer, "visibility", "visible");
activateChoropleth(null, layerSwitch.id);
} else {
map.setLayoutProperty(layerSwitch.dataset.geomLayer, "visibility", "none");
deactivateChoropleth(null, layerSwitch.id);
}
});
});
26 changes: 26 additions & 0 deletions egon/utils/data_processing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import os

from django.contrib.gis.utils import LayerMapping
from import_export import resources
from tablib import Dataset

from config.settings.base import DATA_DIR
from egon.map import models
Expand Down Expand Up @@ -121,3 +123,27 @@ def empty_data(data_models=None):
data_models = data_models or MODELS
for model in data_models:
model.objects.all().delete()


class MapLayerResource(resources.ModelResource):
class Meta:
model = models.MapLayer
import_id_fields = ("id",) # If 'id' is the primary key field


def import_maplayer(file_name=None):
csv_file = os.path.join(DATA_DIR, file_name)
dataset = Dataset()
with open(csv_file, "r") as f:
imported_data = dataset.load(f.read(), format="csv")

models.MapLayer.objects.all().delete()

mymodel_resource = MapLayerResource()
result = mymodel_resource.import_data(imported_data, dry_run=True)

if not result.has_errors():
mymodel_resource.import_data(imported_data, dry_run=False)
print("Data imported successfully.")
else:
print("There was an error importing the data.")
1,509 changes: 707 additions & 802 deletions poetry.lock

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ services:
dockerfile: ./compose/production/django/Dockerfile
image: egon_production_django
restart: unless-stopped
networks:
- egon_network
- caddy_network
volumes:
- ./egon/data:/app/egon/data
- ./egon/static/mvts:/app/staticfiles/mvts
expose:
- "5000"
networks:
- egon_network
- caddy_network
volumes:
- ./egon/data:/app/egon/data
- ./egon/static/mvts:/app/staticfiles/mvts
expose:
- "5000"
depends_on:
- postgres
- redis
Expand All @@ -34,8 +34,8 @@ services:
image: egon_production_postgres
command: postgres -N 500
restart: always
networks:
- egon_network
networks:
- egon_network
volumes:
- production_postgres_data:/var/lib/postgresql/data
- production_postgres_data_backups:/backups
Expand All @@ -45,8 +45,8 @@ services:
redis:
image: redis:5.0
restart: always
networks:
- egon_network
networks:
- egon_network

networks:
egon_network:
Expand Down

0 comments on commit 90e626a

Please sign in to comment.