Remove title from QuestionTable sequence and enhance render_stem method to include title in output
This commit is contained in:
+11
-2
@@ -39,7 +39,7 @@ class QuestionTable(tables.Table):
|
||||
"category",
|
||||
"author",
|
||||
)
|
||||
sequence = ("view","title", "stem", "answers")#, "exams")
|
||||
sequence = ("view", "stem", "answers")#, "exams")
|
||||
attrs = {"class": "table row-selector"}
|
||||
|
||||
def __init__(self, data=None, *args, **kwargs):
|
||||
@@ -51,7 +51,16 @@ class QuestionTable(tables.Table):
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
def render_stem(self, value):
|
||||
def render_stem(self, value, record=None, **kwargs):
|
||||
"""Render the stem, optionally with a title from the record.
|
||||
|
||||
Some versions of django-tables2 may call the render method without
|
||||
passing a `record`; guard for that and fall back to rendering the
|
||||
value only.
|
||||
"""
|
||||
title = getattr(record, "title", None) if record is not None else None
|
||||
if title:
|
||||
return format_html("<h5>{}</h5>{}", title, mark_safe(value))
|
||||
return mark_safe(value)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user