Compare commits
35 commits
11683-add-
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
493626336f | ||
f3ada439fa | |||
|
b3b2a73fc9 | ||
|
df467691b8 | ||
|
2a6434e569 | ||
|
87332a9f05 | ||
|
822fca63c3 | ||
|
9618ac0094 | ||
|
a7abe02784 | ||
|
454767b551 | ||
|
99eb7c39fe | ||
|
780a4ce2d7 | ||
|
31a0a6b060 | ||
|
a68dcb7574 | ||
|
fc6f9e43a7 | ||
|
34ad67e8cd | ||
|
cd99b1bc4f | ||
c5026ad0eb | |||
|
a3cdc6b58a | ||
|
b918903fcf | ||
|
5ba9ee52ea | ||
|
5c173f0ffb | ||
|
c88b94f20f | ||
|
c18fb883cc | ||
|
d24fcd7d86 | ||
|
daf3a6baad | ||
|
b5e786e098 | ||
|
c013387b03 | ||
|
aaf1fc1d9b | ||
|
1af8fe3767 | ||
|
0e0b464534 | ||
|
9863959d88 | ||
|
6e835a10e6 | ||
|
4099b039f5 | ||
|
53ae04404b |
8 changed files with 210 additions and 21 deletions
104
Dockerfile
Normal file
104
Dockerfile
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
#FROM python:3.10-alpine
|
||||||
|
FROM docker.io/python:3.10-slim AS base
|
||||||
|
|
||||||
|
ENV \
|
||||||
|
LANG=C.UTF-8 \
|
||||||
|
LC_ALL=C.UTF-8 \
|
||||||
|
# python:
|
||||||
|
PYTHONFAULTHANDLER=1 \
|
||||||
|
PYTHONUNBUFFERED=1 \
|
||||||
|
PYTHONHASHSEED=random \
|
||||||
|
PYTHONDONTWRITEBYTECODE=1
|
||||||
|
|
||||||
|
RUN apt-get update
|
||||||
|
|
||||||
|
RUN apt-get install -y --no-install-recommends libmagic-dev libglib2.0-dev libpango-1.0-0 libpangoft2-1.0-0
|
||||||
|
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y curl gnupg && \
|
||||||
|
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
|
||||||
|
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
|
||||||
|
apt-get update && \
|
||||||
|
apt-get install -y yarn && \
|
||||||
|
apt-get install -y --no-install-recommends build-essential gcc && \
|
||||||
|
apt-get clean && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
ENV VIRTUAL_ENV=/venv
|
||||||
|
|
||||||
|
# Use production configuration.
|
||||||
|
ENV DJANGO_SETTINGS_MODULE=publichealth.settings
|
||||||
|
ENV DJANGO_CONFIGURATION=production
|
||||||
|
|
||||||
|
|
||||||
|
### builder image
|
||||||
|
|
||||||
|
FROM base as build
|
||||||
|
|
||||||
|
ENV \
|
||||||
|
# pip:
|
||||||
|
PIP_NO_CACHE_DIR=off \
|
||||||
|
PIP_DISABLE_PIP_VERSION_CHECK=on \
|
||||||
|
PIP_DEFAULT_TIMEOUT=100
|
||||||
|
|
||||||
|
RUN python3 -m venv $VIRTUAL_ENV
|
||||||
|
|
||||||
|
RUN mkdir -p /build/static
|
||||||
|
WORKDIR /build
|
||||||
|
|
||||||
|
# Install python dependencies.
|
||||||
|
COPY requirements.txt requirements.txt ./
|
||||||
|
RUN . /venv/bin/activate && pip install -r requirements.txt
|
||||||
|
|
||||||
|
# We will run dumb-init as pid 1.
|
||||||
|
RUN . /venv/bin/activate && pip install dumb-init
|
||||||
|
|
||||||
|
# We will run our app using gunicorn.
|
||||||
|
RUN . /venv/bin/activate && pip install gunicorn
|
||||||
|
|
||||||
|
# Copy local code into to the build image.
|
||||||
|
COPY . /build
|
||||||
|
|
||||||
|
# Copy code required for runtime to the /app folder.
|
||||||
|
RUN mkdir -p /app
|
||||||
|
RUN cp -r publichealth feedler yarn.lock manage.py package.json Gruntfile.js setup_libs.sh /app/
|
||||||
|
|
||||||
|
|
||||||
|
#RUN curl -fsSLO https://deb.nodesource.com/setup_18.x && chmod +x setup_18.x && ./setup_18.x
|
||||||
|
#RUN apt install -y nodejs
|
||||||
|
#RUN npm install -g grunt-cli
|
||||||
|
|
||||||
|
# Collect static data into /app/static.
|
||||||
|
#RUN . /venv/bin/activate && \
|
||||||
|
# DJANGO_STATIC_ROOT=/app/static SECRET_KEY=sl DJANGO_SETTINGS_MODULE=publichealth.settings.production ./manage.py collectstatic --no-input -i media
|
||||||
|
|
||||||
|
#RUN mkdir -p /app/publichealth/static/libs
|
||||||
|
|
||||||
|
#RUN cp -rf node_modules/@bower_components/* /app/publichealth/static/libs
|
||||||
|
|
||||||
|
|
||||||
|
#RUN . /venv/bin/activate && \
|
||||||
|
# DJANGO_STATIC_ROOT=/app/static SECRET_KEY=sl DJANGO_SETTINGS_MODULE=publichealth.settings.production ./manage.py compress --force
|
||||||
|
|
||||||
|
#RUN cp -r /build/static /app/static
|
||||||
|
|
||||||
|
### runtime image
|
||||||
|
|
||||||
|
FROM base as runtime
|
||||||
|
|
||||||
|
#RUN apt-get install -y --no-install-recommends libpango-1.0-0 libpangoft2-1.0-0
|
||||||
|
#RUN apt-get install -y --no-install-recommends procps iproute2 curl
|
||||||
|
|
||||||
|
COPY --from=build /venv /venv
|
||||||
|
COPY --from=build /app /app
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Ensure exectutables from virtualenv are prefered.
|
||||||
|
ENV PATH="/venv/bin:$PATH"
|
||||||
|
ENTRYPOINT ["/venv/bin/dumb-init", "--", "gunicorn", \
|
||||||
|
"-b [::]:8000", \
|
||||||
|
"--log-file=-", \
|
||||||
|
"--worker-tmp-dir", "/dev/shm", \
|
||||||
|
"--workers=2", "--threads=4", "--worker-class=gthread"]
|
||||||
|
CMD ["publichealth.wsgi"]
|
|
@ -1,6 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from django import template
|
from django import template
|
||||||
from django.utils import translation
|
from django.utils import translation
|
||||||
|
from django.db.models import Case, When
|
||||||
|
|
||||||
from wagtail.core.models import Site, Page
|
from wagtail.core.models import Site, Page
|
||||||
from ..models.forms import ContactForm
|
from ..models.forms import ContactForm
|
||||||
|
@ -54,6 +55,7 @@ def top_menu(context, parent, calling_page=None):
|
||||||
menuitems = parent.get_children().live().in_menu().specific()
|
menuitems = parent.get_children().live().in_menu().specific()
|
||||||
for menuitem in menuitems:
|
for menuitem in menuitems:
|
||||||
menuitem.show_dropdown = has_menu_children(menuitem)
|
menuitem.show_dropdown = has_menu_children(menuitem)
|
||||||
|
if calling_page:
|
||||||
menuitem.active = (calling_page.url.startswith(menuitem.url)
|
menuitem.active = (calling_page.url.startswith(menuitem.url)
|
||||||
if calling_page else False)
|
if calling_page else False)
|
||||||
try:
|
try:
|
||||||
|
@ -66,7 +68,7 @@ def top_menu(context, parent, calling_page=None):
|
||||||
'request': context['request'],
|
'request': context['request'],
|
||||||
}
|
}
|
||||||
|
|
||||||
def menuitems_children(parent):
|
def menuitems_children(parent, context=None):
|
||||||
remove_mitglied = False
|
remove_mitglied = False
|
||||||
remove_devenez = False
|
remove_devenez = False
|
||||||
if 'Qui sommes-nous' in parent.title:
|
if 'Qui sommes-nous' in parent.title:
|
||||||
|
@ -77,20 +79,45 @@ def menuitems_children(parent):
|
||||||
items_to_remove = []
|
items_to_remove = []
|
||||||
for menuitem in menuitems_children:
|
for menuitem in menuitems_children:
|
||||||
try:
|
try:
|
||||||
if type(menuitem) == ContactForm:
|
|
||||||
menuitem.title = menuitem.title
|
|
||||||
else:
|
|
||||||
menuitem.title = menuitem.trans_title
|
|
||||||
if 'devenez' in menuitem.title.lower() and remove_devenez:
|
if 'devenez' in menuitem.title.lower() and remove_devenez:
|
||||||
items_to_remove.append(menuitem)
|
items_to_remove.append(menuitem)
|
||||||
elif 'mitglied werden' in menuitem.title.lower() and remove_mitglied:
|
elif 'mitglied werden' in menuitem.title.lower() and remove_mitglied:
|
||||||
items_to_remove.append(menuitem)
|
items_to_remove.append(menuitem)
|
||||||
except AttributeError:
|
menuitem.title = menuitem.trans_title
|
||||||
|
except AttributeError as ae:
|
||||||
pass
|
pass
|
||||||
for item in items_to_remove:
|
for item in items_to_remove:
|
||||||
menuitems_children = menuitems_children & Page.objects.not_page(item)
|
menuitems_children = menuitems_children & Page.objects.not_page(item)
|
||||||
|
if context:
|
||||||
|
request = context['request']
|
||||||
|
site = Site.find_for_request(request)
|
||||||
|
if site.hostname in ['sphc.ch', 'public-health.ch']:
|
||||||
|
# custom page here is the terms and conditions page for public-health.ch and sphc.ch (common)
|
||||||
|
if request.__dict__.get('LANGUAGE_CODE', 'de').lower() == 'en':
|
||||||
|
custom_page_id = 1020
|
||||||
|
else:
|
||||||
|
custom_page_id = 994
|
||||||
|
custom_page = Page.objects.get(id=custom_page_id)
|
||||||
|
menuitems_children = add_item_to_page_queryset(menuitems_children, custom_page)
|
||||||
|
for menuitem in menuitems_children:
|
||||||
|
try:
|
||||||
|
menuitem.title = menuitem.trans_title
|
||||||
|
except AttributeError as aee:
|
||||||
|
pass
|
||||||
return menuitems_children
|
return menuitems_children
|
||||||
|
|
||||||
|
def add_item_to_page_queryset(queryset, custom_page):
|
||||||
|
# Convert queryset to a list
|
||||||
|
pages_list = list(queryset)
|
||||||
|
# Add the custom page to the list
|
||||||
|
pages_list.append(custom_page)
|
||||||
|
# Create a new ordered queryset based on the list order
|
||||||
|
page_ids = [page.id for page in pages_list]
|
||||||
|
preserved_order = Case(*[When(pk=pk, then=pos) for pos, pk in enumerate(page_ids)])
|
||||||
|
new_queryset = Page.objects.filter(id__in=page_ids).order_by(preserved_order).specific()
|
||||||
|
return new_queryset
|
||||||
|
|
||||||
|
|
||||||
# Retrieves the children of the top menu items for the drop downs
|
# Retrieves the children of the top menu items for the drop downs
|
||||||
@register.inclusion_tag('tags/top_menu_children.html', takes_context=True)
|
@register.inclusion_tag('tags/top_menu_children.html', takes_context=True)
|
||||||
def top_menu_children(context, parent):
|
def top_menu_children(context, parent):
|
||||||
|
@ -105,6 +132,6 @@ def top_menu_children(context, parent):
|
||||||
def footer_menu(context, parent, calling_page=None):
|
def footer_menu(context, parent, calling_page=None):
|
||||||
return {
|
return {
|
||||||
'calling_page': calling_page,
|
'calling_page': calling_page,
|
||||||
'menuitems': menuitems_children(parent),
|
'menuitems': menuitems_children(parent, context),
|
||||||
'request': context['request'],
|
'request': context['request'],
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import dj_database_url
|
import dj_database_url
|
||||||
|
|
||||||
|
from logging.handlers import RotatingFileHandler
|
||||||
from .base import *
|
from .base import *
|
||||||
|
|
||||||
# Do not set SECRET_KEY, Postgres or LDAP password or any other sensitive data here.
|
# Do not set SECRET_KEY, Postgres or LDAP password or any other sensitive data here.
|
||||||
|
@ -149,10 +152,19 @@ LOGGING = {
|
||||||
'level': 'ERROR',
|
'level': 'ERROR',
|
||||||
'class': 'django.utils.log.AdminEmailHandler',
|
'class': 'django.utils.log.AdminEmailHandler',
|
||||||
},
|
},
|
||||||
|
'console': {
|
||||||
|
'level': 'DEBUG',
|
||||||
|
'class': 'logging.StreamHandler',
|
||||||
|
'stream': sys.stdout,
|
||||||
|
'formatter': 'simple',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
'formatters': {
|
'formatters': {
|
||||||
'default': {
|
'default': {
|
||||||
'verbose': '[%(asctime)s] (%(process)d/%(thread)d) %(name)s %(levelname)s: %(message)s'
|
'verbose': '[%(asctime)s] (%(process)d/%(thread)d) %(name)s %(levelname)s: %(message)s'
|
||||||
|
},
|
||||||
|
'simple': {
|
||||||
|
'verbose': '[%(asctime)s] (%(process)d/%(thread)d) %(name)s %(levelname)s: %(message)s'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'loggers': {
|
'loggers': {
|
||||||
|
@ -194,7 +206,7 @@ if 'LOG_DIR' in env:
|
||||||
# Public Health Schweiz log
|
# Public Health Schweiz log
|
||||||
LOGGING['handlers']['publichealth_file'] = {
|
LOGGING['handlers']['publichealth_file'] = {
|
||||||
'level': 'INFO',
|
'level': 'INFO',
|
||||||
'class': 'cloghandler.ConcurrentRotatingFileHandler',
|
'class': 'logging.handlers.RotatingFileHandler',
|
||||||
'filename': os.path.join(env['LOG_DIR'], 'publichealth.log'),
|
'filename': os.path.join(env['LOG_DIR'], 'publichealth.log'),
|
||||||
'maxBytes': 5242880, # 5MB
|
'maxBytes': 5242880, # 5MB
|
||||||
'backupCount': 5
|
'backupCount': 5
|
||||||
|
@ -204,7 +216,7 @@ if 'LOG_DIR' in env:
|
||||||
# Wagtail log
|
# Wagtail log
|
||||||
LOGGING['handlers']['wagtail_file'] = {
|
LOGGING['handlers']['wagtail_file'] = {
|
||||||
'level': 'WARNING',
|
'level': 'WARNING',
|
||||||
'class': 'cloghandler.ConcurrentRotatingFileHandler',
|
'class': 'logging.handlers.RotatingFileHandler',
|
||||||
'filename': os.path.join(env['LOG_DIR'], 'wagtail.log'),
|
'filename': os.path.join(env['LOG_DIR'], 'wagtail.log'),
|
||||||
'maxBytes': 5242880, # 5MB
|
'maxBytes': 5242880, # 5MB
|
||||||
'backupCount': 5
|
'backupCount': 5
|
||||||
|
@ -214,7 +226,7 @@ if 'LOG_DIR' in env:
|
||||||
# Error log
|
# Error log
|
||||||
LOGGING['handlers']['errors_file'] = {
|
LOGGING['handlers']['errors_file'] = {
|
||||||
'level': 'ERROR',
|
'level': 'ERROR',
|
||||||
'class': 'cloghandler.ConcurrentRotatingFileHandler',
|
'class': 'logging.handlers.RotatingFileHandler',
|
||||||
'filename': os.path.join(env['LOG_DIR'], 'error.log'),
|
'filename': os.path.join(env['LOG_DIR'], 'error.log'),
|
||||||
'maxBytes': 5242880, # 5MB
|
'maxBytes': 5242880, # 5MB
|
||||||
'backupCount': 5
|
'backupCount': 5
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
html[lang='fr'] .site-ngo-allianz-ebk .navbar-brand {
|
html[lang='fr'] .site-ngo-allianz-ebk .navbar-brand {
|
||||||
background-image: url('/static/org/NGO-Allianz_Logo-fr.jpg');
|
background-image: url('/static/org/NGO-Allianz_Logo-fr.jpg');
|
||||||
}
|
}
|
||||||
|
|
||||||
// -site-ngo-allianz-ebk
|
// -site-ngo-allianz-ebk
|
||||||
|
|
||||||
// Custom styles for gesundheitsmanifest.ch
|
// Custom styles for gesundheitsmanifest.ch
|
||||||
|
@ -61,3 +62,18 @@ html[lang='fr'] .site-ngo-allianz-ebk .navbar-brand {
|
||||||
border-bottom: 1px solid #ddd;
|
border-bottom: 1px solid #ddd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.site-dev-pro-salutech {
|
||||||
|
.navbar-brand {
|
||||||
|
width: 240px;
|
||||||
|
height: 64px;
|
||||||
|
background-size: contain !important;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-image: url('/static/images/pro-salute-logo.png');
|
||||||
|
|
||||||
|
font-size: 0px !important;
|
||||||
|
img { display: none !important; }
|
||||||
|
}
|
||||||
|
#carousel-banner .carousel-caption { display: none; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
BIN
publichealth/static/images/favicon-prosalute.ico
Normal file
BIN
publichealth/static/images/favicon-prosalute.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
|
@ -2,6 +2,9 @@
|
||||||
{% get_site_root as site_root %}
|
{% get_site_root as site_root %}
|
||||||
{% get_site as the_site %}
|
{% get_site as the_site %}
|
||||||
|
|
||||||
|
|
||||||
|
<style>
|
||||||
|
</style>
|
||||||
<nav class="navbar-pre navbar-fixed-top">
|
<nav class="navbar-pre navbar-fixed-top">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="nav">
|
<div class="nav">
|
||||||
|
@ -27,8 +30,15 @@
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<a class="navbar-brand" href="{% pageurl site_root %}">
|
<a class="navbar-brand" href="{% pageurl site_root %}">
|
||||||
|
|
||||||
|
{% if the_site|default:""|truncatechars:"255" == "dev.pro-salute.ch"%}
|
||||||
|
<img src="{% static 'images/pro-salute-logo.png' %}" alt="Pro Salute Logo">
|
||||||
|
{% else %}
|
||||||
<img src="{% static 'images/public-health-logo-sign.png' %}" alt="[logo]">
|
<img src="{% static 'images/public-health-logo-sign.png' %}" alt="[logo]">
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<span class="hidden-xs">{% contact_name the_site=the_site %}</span></a>
|
<span class="hidden-xs">{% contact_name the_site=the_site %}</span></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Updated: 21.07.2021
|
# Updated: 22.05.2024
|
||||||
|
|
||||||
# Core
|
# Core
|
||||||
wagtail==2.15.1
|
wagtail==2.15.1
|
||||||
|
@ -30,5 +30,7 @@ Pillow==8.4.0
|
||||||
gunicorn
|
gunicorn
|
||||||
whitenoise
|
whitenoise
|
||||||
python-dotenv
|
python-dotenv
|
||||||
ConcurrentLogHandler
|
#ConcurrentLogHandler
|
||||||
unidecode
|
unidecode
|
||||||
|
|
||||||
|
django-configurations
|
||||||
|
|
18
setup_libs.sh
Executable file
18
setup_libs.sh
Executable file
|
@ -0,0 +1,18 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cd /app
|
||||||
|
rm -rf node_modules
|
||||||
|
yarn install
|
||||||
|
mkdir -p /app/publichealth/static/libs
|
||||||
|
echo "created /app/publichealth/static/libs contents "
|
||||||
|
ls /app/publichealth/static/libs
|
||||||
|
cp -rf node_modules/@bower_components/* /app/publichealth/static/libs/
|
||||||
|
|
||||||
|
# static resources
|
||||||
|
python manage.py collectstatic --no-input -i media --settings=publichealth.settings.production
|
||||||
|
python manage.py compress --force --settings=publichealth.settings.production
|
||||||
|
|
||||||
|
if [ -d /app/static ]; then
|
||||||
|
echo "Copying"
|
||||||
|
cp -a /app/static /pod
|
||||||
|
fi
|
Loading…
Reference in a new issue