Compare commits

..

20 Commits

Author SHA1 Message Date
PCoder 34ad67e8cd Add favicon-prosalute.ico 2024-06-17 17:37:28 +05:30
PCoder cd99b1bc4f Check variable before accessing attribute 2024-06-04 17:07:38 +05:30
pcoder116 c5026ad0eb Merge pull request 'Dockerify pro-salute' (#10) from pro-salute into master
Reviewed-on: #10
2024-06-02 04:11:38 +00:00
PCoder a3cdc6b58a Write DEBUG level logs to stdout 2024-05-31 19:09:01 +05:30
PCoder b918903fcf Copy setup_libs.sh to /app 2024-05-31 19:08:30 +05:30
PCoder 5ba9ee52ea Create setup_libs.sh 2024-05-31 19:08:08 +05:30
PCoder 5c173f0ffb Revert back installing grunt-cli 2024-05-24 15:55:48 +05:30
PCoder c88b94f20f Final changes 2024-05-23 17:05:21 +05:30
PCoder c18fb883cc Revert back dev configuration 2024-05-22 22:25:54 +05:30
PCoder d24fcd7d86 Merge remote-tracking branch 'origin/master' into pro-salute 2024-05-22 22:24:03 +05:30
PCoder daf3a6baad Cleanup 2024-05-22 21:56:55 +05:30
PCoder b5e786e098 Copy built static files to app 2024-05-22 21:55:41 +05:30
PCoder c013387b03 Generate / copy staticfiles + node libraries 2024-05-22 21:55:04 +05:30
PCoder aaf1fc1d9b Install yarn + tools 2024-05-22 21:52:23 +05:30
PCoder 1af8fe3767 Use RotatingFileHandler instead of ConcurrentLogHandler
Why?
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
      error in ConcurrentLogHandler setup command: use_2to3 is invalid.
      [end of output]

Looks like the module is incompatible with the latest setuptools. The recommended solution on the Internet seems to be to downgrade setuptools to 57.5.0 ;; however, this still does not solve the issue for my setup
2024-05-22 21:50:56 +05:30
PCoder 0e0b464534 Add django-configurations requirement 2024-05-22 16:53:37 +05:30
PCoder 9863959d88 Add feedler module to the app folder 2024-05-17 19:06:50 +05:30
PCoder 6e835a10e6 Fix required changes 2024-05-15 11:01:32 +05:30
M.Ravi 4099b039f5 Add Dockerfile 2024-05-15 04:04:32 +00:00
M.Ravi 53ae04404b Changes on the nations server 2024-05-15 01:44:31 +00:00
15 changed files with 181 additions and 139 deletions

104
Dockerfile Normal file
View 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"]

View File

@ -1,8 +0,0 @@
from django import template
from html import unescape
register = template.Library()
@register.filter
def ph_html_decode(value):
return unescape(str(value))

View File

@ -1,32 +0,0 @@
# Generated by Django 3.2.13 on 2023-05-15 12:47
from django.db import migrations
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.embeds.blocks
import wagtail.images.blocks
class Migration(migrations.Migration):
dependencies = [
('home', '0034_auto_20220714_1145'),
]
operations = [
migrations.AlterField(
model_name='articlepage',
name='body_de',
field=wagtail.core.fields.StreamField([('paragraph', wagtail.core.blocks.RichTextBlock()), ('section', wagtail.core.blocks.CharBlock(form_classname='full title')), ('info', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.CharBlock(required=True)), ('photo', wagtail.images.blocks.ImageChooserBlock(required=True)), ('summary', wagtail.core.blocks.RichTextBlock(required=True)), ('action', wagtail.core.blocks.CharBlock(required=False)), ('url', wagtail.core.blocks.URLBlock(required=False))], icon='help')), ('media', wagtail.core.blocks.ChoiceBlock(choices=[('gallery', 'Image gallery')], icon='media')), ('iframe', wagtail.embeds.blocks.EmbedBlock())], blank=True, null=True),
),
migrations.AlterField(
model_name='articlepage',
name='body_en',
field=wagtail.core.fields.StreamField([('paragraph', wagtail.core.blocks.RichTextBlock()), ('section', wagtail.core.blocks.CharBlock(form_classname='full title')), ('info', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.CharBlock(required=True)), ('photo', wagtail.images.blocks.ImageChooserBlock(required=True)), ('summary', wagtail.core.blocks.RichTextBlock(required=True)), ('action', wagtail.core.blocks.CharBlock(required=False)), ('url', wagtail.core.blocks.URLBlock(required=False))], icon='help')), ('media', wagtail.core.blocks.ChoiceBlock(choices=[('gallery', 'Image gallery')], icon='media')), ('iframe', wagtail.embeds.blocks.EmbedBlock())], blank=True, null=True),
),
migrations.AlterField(
model_name='articlepage',
name='body_fr',
field=wagtail.core.fields.StreamField([('paragraph', wagtail.core.blocks.RichTextBlock()), ('section', wagtail.core.blocks.CharBlock(form_classname='full title')), ('info', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.CharBlock(required=True)), ('photo', wagtail.images.blocks.ImageChooserBlock(required=True)), ('summary', wagtail.core.blocks.RichTextBlock(required=True)), ('action', wagtail.core.blocks.CharBlock(required=False)), ('url', wagtail.core.blocks.URLBlock(required=False))], icon='help')), ('media', wagtail.core.blocks.ChoiceBlock(choices=[('gallery', 'Image gallery')], icon='media')), ('iframe', wagtail.embeds.blocks.EmbedBlock())], blank=True, null=True),
),
]

