Compare commits

..

4 Commits

Author SHA1 Message Date
9863807ad6 Merge pull request '# QRCode fix' (#533) from django_6_upgrade into master
Reviewed-on: #533
2026-03-01 13:30:49 +00:00
62e02d745f # QRCode fix
* fixes bug where svg qr code would not be created properly since an upgrade of the package
2026-03-01 14:30:30 +01:00
1a9de7f874 Merge pull request '# Requirements update' (#531) from django_6_upgrade into master
Reviewed-on: #531
2026-03-01 13:02:52 +00:00
46b66eb95d # Requirements update
* updates requirements.txt
* fixes deprecated usage of certain functions brought by Django6.x
2026-03-01 14:02:33 +01:00
13 changed files with 75 additions and 233 deletions

View File

@@ -1,36 +0,0 @@
# Nutze ein schlankes Python-Image
FROM python:3.11-slim-bullseye
ENV PYTHONUNBUFFERED 1
WORKDIR /konova
# Installiere System-Abhängigkeiten
RUN apt-get update && apt-get install -y --no-install-recommends \
gdal-bin redis-server nginx \
&& rm -rf /var/lib/apt/lists/* # Platz sparen
# Erstelle benötigte Verzeichnisse & setze Berechtigungen
RUN mkdir -p /var/log/nginx /var/log/gunicorn /var/lib/nginx /tmp/nginx_client_body \
&& touch /var/log/nginx/access.log /var/log/nginx/error.log \
&& chown -R root:root /var/log/nginx /var/lib/nginx /tmp/nginx_client_body
# Kopiere und installiere Python-Abhängigkeiten
COPY ./requirements.txt /konova/
RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
# Entferne Standard-Nginx-Site und ersetze sie durch eigene Config
RUN rm -rf /etc/nginx/sites-enabled/default
COPY ./nginx.conf /etc/nginx/conf.d
# Kopiere restliche Projektdateien
COPY . /konova/
# Sammle statische Dateien
RUN python manage.py collectstatic --noinput
# Exponiere Ports
#EXPOSE 80 6379 8000
# Setze Entrypoint
ENTRYPOINT ["/konova/docker-entrypoint.sh"]

View File

@@ -4,7 +4,6 @@ the database postgresql and the css library bootstrap as well as the icon packag
fontawesome for a modern look, following best practices from the industry.
## Background processes
### !!! For non-docker run
Konova uses celery for background processing. To start the worker you need to run
```shell
$ celery -A konova worker -l INFO
@@ -19,58 +18,3 @@ Technical documention is provided in the projects git wiki.
A user documentation is not available (and not needed, yet).
# Docker
To run the docker-compose as expected, you need to take the following steps:
1. Create a database containing docker, using an appropriate Dockerfile, e.g. the following
```
version: '3.3'
services:
postgis:
image: postgis/postgis
restart: always
container_name: postgis-docker
ports:
- 5433:5432
volumes:
- db-volume:/var/lib/postgresql/data
environment:
- POSTGRES_PASSWORD=postgres
- POSTGRES_USER=postgres
networks:
- db-network-bridge
networks:
db-network-bridge:
driver: "bridge"
volumes:
db-volume:
```
This Dockerfile creates a Docker container running postgresql and postgis, creates the default superuser postgres,
creates a named volume for persisting the database and creates a new network bridge, which **must be used by any other
container, which wants to write/read on this database**.
2. Make sure the name of the network bridge above matches the network in the konova docker-compose.yml
3. Get into the running postgis container (`docker exec -it postgis-docker bash`) and create new databases, users and so on. Make sure the database `konova` exists now!
4. Replace all `CHANGE_ME_xy` values inside of konova/docker-compose.yml for your installation. Make sure the `SSO_HOST` holds the proper SSO host, e.g. for the arnova project `arnova.example.org` (Arnova must be installed and the webserver configured as well, of course)
5. Take a look on konova/settings.py and konova/sub_settings/django_settings.py. Again: Replace all occurences of `CHANGE_ME` with proper values for your installation.
1. Make sure you have the proper host strings added to `ALLOWED_HOSTS` inside of django_settings.py.
6. Build and run the docker setup using `docker-compose build` and `docker-compose start` from the main directory of this project (where the docker-compose.yml lives)
7. Run migrations! To do so, get into the konova service container (`docker exec -it konova-docker bash`) and run the needed commands (`python manage.py makemigrations LIST_OF_ALL_MIGRATABLE_APPS`, then `python manage.py migrate`)
8. Run the setup command `python manage.py setup` and follow the instructions on the CLI
9. To enable **SMTP** mail support, make sure your host machine (the one where the docker container run) has the postfix service configured properly. Make sure the `mynetworks` variable is xtended using the docker network bridge ip, created in the postgis container and used by the konova services.
1. **Hint**: You can find out this easily by trying to perform a test mail in the running konova web application (which will fail, of course). Then take a look to the latest entries in `/var/log/mail.log` on your host machine. The failed IP will be displayed there.
2. **Please note**: This installation guide is based on SMTP using postfix!
3. Restart the postfix service on your host machine to reload the new configuration (`service postfix restart`)
10. Finally, make sure your host machine webserver passes incoming requests properly to the docker nginx webserver of konova. A proper nginx config for the host machine may look like this:
```
server {
server_name konova.domain.org;
location / {
proxy_pass http://localhost:KONOVA_NGINX_DOCKER_PORT/;
proxy_set_header Host $host;
}
}
```

View File

@@ -124,7 +124,7 @@ class CompensationTable(BaseTable, TableRenderMixin, TableOrderMixin):
html += self.render_previously_checked_star(
tooltip=tooltip,
)
return format_html(html)
return format_html(html, None)
def render_r(self, value, record: Compensation):
""" Renders the registered column for a compensation
@@ -146,5 +146,5 @@ class CompensationTable(BaseTable, TableRenderMixin, TableOrderMixin):
tooltip=tooltip,
icn_filled=recorded,
)
return format_html(html)
return format_html(html, None)

View File

@@ -95,7 +95,7 @@ class EcoAccountTable(BaseTable, TableRenderMixin, TableOrderMixin):
txt=value,
new_tab=False,
)
return format_html(html)
return format_html(html, None)
def render_av(self, value, record: EcoAccount):
""" Renders the available column for an eco account
@@ -113,7 +113,7 @@ class EcoAccountTable(BaseTable, TableRenderMixin, TableOrderMixin):
value_relative = 0
html = render_to_string("konova/widgets/progressbar.html", {"value": value_relative})
html += f"{number_format(record.deductable_rest, decimal_pos=2)}"
return format_html(html)
return format_html(html, None)
def render_r(self, value, record: EcoAccount):
""" Renders the recorded column for an eco account
@@ -135,4 +135,4 @@ class EcoAccountTable(BaseTable, TableRenderMixin, TableOrderMixin):
tooltip=tooltip,
icn_filled=checked,
)
return format_html(html)
return format_html(html, None)

View File

@@ -1,21 +0,0 @@
services:
konova:
external_links:
- postgis:db
- arnova-nginx-server:arnova
build: .
image: "ksp/konova:x.y"
container_name: "konova-docker"
command: ./docker-entrypoint.sh
restart: always
volumes:
- /data/apps/konova/uploaded_files:/konova_uploaded_files
ports:
- "1337:80"
# Instead of an own, new network, we need to connect to the existing one, which is provided by the postgis container
# NOTE: THIS NETWORK MUST EXIST
networks:
default:
name: postgis_nat_it_backend
external: true

View File

@@ -1,27 +0,0 @@
#!/bin/bash
set -e # Beende Skript bei Fehlern
set -o pipefail # Fehler in Pipelines nicht ignorieren
# Starte Redis
redis-server --daemonize yes
# Starte Celery Worker im Hintergrund
celery -A konova worker --loglevel=info &
# Starte Nginx als Hintergrundprozess
nginx -g "daemon off;" &
# Setze Gunicorn Worker-Anzahl (Standard: (2*CPUs)+1)
WORKERS=${GUNICORN_WORKERS:-$((2 * $(nproc) + 1))}
# Stelle sicher, dass Logs existieren
mkdir -p /var/log/gunicorn
touch /var/log/gunicorn/access.log /var/log/gunicorn/error.log
# Starte Gunicorn als Hauptprozess
exec gunicorn --workers="$WORKERS" konova.wsgi:application \
--bind=0.0.0.0:8000 \
--access-logfile /var/log/gunicorn/access.log \
--error-logfile /var/log/gunicorn/error.log \
--access-logformat '%({x-real-ip}i)s via %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"'

View File

@@ -88,7 +88,7 @@ class EmaTable(BaseTable, TableRenderMixin, TableOrderMixin):
txt=value,
new_tab=False,
)
return format_html(html)
return format_html(html, None)
def render_r(self, value, record: Ema):
""" Renders the registered column for a EMA
@@ -110,4 +110,4 @@ class EmaTable(BaseTable, TableRenderMixin, TableOrderMixin):
tooltip=tooltip,
icn_filled=recorded,
)
return format_html(html)
return format_html(html, None)

View File

@@ -127,7 +127,7 @@ class InterventionTable(BaseTable, TableRenderMixin, TableOrderMixin):
html += self.render_previously_checked_star(
tooltip=tooltip,
)
return format_html(html)
return format_html(html, None)
def render_r(self, value, record: Intervention):
""" Renders the recorded column for an intervention
@@ -149,5 +149,5 @@ class InterventionTable(BaseTable, TableRenderMixin, TableOrderMixin):
tooltip=tooltip,
icn_filled=checked,
)
return format_html(html)
return format_html(html, None)

View File

@@ -191,10 +191,11 @@ STATICFILES_DIRS = [
]
# EMAIL (see https://docs.djangoproject.com/en/dev/topics/email/)
# CHANGE_ME !!! ONLY FOR DEVELOPMENT !!!
if DEBUG:
# ONLY FOR DEVELOPMENT NEEDED
EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
EMAIL_FILE_PATH = '/tmp/app-messages'
EMAIL_FILE_PATH = '/tmp/app-messages' # change this to a proper location
DEFAULT_FROM_EMAIL = env("DEFAULT_FROM_EMAIL") # The default email address for the 'from' element
SERVER_EMAIL = DEFAULT_FROM_EMAIL # The default email sender address, which is used by Django to send errors via mail

View File

@@ -30,15 +30,17 @@ class QrCode:
Returns:
qrcode_svg (str): The qr code as svg
"""
img_factory = svg.SvgImage
qrcode_img = qrcode.make(
content,
image_factory=img_factory,
qr = qrcode.QRCode(
image_factory=qrcode.image.svg.SvgPathImage,
box_size=size
)
stream = BytesIO()
qrcode_img.save(stream)
return stream.getvalue().decode()
qr.add_data(content)
qr.make(
fit=True
)
img = qr.make_image()
return img.to_string(encoding="unicode")
def get_img(self):
return self._img

View File

@@ -178,7 +178,9 @@ class TableRenderMixin:
if len(value) > max_length:
value = f"{value[:max_length]}..."
value = format_html(
f'<div title="{value_orig}">{value}</div>'
'<div title="{}">{}</div>',
value_orig,
value
)
return value
@@ -222,7 +224,7 @@ class TableRenderMixin:
tooltip=_("Full access granted") if is_entry_shared else _("Access not granted"),
icn_class="fas fa-edit rlp-r-inv" if is_entry_shared else "far fa-edit",
)
return format_html(html)
return format_html(html, None)
class TableOrderMixin:

View File

@@ -1,25 +0,0 @@
server {
listen 80;
client_max_body_size 25M;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_redirect off;
proxy_cache_bypass $http_upgrade;
}
location /static/ {
alias /konova/static/;
access_log /var/log/nginx/access.log;
autoindex off;
types {
text/css css;
application/javascript js;
}
}
error_log /var/log/nginx/error.log;
}

View File

@@ -1,63 +1,65 @@
amqp==5.3.1
asgiref==3.8.1
asgiref==3.11.1
async-timeout==5.0.1
beautifulsoup4==4.13.0b2
billiard==4.2.1
beautifulsoup4==4.14.3
billiard==4.2.4
cached-property==2.0.1
celery==5.4.0
certifi==2024.12.14
cffi==1.17.1
chardet==5.2.0
charset-normalizer==3.4.0
click==8.1.8
celery==5.6.2
certifi==2026.2.25
cffi==2.0.0
chardet==6.0.0.post1
charset-normalizer==3.4.4
click==8.3.1
click-didyoumean==0.3.1
click-plugins==1.1.1
click-plugins==1.1.1.2
click-repl==0.3.0
coverage==7.6.9
cryptography==44.0.0
Deprecated==1.2.15
Django==5.1.4
django-autocomplete-light==3.11.0
coverage==7.13.4
cryptography==46.0.5
Deprecated==1.3.1
Django==6.0.2
django-autocomplete-light==3.12.1
django-bootstrap-modal-forms==3.0.5
django-bootstrap4==24.4
django-environ==0.11.2
django-filter==24.3
django-bootstrap4==26.1
django-environ==0.13.0
django-filter==25.2
django-fontawesome-5==1.0.18
django-oauth-toolkit==3.0.1
django-tables2==2.7.1
django-oauth-toolkit==3.2.0
django-tables2==2.8.0
et_xmlfile==2.0.0
gunicorn==23.0.0
idna==3.10
importlib_metadata==8.5.0
gunicorn==25.1.0
idna==3.11
importlib_metadata==8.7.1
itsdangerous==2.2.0
jwcrypto==1.5.6
kombu==5.4.0rc1
oauthlib==3.2.2
kombu==5.6.2
oauthlib==3.3.1
openpyxl==3.2.0b1
packaging==24.2
packaging==26.0
pika==1.3.2
pillow==11.0.0
prompt_toolkit==3.0.48
psycopg==3.2.3
psycopg-binary==3.2.3
pycparser==2.22
pyparsing==3.2.0
pillow==12.1.1
prompt_toolkit==3.0.52
psycopg==3.3.3
psycopg-binary==3.3.3
pycparser==3.0
pyparsing==3.3.2
pypng==0.20220715.0
pyproj==3.7.0
pyproj==3.7.2
python-dateutil==2.9.0.post0
pytz==2024.2
PyYAML==6.0.2
qrcode==7.3.1
redis==5.1.0b6
requests<2.32.0
six==1.16.0
soupsieve==2.5
sqlparse==0.5.1
typing_extensions==4.12.2
tzdata==2024.2
urllib3==2.3.0
pytz==2025.2
PyYAML==6.0.3
qrcode==8.2
redis==7.2.1
requests==2.32.5
six==1.17.0
soupsieve==2.8.3
sqlparse==0.5.5
typing_extensions==4.15.0
tzdata==2025.3
tzlocal==5.3.1
urllib3==2.6.3
vine==5.1.0
wcwidth==0.2.13
wcwidth==0.6.0
webservices==0.7
wrapt==1.16.0
xmltodict==0.14.2
zipp==3.21.0
wrapt==2.1.1
xmltodict==1.0.4
zipp==3.23.0