Note

Audience: Dev

Admin Memo#

How to load the demo#

When running an instance locally, you can load the demo by running:

python manage.py load_demo

Note

If you already added some data, you might need to use --ignore-idempotent

How to load the demo in k8s#

export CI_COMMIT_REF_SLUG=$(git branch --show-current)
kubectl config use-context strass-dev
BACKEND_POD=$(kubectl get po -l branch=branch-${CI_COMMIT_REF_SLUG},role=front --output jsonpath='{.items[0].metadata.name}')
kubectl exec $BACKEND_POD --container django-container -- python manage.py load_demo

How to theme STRASS#

Some instance need specific logo, specific colors, … To comply to those needs a theme have to be made. It consists in creating a python package which will place in the application various html fragments and files in various folders. An example can be found at https://gitlab.pasteur.fr/bbrancot/django-basetheme-bootstrap-ebaii-theme

To create a new theme :

  • Fork the project

  • Rename ebaii to yourtheme (tips: using lower case without - or _ will save you many issues)

  • Update setup.cfg (name, version, description)

  • Adapte/remove html fragments in yourtheme/templates/strass_app/

  • Create/edit css in yourtheme/static/css/, to include more file adapte yourtheme/templates/strass_app/extra_in_header.html

  • Images can be shipped in yourtheme/static/img/

Once push to https://gitlab.pasteur.fr/api/v4/projects/alovelace%2Fdjango-basetheme-bootstrap-mytheme you need to use the theme in the application like this:

diff --git a/src/strass/strass/settings.py b/src/strass/strass/settings.py
index 0d6c462d..889acf67 100644
--- a/src/strass/strass/settings.py
+++ b/src/strass/strass/settings.py
@@ -53,7 +53,6 @@ INSTALLED_APPS = [
     'crispy_bootstrap4',
     'django_kubernetes_probes',
     'strass_app',
+    'yourtheme',
 ]

 if DEBUG or config('USE_DJANGO_EXTENSIONS', default=False, cast=bool):
index 94b6c670..14ebfb78 100644
--- a/src/strass/requirements.txt
+++ b/src/strass/requirements.txt
@@ -7,8 +7,6 @@ python-decouple
 django-basetheme-bootstrap>=1.6.1
 --extra-index-url https://gitlab.pasteur.fr/api/v4/projects/hub%2Fdjango-kubernetes-probes/packages/pypi/simple
 django-kubernetes-probes>=1.1
+--extra-index-url https://gitlab.pasteur.fr/api/v4/projects/alovelace%2Fdjango-basetheme-bootstrap-mytheme/packages/pypi/simple
+django-basetheme-bootstrap-mytheme>=1.0.0
 django-formtools
 csscompressor
 coverage

How to remove a language#

French and English language cannot be removed as the internationalization system uses this two languages to check it soundness. For the other language, just remove the language from LANGUAGES in src/strass/strass/settings.py.

How to add a new language#

For the call#

The first step to add a new language is not make it available for Django, do it in src/strass/strass/settings.py. Once added the language will be available in the language menu in the top right, and call will be also proposed in this new language.

diff --git a/src/strass/strass/settings.py b/src/strass/strass/settings.py
index 889acf67..275e09d5 100644
--- a/src/strass/strass/settings.py
+++ b/src/strass/strass/settings.py
@@ -134,6 +134,7 @@ LOCALE_PATHS = [
 LANGUAGES = [
     ('en', 'English'),
     ('fr', 'Français'),
+    ('de', 'German'),
 ]

 TIME_ZONE = 'CET'

In all the application#

Note

Translating the application in a new language implies to translate ~800 text entries.

To translate the whole application is a new language the code base have to be locally cloned, virtualenv created and dependencies installed.

# create the translation file for django itself
python manage.py makemessages -l de --no-location
# create the translation file for internationalization in javascript
python manage.py makemessages -d djangojs -l de --no-location

Then edit the following file :

  • /src/strass/strass_app/locale/de/LC_MESSAGES/django.po

  • /src/strass/strass_app/locale/de/LC_MESSAGES/djangojs.po

  • /src/strass/locale/de/LC_MESSAGES/django.po

To validate your file, regularly run the following command.

python manage.py compilemessages --ignore *venv*