From eb48d72afe27a0ef700191c60df7f1b57c626ce1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Tue, 29 Apr 2014 10:11:27 +0200 Subject: [PATCH] Fixed get template on post_save handler --- taiga/projects/models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/taiga/projects/models.py b/taiga/projects/models.py index 5b15066b..609d0c07 100644 --- a/taiga/projects/models.py +++ b/taiga/projects/models.py @@ -35,6 +35,7 @@ from django_pgjson.fields import JsonField from taiga.users.models import Role from taiga.domains.models import DomainMember +from taiga.domains import get_active_domain from taiga.projects.userstories.models import UserStory from taiga.base.utils.slug import slugify_uniquely from taiga.base.utils.dicts import dict_sum @@ -832,6 +833,9 @@ def project_post_save(sender, instance, created, **kwargs): return template_slug = getattr(instance, "template", settings.DEFAULT_PROJECT_TEMPLATE) - template = ProjectTemplate.objects.get(slug=template_slug, domain__isnull=True) + template = ProjectTemplate.objects.filter(slug=template_slug).get( + models.Q(domain__isnull=True) | models.Q(domain=get_active_domain()) + ) + template.apply_to_project(instance) instance.save()