diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f188cf..98b5f2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Note: Breaking changes between versions are indicated by "💥". ## Unreleased +- [Bugfix] Fix running forum locally when both elasticsearch and mongodb are not activated (#266) - [Bugfix] Fix MongoDb url in forum when running separate service (#267) - 💥[Improvement] Better `dev` commands, with dedicated development docker image. One of the consequences is that the `dev watchthemes` command is replaced by `dev run lms watchthemes`. - [Improvement] `images` commands now accept multiple `image` arguments diff --git a/tests/test_utils.py b/tests/test_utils.py index 09fe807..2716a96 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,7 +1,6 @@ import unittest from tutor import utils -from tutor import serialize class UtilsTests(unittest.TestCase): @@ -20,3 +19,6 @@ class UtilsTests(unittest.TestCase): def test_reverse_host(self): self.assertEqual("com.google.www", utils.reverse_host("www.google.com")) + + def test_list_if(self): + self.assertEqual('["cms"]', utils.list_if([("lms", False), ("cms", True)])) diff --git a/tutor/env.py b/tutor/env.py index 75f8875..823afda 100644 --- a/tutor/env.py +++ b/tutor/env.py @@ -33,6 +33,7 @@ class Renderer: ) environment.filters["random_string"] = utils.random_string environment.filters["common_domain"] = utils.common_domain + environment.filters["list_if"] = utils.list_if environment.filters["reverse_host"] = utils.reverse_host environment.filters["walk_templates"] = walk_templates environment.globals["TUTOR_VERSION"] = __version__ diff --git a/tutor/templates/local/docker-compose.yml b/tutor/templates/local/docker-compose.yml index f35d4dd..d155534 100644 --- a/tutor/templates/local/docker-compose.yml +++ b/tutor/templates/local/docker-compose.yml @@ -69,9 +69,7 @@ services: - ../../data/openedx-media:/var/www/openedx-media:ro {% if ACTIVATE_HTTPS %}- ../../data/letsencrypt:/etc/letsencrypt/:ro{% endif %} {{ patch("local-docker-compose-nginx-volumes")|indent(6) }} - depends_on: - {% if ACTIVATE_LMS %}- lms{% endif %} - {% if ACTIVATE_CMS %}- cms {% endif %} + depends_on: {{ [("lms", ACTIVATE_LMS), ("cms", ACTIVATE_CMS)]|list_if }} {% if ACTIVATE_RABBITMQ %} rabbitmq: @@ -98,9 +96,7 @@ services: MONGODB_HOST: "{{ MONGODB_HOST }}" MONGODB_PORT: "{{ MONGODB_PORT }}" restart: unless-stopped - depends_on: - {% if ACTIVATE_ELASTICSEARCH %}- elasticsearch{% endif %} - {% if ACTIVATE_MONGODB %}- mongodb{% endif %} + depends_on: {{ [("elasticsearch", ACTIVATE_ELASTICSEARCH), ("mongodb", ACTIVATE_MONGODB)]|list_if }} {% endif %} ############# LMS and CMS diff --git a/tutor/utils.py b/tutor/utils.py index cb76f37..2e165ef 100644 --- a/tutor/utils.py +++ b/tutor/utils.py @@ -1,3 +1,4 @@ +import json import os import random import shutil @@ -24,6 +25,8 @@ def random_string(length): [random.choice(string.ascii_letters + string.digits) for _ in range(length)] ) +def list_if(services): + return json.dumps([service[0] for service in services if service[1]]) def common_domain(d1, d2): """