Projet

Général

Profil

0001-templatetags-allow-add-filter-to-concatenate-lists-6.patch

Thomas Noël, 22 juin 2022 10:48

Télécharger (1,43 ko)

Voir les différences:

Subject: [PATCH] templatetags: allow add filter to concatenate lists (#66471)

 tests/test_templates.py           | 1 +
 wcs/qommon/templatetags/qommon.py | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
tests/test_templates.py
519 519
    assert tmpl.render({'term1': None, 'term2': 'bar'}) == 'bar'
520 520
    assert tmpl.render({'term1': None, 'term2': ''}) == ''
521 521
    assert tmpl.render({'term1': None, 'term2': None}) == ''
522
    assert tmpl.render({'term1': [1, 2], 'term2': [3, 4]}) == '[1, 2, 3, 4]'
522 523

  
523 524
    # subtract
524 525
    tmpl = Template('{{ term1|subtract:term2 }}')
wcs/qommon/templatetags/qommon.py
566 566
    # compute addition if both terms are numbers
567 567
    try:
568 568
        return parse_decimal(term1, do_raise=True) + parse_decimal(term2, do_raise=True)
569
    except (ArithmeticError, TypeError):
569
    except (ArithmeticError, TypeError, ValueError):
570 570
        pass
571 571

  
572 572
    # fallback to django add filter
573
-