Implement selection-enabled table base class and update QuestionTable to inherit from it

This commit is contained in:
Ross
2025-11-01 20:45:59 +00:00
parent 8e8041cdc4
commit 57a3b02da3
2 changed files with 28 additions and 4 deletions
+22
View File
@@ -12,6 +12,28 @@ from generic.models import CidUser, Examination, Supervisor, findMiddle
from django.contrib.auth.models import User
# Generic selection-enabled table base class.
# Inherit from this class to automatically get a selection checkbox
# column (input name="selection") and table attrs that client-side
# scripts can use to find selectable tables.
class SelectionTable(tables.Table):
# Provide a default selection checkbox column. Subclasses that wish to
# customise can override this attribute.
selection = tables.CheckBoxColumn(
accessor="pk",
orderable=False,
attrs={
'th': {'class': 'selection-col'},
'td': {'class': 'selection-col'},
'input': {'name': 'selection'},
},
verbose_name=''
)
class Meta:
# Defaults: add js-row-selectable class so client-side code can
# locate tables that support row selection.
attrs = {"class": "table js-row-selectable", "data-selection-name": "selection"}
class SingleImageColumn(tables.Column):
def render(self, value):