From cd0851fe1d68c707f64143d8e6c2e862930e6f30 Mon Sep 17 00:00:00 2001
From: Emmanuel Cazenave <ecazenave@entrouvert.com>
Date: Wed, 18 May 2022 16:07:29 +0200
Subject: [PATCH] add lingo application (#65382)

---
 group_vars/all                                |  8 ++++++++
 install.yml                                   |  1 +
 roles/app-setup/templates/lingo-settings.j2   |  6 ++++++
 roles/base/files/publik-groups.conf           |  4 ++--
 roles/deploy-tenants/templates/cook-recipe.j2 |  6 ++++++
 roles/lingo/tasks/main.yml                    | 18 ++++++++++++++++++
 roles/lingo/vars/main.yml                     | 12 ++++++++++++
 7 files changed, 53 insertions(+), 2 deletions(-)
 create mode 100644 roles/app-setup/templates/lingo-settings.j2
 create mode 100644 roles/lingo/tasks/main.yml
 create mode 100644 roles/lingo/vars/main.yml

diff --git a/group_vars/all b/group_vars/all
index 8eb3440..6ee9735 100644
--- a/group_vars/all
+++ b/group_vars/all
@@ -67,6 +67,13 @@ apps:
     nginx_host_pattern: '~^(.*)welco\.dev\.publik\.love$'
     project_name: welco
     server_port: 8052
+  lingo:
+    db_name: lingo
+    host_pattern: "*lingo.dev.publik.love"
+    nginx_host_pattern: '~^(.*)lingo\.dev\.publik\.love$'
+    project_name: lingo
+    server_port: 8056
+
 tenants_conf:
   connexion-authentic: "authentic.dev.publik.love"
   agent-combo: "agent-combo.dev.publik.love"
@@ -78,3 +85,4 @@ tenants_conf:
   dev-chrono: "chrono.dev.publik.love"
   dev-bijoe: "bijoe.dev.publik.love"
   dev-welco: # disabled by default -- could be "welco.dev.publik.love"
+  dev-lingo: "lingo.dev.publik.love"
diff --git a/install.yml b/install.yml
index 84937ee..e3ddf0a 100644
--- a/install.yml
+++ b/install.yml
@@ -12,6 +12,7 @@
     - fargo
     - chrono
     - bijoe
+    - lingo
     - welco
     - hobo-agent
     - end
diff --git a/roles/app-setup/templates/lingo-settings.j2 b/roles/app-setup/templates/lingo-settings.j2
new file mode 100644
index 0000000..a3cf9fe
--- /dev/null
+++ b/roles/app-setup/templates/lingo-settings.j2
@@ -0,0 +1,6 @@
+{% extends "app-settings-base.j2" %}
+
+{% block app_custom_after %}
+# disable django-mellon autologin
+MELLON_OPENED_SESSION_COOKIE_NAME = None
+{% endblock %}
diff --git a/roles/base/files/publik-groups.conf b/roles/base/files/publik-groups.conf
index 8f7059f..5448642 100644
--- a/roles/base/files/publik-groups.conf
+++ b/roles/base/files/publik-groups.conf
@@ -1,5 +1,5 @@
 [group:django]
-programs=authentic2-multitenant,bijoe,chrono,combo,hobo,fargo,passerelle,welco,wcs
+programs=authentic2-multitenant,bijoe,chrono,combo,hobo,fargo,lingo,passerelle,welco,wcs
 
 [group:uwsgi]
-programs=authentic2-multitenant-uwsgi,bijoe-uwsgi,chrono-uwsgi,combo-uwsgi,hobo-uwsgi,fargo-uwsgi,passerelle-uwsgi,welco-uwsgi,wcs-uwsgi
\ No newline at end of file
+programs=authentic2-multitenant-uwsgi,bijoe-uwsgi,chrono-uwsgi,combo-uwsgi,hobo-uwsgi,fargo-uwsgi,lingo-uwsgi,passerelle-uwsgi,welco-uwsgi,wcs-uwsgi
\ No newline at end of file
diff --git a/roles/deploy-tenants/templates/cook-recipe.j2 b/roles/deploy-tenants/templates/cook-recipe.j2
index 0145d7c..a570545 100644
--- a/roles/deploy-tenants/templates/cook-recipe.j2
+++ b/roles/deploy-tenants/templates/cook-recipe.j2
@@ -62,6 +62,12 @@
         "title": "Courrier"
     }},
     {% endif %}
+    {% if tenants_conf['dev-lingo'] %}
+    {"create-lingo": {
+        "url": "https://{{tenants_conf['dev-lingo']}}/",
+        "title": "Facturation"
+    }},
+    {% endif %}
     {"set-theme": {
       "theme": "clapotis-les-canards"
     }}
diff --git a/roles/lingo/tasks/main.yml b/roles/lingo/tasks/main.yml
new file mode 100644
index 0000000..66e50ac
--- /dev/null
+++ b/roles/lingo/tasks/main.yml
@@ -0,0 +1,18 @@
+- name: source install lingo
+  import_tasks: install_source.yml
+  vars:
+    repo: "lingo"
+    repo_dir: "{{ src_dir }}/lingo"
+    version: "{{lingo_version|default('main')}}"
+  tags:
+    - source
+
+- name: lingo app setup
+  import_role:
+    name: app-setup
+
+- name: lingo nginx setup
+  import_role:
+    name: nginx-setup
+  vars:
+    app: "{{apps['lingo']}}"
diff --git a/roles/lingo/vars/main.yml b/roles/lingo/vars/main.yml
new file mode 100644
index 0000000..9ece192
--- /dev/null
+++ b/roles/lingo/vars/main.yml
@@ -0,0 +1,12 @@
+app_name: lingo
+compile_scss: false
+compile_translations: true
+db_name: "{{apps['lingo']['db_name']}}"
+manage_cmd: "{{venv_py3_python}} {{src_dir}}/lingo/manage.py"
+nginx_host_pattern: "{{apps['lingo']['nginx_host_pattern']}}"
+nginx_template_name: "std-nginx-server.j2"
+project_name: "{{apps['lingo']['project_name']}}"
+server_port: "{{apps['lingo']['server_port']}}"
+settings_env_var: LINGO_SETTINGS_FILE
+uwsgi_settings_orig: "{{src_dir}}/{{app_name}}/debian/uwsgi.ini"
+virtualenv: "{{venv_py3}}"
-- 
2.30.2

