Fixed get template on post_save handler

remotes/origin/enhancement/email-actions
Jesús Espino 2014-04-29 10:11:27 +02:00
parent 39e0e2dcf7
commit eb48d72afe
1 changed files with 5 additions and 1 deletions

View File

@ -35,6 +35,7 @@ from django_pgjson.fields import JsonField
from taiga.users.models import Role from taiga.users.models import Role
from taiga.domains.models import DomainMember from taiga.domains.models import DomainMember
from taiga.domains import get_active_domain
from taiga.projects.userstories.models import UserStory from taiga.projects.userstories.models import UserStory
from taiga.base.utils.slug import slugify_uniquely from taiga.base.utils.slug import slugify_uniquely
from taiga.base.utils.dicts import dict_sum from taiga.base.utils.dicts import dict_sum
@ -832,6 +833,9 @@ def project_post_save(sender, instance, created, **kwargs):
return return
template_slug = getattr(instance, "template", settings.DEFAULT_PROJECT_TEMPLATE) 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) template.apply_to_project(instance)
instance.save() instance.save()