Update view cell in QuestionTable to display SVG icon for open access questions

This commit is contained in:
Ross
2025-10-20 21:28:18 +01:00
parent 7f68fc23c6
commit 593eafd427
+10 -1
View File
@@ -8,11 +8,19 @@ from django.utils.html import format_html
class QuestionTable(tables.Table):
def get_view_cell(record):
if record.open_access:
return format_html(f"""<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-opencollective" viewBox="0 0 16 16">
<path fill-opacity=".4" d="M12.995 8.195c0 .937-.312 1.912-.78 2.693l1.99 1.99c.976-1.327 1.6-2.966 1.6-4.683 0-1.795-.624-3.434-1.561-4.76l-2.068 2.028c.468.781.78 1.679.78 2.732h.04Z"/>
<path d="M8 13.151a4.995 4.995 0 1 1 0-9.99c1.015 0 1.951.273 2.732.82l1.95-2.03a7.805 7.805 0 1 0 .04 12.449l-1.951-2.03a5.072 5.072 0 0 1-2.732.781z"/>
</svg> View""")
else:
return f'View'
#edit = tables.LinkColumn(
# "sbas:sbas_question_update", text="Edit", args=[A("pk")], orderable=False
#)
view = tables.LinkColumn(
"sbas:question_detail", text="View", args=[A("pk")], orderable=False
"sbas:question_detail", text=get_view_cell, args=[A("pk")], orderable=False
)
#delete = tables.LinkColumn(
# "sbas:question_delete", text="Delete", args=[A("pk")], orderable=False
@@ -70,6 +78,7 @@ class QuestionTable(tables.Table):
return mark_safe(value)
class UserAnswerTable(tables.Table):
select = tables.CheckBoxColumn(accessor=("pk"))
#delete = tables.LinkColumn(