View File

@ -1,36 +0,0 @@
# Generated by Django 3.2.13 on 2023-05-15 13:56
from django.db import migrations
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.images.blocks
class Migration(migrations.Migration):
dependencies = [
('home', '0035_auto_20230515_1447'),
]
operations = [
migrations.AddField(
model_name='articlepage',
name='html_content',
field=wagtail.core.fields.RichTextField(blank=True),
),
migrations.AlterField(
model_name='articlepage',
name='body_de',
field=wagtail.core.fields.StreamField([('paragraph', wagtail.core.blocks.RichTextBlock()), ('section', wagtail.core.blocks.CharBlock(form_classname='full title')), ('info', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.CharBlock(required=True)), ('photo', wagtail.images.blocks.ImageChooserBlock(required=True)), ('summary', wagtail.core.blocks.RichTextBlock(required=True)), ('action', wagtail.core.blocks.CharBlock(required=False)), ('url', wagtail.core.blocks.URLBlock(required=False))], icon='help')), ('media', wagtail.core.blocks.ChoiceBlock(choices=[('gallery', 'Image gallery')], icon='media'))], blank=True, null=True),
),
migrations.AlterField(
model_name='articlepage',
name='body_en',
field=wagtail.core.fields.StreamField([('paragraph', wagtail.core.blocks.RichTextBlock()), ('section', wagtail.core.blocks.CharBlock(form_classname='full title')), ('info', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.CharBlock(required=True)), ('photo', wagtail.images.blocks.ImageChooserBlock(required=True)), ('summary', wagtail.core.blocks.RichTextBlock(required=True)), ('action', wagtail.core.blocks.CharBlock(required=False)), ('url', wagtail.core.blocks.URLBlock(required=False))], icon='help')), ('media', wagtail.core.blocks.ChoiceBlock(choices=[('gallery', 'Image gallery')], icon='media'))], blank=True, null=True),
),
migrations.AlterField(
model_name='articlepage',
name='body_fr',
field=wagtail.core.fields.StreamField([('paragraph', wagtail.core.blocks.RichTextBlock()), ('section', wagtail.core.blocks.CharBlock(form_classname='full title')), ('info', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.CharBlock(required=True)), ('photo', wagtail.images.blocks.ImageChooserBlock(required=True)), ('summary', wagtail.core.blocks.RichTextBlock(required=True)), ('action', wagtail.core.blocks.CharBlock(required=False)), ('url', wagtail.core.blocks.URLBlock(required=False))], icon='help')), ('media', wagtail.core.blocks.ChoiceBlock(choices=[('gallery', 'Image gallery')], icon='media'))], blank=True, null=True),
),
]

View File

