misc: use a template to render the text cell (#13367)

This commit is contained in:
Frédéric Péters 2016-09-29 14:45:52 +02:00
parent 9242e4d37a
commit ae8f3eff56
3 changed files with 6 additions and 3 deletions

View File

@ -441,11 +441,13 @@ class CellBase(models.Model):
class TextCell(CellBase):
text = RichTextField(_('Text'), blank=True, null=True)
template_name = 'combo/text-cell.html'
class Meta:
verbose_name = _('Text')
def render(self, context):
return mark_safe(self.text or '')
def is_relevant(self, context):
return bool(self.text)
def get_additional_label(self):
if not self.text:

View File

@ -0,0 +1 @@
{{cell.text|safe}}

View File

@ -204,7 +204,7 @@ def test_ajax_cell(app):
cell.save()
resp = app.get(reverse('combo-public-ajax-page-cell',
kwargs={'page_pk': page.id, 'cell_reference': cell.get_reference()}))
assert resp.body == '<p>Foobar</p>'
assert resp.body.strip() == '<p>Foobar</p>'
resp = app.get(reverse('combo-public-ajax-page-cell',
kwargs={'page_pk': page2.id, 'cell_reference': cell.get_reference()}),