From 54f82f772b05bc01151d7c3ef4807d679bc80560 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Thu, 11 Aug 2022 08:53:54 +0100 Subject: [PATCH] Monkey patch header names --- core/views/ui/tables.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/core/views/ui/tables.py b/core/views/ui/tables.py index c1fbcff..d5c8b30 100644 --- a/core/views/ui/tables.py +++ b/core/views/ui/tables.py @@ -1,5 +1,27 @@ from django.conf import settings from django_tables2 import Column, Table +from django_tables2.columns.base import BoundColumn + +# Make the table column headings lowercase +orig_Column_header = BoundColumn.header + + +@property +def lower_header(self): + header = orig_Column_header.__get__(self) + header = header.lower() + header = header.title() + if header != "Ident": + header = header.replace("Id", "ID") + header = header.replace("id", "ID") + if header == "Ts": + header = "TS" + header = header.replace("Nsfw", "NSFW") + + return header + + +BoundColumn.header = lower_header class DrilldownTable(Table):