From 86ec95ab6ca601e9ce1275eb193313c6c0c6f190 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Thu, 11 Aug 2022 07:22:22 +0100 Subject: [PATCH] Fix tag population and date formatting --- .../templates/ui/drilldown/table_results.html | 23 +- .../ui/drilldown/table_results_partial.html | 334 +++++++++--------- core/views/ui/drilldown.py | 1 + core/views/ui/tables.py | 10 +- 4 files changed, 189 insertions(+), 179 deletions(-) diff --git a/core/templates/ui/drilldown/table_results.html b/core/templates/ui/drilldown/table_results.html index c691678..05d31d8 100644 --- a/core/templates/ui/drilldown/table_results.html +++ b/core/templates/ui/drilldown/table_results.html @@ -1,5 +1,6 @@ {% load static %} {% load index %} +{% load joinsep %} {% include 'partials/notify.html' %} {% if table %} -{% endif %} \ No newline at end of file +{% endif %} +{# Update the tags in case the user changed the query #} +{# Check for focus and refocus #} + \ No newline at end of file diff --git a/core/templates/ui/drilldown/table_results_partial.html b/core/templates/ui/drilldown/table_results_partial.html index cd7aa35..2da0314 100644 --- a/core/templates/ui/drilldown/table_results_partial.html +++ b/core/templates/ui/drilldown/table_results_partial.html @@ -1,7 +1,6 @@ {% load django_tables2 %} {% load i18n %} {% load django_tables2_bulma_template %} -{% load joinsep %} {% block table-wrapper %}
@@ -13,34 +12,38 @@ {% block table.thead.row %} {% for column in table.columns %} - {% block table.thead.th %} - - {% if column.orderable %} - {% if column.is_ordered %} - {% is_descending column.order_by as descending %} - {% if descending %} - + + {% if column.name not in hide %} + {% block table.thead.th %} + + {% if column.orderable %} + {% if column.is_ordered %} + {% is_descending column.order_by as descending %} + {% if descending %} + + {% else %} + + {% endif %} {% else %} - + {% endif %} + + {{ column.header }} + {% else %} - - {% endif %} - {{ column.header }} - - {% else %} - {{ column.header }} - {% endif %} - - {% endblock table.thead.th %} + {% endif %} + + {% endblock table.thead.th %} + {% endif %} + {% endfor %} {% endblock table.thead.row %} @@ -65,144 +68,151 @@ has-background-info-light {% endif %}"> {% for column, cell in row.items %} - {% block table.tbody.td %} - {% 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' %} - -
- - + + + {% elif column.name == 'msg' %} + {{ row.cells.msg }} + {% elif column.name == 'host' %} + + {{ cell }} -
- {% if row.cells.src == 'irc' %} - - {% endif %} -
- {% if row.cells.num_chans is not None %} + + {% elif column.name == 'nick' %} + +
- - {{ row.cells.num_chans }} - + {% if row.cells.online is True %} + + + + {% elif row.cells.online is False %} + + + + {% else %} + + + + {% endif %}
- {% endif %} -
- - {% elif column.name == 'channel' %} - -
- - {{ cell }} - - {% if row.cells.num_users is not None %} + + {{ cell }} +
- - {{ row.cells.num_users }} - + {% if row.cells.src == 'irc' %} + + {% endif %}
- {% endif %} -
- - {% elif column.name == 'net' %} - - + {% 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 }} - - - {% else %} - - {{ cell }} - - {% endif %} - {% endblock table.tbody.td %} + + {% endif %} + {% endblock table.tbody.td %} + {% endif %} {% endfor %} {% endblock table.tbody.row %} @@ -309,24 +319,4 @@ {% 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/drilldown.py b/core/views/ui/drilldown.py index e1882ba..829c28c 100644 --- a/core/views/ui/drilldown.py +++ b/core/views/ui/drilldown.py @@ -190,6 +190,7 @@ class DrilldownTableView(SingleTableView): for k, v in self.context.items(): if k not in context: context[k] = v + context["hide"] = ["date", "time", "id", "num", "channel_nsfw", "num_users", "num_chans", "exemption", "version_sentiment"] if request.method == "GET": if not request.htmx: diff --git a/core/views/ui/tables.py b/core/views/ui/tables.py index d5c8b30..2d2f0a7 100644 --- a/core/views/ui/tables.py +++ b/core/views/ui/tables.py @@ -5,9 +5,8 @@ from django_tables2.columns.base import BoundColumn # Make the table column headings lowercase orig_Column_header = BoundColumn.header - @property -def lower_header(self): +def format_header(self): header = orig_Column_header.__get__(self) header = header.lower() header = header.title() @@ -20,8 +19,7 @@ def lower_header(self): return header - -BoundColumn.header = lower_header +BoundColumn.header = format_header class DrilldownTable(Table): @@ -38,8 +36,8 @@ class DrilldownTable(Table): num = Column() src = Column() ts = Column() - # date = Column() - # time = Column() + date = Column() + time = Column() type = Column() bot = Column() channel = Column()