Projet

Général

Profil

0001-wcs-use-custom-title-as-card-cell-additional-label-6.patch

Lauréline Guérin, 28 janvier 2022 16:59

Télécharger (1,76 ko)

Voir les différences:

Subject: [PATCH] wcs: use custom title as card cell additional label (#61040)

 combo/apps/wcs/models.py | 5 ++---
 tests/test_wcs.py        | 1 +
 2 files changed, 3 insertions(+), 3 deletions(-)
combo/apps/wcs/models.py
26 26
from django.forms import Select
27 27
from django.forms import models as model_forms
28 28
from django.template import Context, RequestContext, Template, TemplateSyntaxError, VariableDoesNotExist
29
from django.utils.html import escape
29 30
from django.utils.safestring import mark_safe
30 31
from django.utils.text import slugify
31 32
from django.utils.translation import ugettext_lazy as _
......
778 779
        return self.carddef_reference.split(':')[1]
779 780

  
780 781
    def get_additional_label(self):
781
        if not self.cached_title:
782
            return
783
        return self.cached_title
782
        return escape(self.custom_title) or self.cached_title or None
784 783

  
785 784

  
786 785
@register_cell_class
tests/test_wcs.py
2356 2356
    cell.title_type = 'manual'
2357 2357
    cell.custom_title = '<b>Foo bar {{ card.fields.fielda }}</b>'
2358 2358
    cell.save()
2359
    assert cell.get_additional_label() == '&lt;b&gt;Foo bar {{ card.fields.fielda }}&lt;/b&gt;'
2359 2360
    result = cell.render(context)
2360 2361
    assert '<h2>&lt;b&gt;Foo bar a&lt;/b&gt;</h2>' in result
2361 2362

  
2362
-