wcs: use custom title as card cell additional label (#61040)
gitea-wip/combo/pipeline/head There was a failure building this commit Details
gitea/combo/pipeline/head Something is wrong with the build of this commit Details

This commit is contained in:
Lauréline Guérin 2022-01-28 16:58:28 +01:00
parent 4244cfdd8f
commit b5d82f30e4
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 3 additions and 3 deletions

View File

@ -26,6 +26,7 @@ from django.db import models
from django.forms import Select
from django.forms import models as model_forms
from django.template import Context, RequestContext, Template, TemplateSyntaxError, VariableDoesNotExist
from django.utils.html import escape
from django.utils.safestring import mark_safe
from django.utils.text import slugify
from django.utils.translation import ugettext_lazy as _
@ -783,9 +784,7 @@ class CardMixin:
return self.carddef_reference.split(':')[1]
def get_additional_label(self):
if not self.cached_title:
return
return self.cached_title
return escape(self.custom_title) or self.cached_title or None
@register_cell_class

View File

@ -2422,6 +2422,7 @@ def test_card_cell_render(mock_send, context, app):
cell.title_type = 'manual'
cell.custom_title = '<b>Foo bar {{ card.fields.fielda }}</b>'
cell.save()
assert cell.get_additional_label() == '&lt;b&gt;Foo bar {{ card.fields.fielda }}&lt;/b&gt;'
result = cell.render(context)
assert '<h2>&lt;b&gt;Foo bar a&lt;/b&gt;</h2>' in result