Begin implementing modern tables
This commit is contained in:
0
core/views/ui/__init__.py
Normal file
0
core/views/ui/__init__.py
Normal file
@@ -3,7 +3,9 @@ import json
|
||||
from django.conf import settings
|
||||
from django.http import HttpResponse, JsonResponse
|
||||
from django.shortcuts import render
|
||||
from django.utils.html import format_html
|
||||
from django.views import View
|
||||
from django_tables2 import SingleTableMixin
|
||||
from rest_framework.parsers import FormParser
|
||||
from rest_framework.views import APIView
|
||||
|
||||
@@ -14,6 +16,33 @@ from core.lib.threshold import (
|
||||
get_chans,
|
||||
get_users,
|
||||
)
|
||||
from core.views.ui.tables import DrilldownTable
|
||||
|
||||
|
||||
class DrilldownTableView(View, SingleTableMixin):
|
||||
table_class = DrilldownTable
|
||||
template_name = "ui/drilldown/table_results.html"
|
||||
paginate_by = 5
|
||||
|
||||
def post(self, request):
|
||||
context = query_results(request)
|
||||
table = DrilldownTable(context["results"])
|
||||
context["table"] = table
|
||||
del context["results"]
|
||||
if "message" in context:
|
||||
return render(request, self.template_name, context)
|
||||
|
||||
if self.request.htmx:
|
||||
print("IS HTMX")
|
||||
template_name = "ui/drilldown/table_results.html"
|
||||
else:
|
||||
print("IS NOT HTMX")
|
||||
template_name = "ui/drilldown/table_results_partial.html"
|
||||
|
||||
if context:
|
||||
return render(request, self.template_name, context)
|
||||
else:
|
||||
return HttpResponse("No results")
|
||||
|
||||
|
||||
class Drilldown(View):
|
||||
|
||||
33
core/views/ui/tables.py
Normal file
33
core/views/ui/tables.py
Normal file
@@ -0,0 +1,33 @@
|
||||
from django_tables2 import Table, Column
|
||||
|
||||
class DrilldownTable(Table):
|
||||
id = Column()
|
||||
host = Column()
|
||||
ident = Column()
|
||||
nick = Column()
|
||||
nick_id = Column()
|
||||
user_id = Column()
|
||||
msg = Column()
|
||||
msg_id = Column()
|
||||
net = Column()
|
||||
net_id = Column()
|
||||
num = Column()
|
||||
src = Column()
|
||||
ts = Column()
|
||||
type = Column()
|
||||
bot = Column()
|
||||
channel = Column()
|
||||
channel_category = Column()
|
||||
channel_category_id = Column()
|
||||
channel_category_nsfw = Column()
|
||||
channel_id = Column()
|
||||
channel_nsfw = Column()
|
||||
guild_member_count = Column()
|
||||
guild = Column()
|
||||
guild_id = Column()
|
||||
mode = Column()
|
||||
modearg = Column()
|
||||
sentiment = Column()
|
||||
status = Column()
|
||||
user = Column()
|
||||
version_sentiment = Column()
|
||||
Reference in New Issue
Block a user