@ -1,35 +0,0 @@
# Generated by Django 3.2.13 on 2023-05-16 10:41
from django.db import migrations
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.images.blocks
class Migration(migrations.Migration):
dependencies = [
('home', '0036_auto_20230515_1556'),
]
operations = [
migrations.RemoveField(
model_name='articlepage',
name='html_content',
),
migrations.AlterField(
model_name='articlepage',
name='body_de',
field=wagtail.core.fields.StreamField([('paragraph', wagtail.core.blocks.RichTextBlock()), ('section', wagtail.core.blocks.CharBlock(form_classname='full title')), ('info', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.CharBlock(required=True)), ('photo', wagtail.images.blocks.ImageChooserBlock(required=True)), ('summary', wagtail.core.blocks.RichTextBlock(required=True)), ('action', wagtail.core.blocks.CharBlock(required=False)), ('url', wagtail.core.blocks.URLBlock(required=False))], icon='help')), ('media', wagtail.core.blocks.ChoiceBlock(choices=[('gallery', 'Image gallery')], icon='media')), ('iframe', wagtail.core.blocks.RichTextBlock())], blank=True, null=True),
),
migrations.AlterField(
model_name='articlepage',
name='body_en',
field=wagtail.core.fields.StreamField([('paragraph', wagtail.core.blocks.RichTextBlock()), ('section', wagtail.core.blocks.CharBlock(form_classname='full title')), ('info', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.CharBlock(required=True)), ('photo', wagtail.images.blocks.ImageChooserBlock(required=True)), ('summary', wagtail.core.blocks.RichTextBlock(required=True)), ('action', wagtail.core.blocks.CharBlock(required=False)), ('url', wagtail.core.blocks.URLBlock(required=False))], icon='help')), ('media', wagtail.core.blocks.ChoiceBlock(choices=[('gallery', 'Image gallery')], icon='media')), ('iframe', wagtail.core.blocks.RichTextBlock())], blank=True, null=True),
),
migrations.AlterField(
model_name='articlepage',
name='body_fr',
field=wagtail.core.fields.StreamField([('paragraph', wagtail.core.blocks.RichTextBlock()), ('section', wagtail.core.blocks.CharBlock(form_classname='full title')), ('info', wagtail.core.blocks.StructBlock([('title', wagtail.core.blocks.CharBlock(required=True)), ('photo', wagtail.images.blocks.ImageChooserBlock(required=True)), ('summary', wagtail.core.blocks.RichTextBlock(required=True)), ('action', wagtail.core.blocks.CharBlock(required=False)), ('url', wagtail.core.blocks.URLBlock(required=False))], icon='help')), ('media', wagtail.core.blocks.ChoiceBlock(choices=[('gallery', 'Image gallery')], icon='media')), ('iframe', wagtail.core.blocks.RichTextBlock())], blank=True, null=True),
),
]

View File

@ -185,8 +185,7 @@ class ArticlePage(Page):
('info', InfoBlock(icon='help')),
('media', ChoiceBlock(choices=[
('gallery', 'Image gallery'),
], icon='media')),
('iframe', RichTextBlock())
], icon='media'))
], null=True, blank=True)
body_fr = StreamField([
('paragraph', RichTextBlock()),
@ -194,8 +193,7 @@ class ArticlePage(Page):
('info', InfoBlock(icon='help')),
('media', ChoiceBlock(choices=[
('gallery', 'Image gallery'),
], icon='media')),
('iframe', RichTextBlock())
], icon='media'))
], null=True, blank=True)
body_en = StreamField([
('paragraph', RichTextBlock()),
@ -203,8 +201,7 @@ class ArticlePage(Page):
('info', InfoBlock(icon='help')),
('media', ChoiceBlock(choices=[
('gallery', 'Image gallery'),
], icon='media')),
('iframe', RichTextBlock())
], icon='media'))
], null=True, blank=True)
trans_body = TranslatedField(
'body_de',

View File

@ -1,4 +1,4 @@
{% load wagtailcore_tags wagtailimages_tags custom_filters %}
{% load wagtailcore_tags wagtailimages_tags %}
{% if page.feed_image %}
<div class="image">
@ -23,10 +23,6 @@
{% if block.value == 'gallery' %}
{% include 'home/photo_gallery.html' %}
{% endif %}
{% elif block.block_type == 'iframe' %}
{% autoescape off %}
{{ block.value|richtext|ph_html_decode}}
{% endautoescape %}
{% elif block.block_type != 'info' %}
<p class="block-{{ block.block_type }}">
{% include_block block %}

View File

@ -54,12 +54,13 @@ def top_menu(context, parent, calling_page=None):
menuitems = parent.get_children().live().in_menu().specific()
for menuitem in menuitems:
menuitem.show_dropdown = has_menu_children(menuitem)
menuitem.active = (calling_page.url.startswith(menuitem.url)
if calling_page else False)
try:
menuitem.title = menuitem.trans_title
except AttributeError:
pass
if calling_page:
menuitem.active = (calling_page.url.startswith(menuitem.url)
if calling_page else False)
try:
menuitem.title = menuitem.trans_title
except AttributeError:
pass
return {
'calling_page': calling_page,
'menuitems': menuitems,

View File

@ -109,9 +109,6 @@ TEMPLATES = [
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
'libraries': {
'custom_filters': 'publichealth.home.custom_filters',
},
},
},
]

