Monkey patch header names

This commit is contained in:
Mark Veidemanis 2022-08-11 08:53:54 +01:00
parent 6e25881c73
commit 54f82f772b
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 22 additions and 0 deletions

View File

@ -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):