From dbc5f2d92b256a2f39e10b53237fc37bc711c089 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Mon, 21 May 2018 22:17:00 +0200 Subject: [PATCH 3/3] prevent hobo-cook from changing the current tenant (to be rebased) --- hobo/contrib/ozwillo/models.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hobo/contrib/ozwillo/models.py b/hobo/contrib/ozwillo/models.py index 0111034..08a9f82 100644 --- a/hobo/contrib/ozwillo/models.py +++ b/hobo/contrib/ozwillo/models.py @@ -27,6 +27,9 @@ from django.db import models from django.db.transaction import atomic from django.utils.text import slugify from django.core.management import call_command +from django.db import connection + +from tenant_schemas.utils import tenant_context class OzwilloInstance(models.Model): @@ -127,7 +130,10 @@ class OzwilloInstance(models.Model): with tempfile.NamedTemporaryFile() as recipe_file: json.dump(template_recipe, recipe_file) recipe_file.flush() - call_command('cook', recipe_file.name, timeout=1000, verbosity=0) + + # cook play with the tenant context, we must protect from that + with tenant_context(connection.tenant): + call_command('cook', recipe_file.name, timeout=1000, verbosity=0) # Load user portal template logger.info(u'ozwillo: loading combo template') -- 2.17.0