View File

@ -1,6 +1,9 @@
import logging
import os
import sys
import dj_database_url
from logging.handlers import RotatingFileHandler
from .base import *
# Do not set SECRET_KEY, Postgres or LDAP password or any other sensitive data here.
@ -149,10 +152,19 @@ LOGGING = {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler',
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'stream': sys.stdout,
'formatter': 'simple',
},
},
'formatters': {
'default': {
'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': {
@ -194,7 +206,7 @@ if 'LOG_DIR' in env:
# Public Health Schweiz log
LOGGING['handlers']['publichealth_file'] = {
'level': 'INFO',
'class': 'cloghandler.ConcurrentRotatingFileHandler',
'class': 'logging.handlers.RotatingFileHandler',
'filename': os.path.join(env['LOG_DIR'], 'publichealth.log'),
'maxBytes': 5242880, # 5MB
'backupCount': 5
@ -204,7 +216,7 @@ if 'LOG_DIR' in env:
# Wagtail log
LOGGING['handlers']['wagtail_file'] = {
'level': 'WARNING',
'class': 'cloghandler.ConcurrentRotatingFileHandler',
'class': 'logging.handlers.RotatingFileHandler',
'filename': os.path.join(env['LOG_DIR'], 'wagtail.log'),
'maxBytes': 5242880, # 5MB
'backupCount': 5
@ -214,7 +226,7 @@ if 'LOG_DIR' in env:
# Error log
LOGGING['handlers']['errors_file'] = {
'level': 'ERROR',
'class': 'cloghandler.ConcurrentRotatingFileHandler',
'class': 'logging.handlers.RotatingFileHandler',
'filename': os.path.join(env['LOG_DIR'], 'error.log'),
'maxBytes': 5242880, # 5MB
'backupCount': 5

View File

@ -49,6 +49,7 @@
html[lang='fr'] .site-ngo-allianz-ebk .navbar-brand {
background-image: url('/static/org/NGO-Allianz_Logo-fr.jpg');
}
// -site-ngo-allianz-ebk
// Custom styles for gesundheitsmanifest.ch
@ -61,3 +62,18 @@ html[lang='fr'] .site-ngo-allianz-ebk .navbar-brand {
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; }
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -2,6 +2,9 @@
{% get_site_root as site_root %}
{% get_site as the_site %}
<style>
</style>
<nav class="navbar-pre navbar-fixed-top">
<div class="container">
<div class="nav">
@ -27,9 +30,16 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="{% pageurl site_root %}">
<img src="{% static 'images/public-health-logo-sign.png' %}" alt="[logo]">
<span class="hidden-xs">{% contact_name the_site=the_site %}</span></a>
<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]">
{% endif %}
<span class="hidden-xs">{% contact_name the_site=the_site %}</span></a>
</div>
{% block menu %}

View File

@ -1,4 +1,4 @@
# Updated: 21.07.2021
# Updated: 22.05.2024
# Core
wagtail==2.15.1
@ -30,5 +30,7 @@ Pillow==8.4.0
gunicorn
whitenoise
python-dotenv
ConcurrentLogHandler
#ConcurrentLogHandler
unidecode
django-configurations

18
setup_libs.sh Executable file
View 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