From d36f397c6ec3424c584c61e865423aa82dedc707 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Wed, 10 Aug 2022 20:35:34 +0100 Subject: [PATCH] Make the table dynamic --- .../ui/drilldown/table_results_partial.html | 173 +++++++++++++++++- core/views/ui/tables.py | 6 + 2 files changed, 177 insertions(+), 2 deletions(-) diff --git a/core/templates/ui/drilldown/table_results_partial.html b/core/templates/ui/drilldown/table_results_partial.html index 78f9dbc..0c4a7c2 100644 --- a/core/templates/ui/drilldown/table_results_partial.html +++ b/core/templates/ui/drilldown/table_results_partial.html @@ -1,6 +1,8 @@ {% load django_tables2 %} {% load i18n %} {% load django_tables2_bulma_template %} +{% load joinsep %} + {% block table-wrapper %}
{% block table %} @@ -49,10 +51,157 @@ {% for row in table.paginated_rows %} {% block table.tbody.row %} - + {% for column, cell in row.items %} {% block table.tbody.td %} - {% if column.localize == None %}{{ cell }}{% else %}{% if column.localize %}{{ cell|localize }}{% else %}{{ cell|unlocalize }}{% endif %}{% endif %} + {% if column.name == 'src' %} + + + {% if row.cells.src == 'irc' %} + + + + {% elif row.cells.src == 'dis' %} + + + + {% endif %} + + + {% elif column.name == 'type' %} + + + {% if row.cells.type == 'msg' %} + + + + {% elif row.cells.type == 'join' %} + + + + {% elif row.cells.type == 'part' %} + + + + {% elif row.cells.type == 'quit' %} + + + + {% elif row.cells.type == 'kick' %} + + + + {% elif row.cells.type == 'nick' %} + + + + {% elif row.cells.type == 'mode' %} + + + + {% elif row.cells.type == 'action' %} + + + + {% else %} + {{ row.cells.type }} + {% endif %} + + + {% elif column.name == 'msg' %} + {{ row.cells.msg }} + {% elif column.name == 'host' %} + + + {{ cell }} + + + {% elif column.name == 'nick' %} + +
+
+ {% if row.cells.online is True %} + + + + {% elif row.cells.online is False %} + + + + {% else %} + + + + {% endif %} +
+ + {{ cell }} + +
+ {% if row.cells.src == 'irc' %} + + {% endif %} +
+ {% if row.cells.num_chans is not None %} +
+ + {{ row.cells.num_chans }} + +
+ {% endif %} +
+ + {% elif column.name == 'channel' %} + +
+ + {{ cell }} + + {% if row.cells.num_users is not None %} +
+ + {{ row.cells.num_users }} + +
+ {% endif %} +
+ + {% elif column.name == 'net' %} + + + {{ cell }} + + + {% else %} + + {{ cell }} + + {% endif %} {% endblock table.tbody.td %} {% endfor %} @@ -160,4 +309,24 @@ {% endif %} {% endblock pagination %}
+ {# Update the tags in case the user changed the query #} + {# Check for focus and refocus #} + {% endblock table-wrapper %} \ No newline at end of file diff --git a/core/views/ui/tables.py b/core/views/ui/tables.py index ed64836..ca93a12 100644 --- a/core/views/ui/tables.py +++ b/core/views/ui/tables.py @@ -15,6 +15,8 @@ class DrilldownTable(Table): num = Column() src = Column() ts = Column() + # date = Column() + # time = Column() type = Column() bot = Column() channel = Column() @@ -32,5 +34,9 @@ class DrilldownTable(Table): status = Column() user = Column() version_sentiment = Column() + exemption = Column() + num_chans = Column() + num_users = Column() template_name = "ui/drilldown/table_results.html" paginate_by = 5 + row_attrs = "is-primary"