From 11d45424125788db78bbb90e993f31bcc88dc27c Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Sat, 11 Feb 2023 15:44:20 +0000 Subject: [PATCH] Cache the table and remove CRUD tools included in mixins --- core/templates/modals/context.html | 2 +- core/templates/modals/drilldown.html | 2 +- core/templates/partials/close-modal.html | 1 - core/templates/partials/close-widget.html | 3 - core/templates/partials/close-window.html | 3 - core/templates/partials/results_load.html | 2 +- core/templates/partials/results_table.html | 999 +++++++++--------- core/templates/widgets/drilldown.html | 2 +- .../templates/window-content/object-form.html | 34 - core/templates/window-content/object.html | 45 - core/templates/window-content/objects.html | 45 - core/templates/windows/drilldown.html | 2 +- core/templates/wm/modal.html | 20 - core/templates/wm/page.html | 6 - core/templates/wm/panel.html | 17 - core/templates/wm/widget.html | 37 - core/templates/wm/window.html | 10 - core/views/ui/drilldown.py | 8 +- 18 files changed, 513 insertions(+), 725 deletions(-) delete mode 100644 core/templates/partials/close-modal.html delete mode 100644 core/templates/partials/close-widget.html delete mode 100644 core/templates/partials/close-window.html delete mode 100644 core/templates/window-content/object-form.html delete mode 100644 core/templates/window-content/object.html delete mode 100644 core/templates/window-content/objects.html delete mode 100644 core/templates/wm/modal.html delete mode 100644 core/templates/wm/page.html delete mode 100644 core/templates/wm/panel.html delete mode 100644 core/templates/wm/widget.html delete mode 100644 core/templates/wm/window.html diff --git a/core/templates/modals/context.html b/core/templates/modals/context.html index 2b0c7a4..51f99b2 100644 --- a/core/templates/modals/context.html +++ b/core/templates/modals/context.html @@ -1,4 +1,4 @@ -{% extends 'wm/modal.html' %} +{% extends 'mixins/wm/modal.html' %} {% load index %} {% load static %} diff --git a/core/templates/modals/drilldown.html b/core/templates/modals/drilldown.html index 4eab9de..86da065 100644 --- a/core/templates/modals/drilldown.html +++ b/core/templates/modals/drilldown.html @@ -1,4 +1,4 @@ -{% extends 'wm/modal.html' %} +{% extends 'mixins/wm/modal.html' %} {% block modal_content %} {% include 'window-content/drilldown.html' %} diff --git a/core/templates/partials/close-modal.html b/core/templates/partials/close-modal.html deleted file mode 100644 index 6c0173c..0000000 --- a/core/templates/partials/close-modal.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/core/templates/partials/close-widget.html b/core/templates/partials/close-widget.html deleted file mode 100644 index 0c66e85..0000000 --- a/core/templates/partials/close-widget.html +++ /dev/null @@ -1,3 +0,0 @@ - \ No newline at end of file diff --git a/core/templates/partials/close-window.html b/core/templates/partials/close-window.html deleted file mode 100644 index 894974c..0000000 --- a/core/templates/partials/close-window.html +++ /dev/null @@ -1,3 +0,0 @@ - \ No newline at end of file diff --git a/core/templates/partials/results_load.html b/core/templates/partials/results_load.html index 8b631ae..13c5f88 100644 --- a/core/templates/partials/results_load.html +++ b/core/templates/partials/results_load.html @@ -1,4 +1,4 @@ -{% extends 'wm/widget.html' %} +{% extends 'mixins/wm/widget.html' %} {% load static %} {% block heading %} diff --git a/core/templates/partials/results_table.html b/core/templates/partials/results_table.html index a466c49..1d9ecf3 100644 --- a/core/templates/partials/results_table.html +++ b/core/templates/partials/results_table.html @@ -5,529 +5,532 @@ {% load urlsafe %} {% load pretty %} {% load splitstr %} +{% load cache %} -{% block table-wrapper %} - -
- {% block table %} -
-
- + {% endblock table-wrapper %} +{% endcache %} \ No newline at end of file diff --git a/core/templates/widgets/drilldown.html b/core/templates/widgets/drilldown.html index 1b460c1..ae37180 100644 --- a/core/templates/widgets/drilldown.html +++ b/core/templates/widgets/drilldown.html @@ -1,4 +1,4 @@ -{% extends 'wm/widget.html' %} +{% extends 'mixins/wm/widget.html' %} {% block widget_options %} diff --git a/core/templates/window-content/object-form.html b/core/templates/window-content/object-form.html deleted file mode 100644 index 0cf755e..0000000 --- a/core/templates/window-content/object-form.html +++ /dev/null @@ -1,34 +0,0 @@ -{% include 'mixins/partials/notify.html' %} -{% if page_title is not None %} -

{{ page_title }}

-{% endif %} -{% if page_subtitle is not None %} -

{{ page_subtitle }}

-{% endif %} -{% load crispy_forms_tags %} - -{% load crispy_forms_bulma_field %} -
- {% csrf_token %} - {{ form|crispy }} - {% if hide_cancel is not True %} - - {% endif %} - -
- - - - - - - - diff --git a/core/templates/window-content/object.html b/core/templates/window-content/object.html deleted file mode 100644 index 343ae7c..0000000 --- a/core/templates/window-content/object.html +++ /dev/null @@ -1,45 +0,0 @@ -{% include 'mixins/partials/notify.html' %} -{% if page_title is not None %} -

{{ page_title }}

-{% endif %} -{% if page_subtitle is not None %} -

{{ page_subtitle }}

-{% endif %} -
- - {% if submit_url is not None %} - - {% endif %} - {% if delete_all_url is not None %} - - {% endif %} -
- -{% include detail_template %} - diff --git a/core/templates/window-content/objects.html b/core/templates/window-content/objects.html deleted file mode 100644 index 81423ed..0000000 --- a/core/templates/window-content/objects.html +++ /dev/null @@ -1,45 +0,0 @@ -{% include 'mixins/partials/notify.html' %} -{% if page_title is not None %} -

{{ page_title }}

-{% endif %} -{% if page_subtitle is not None %} -

{{ page_subtitle }}

-{% endif %} -
- - {% if submit_url is not None %} - - {% endif %} - {% if delete_all_url is not None %} - - {% endif %} -
- -{% include list_template %} - diff --git a/core/templates/windows/drilldown.html b/core/templates/windows/drilldown.html index d070e4c..c7a78df 100644 --- a/core/templates/windows/drilldown.html +++ b/core/templates/windows/drilldown.html @@ -1,4 +1,4 @@ -{% extends 'wm/window.html' %} +{% extends 'mixins/wm/window.html' %} {% block heading %} Drilldown diff --git a/core/templates/wm/modal.html b/core/templates/wm/modal.html deleted file mode 100644 index b8e5614..0000000 --- a/core/templates/wm/modal.html +++ /dev/null @@ -1,20 +0,0 @@ -{% load static %} - - -{% block scripts %} -{% endblock %} - -{% block styles %} -{% endblock %} - - \ No newline at end of file diff --git a/core/templates/wm/page.html b/core/templates/wm/page.html deleted file mode 100644 index 93ea8c1..0000000 --- a/core/templates/wm/page.html +++ /dev/null @@ -1,6 +0,0 @@ -{% extends "base.html" %} - - -{% block content %} - {% include window_content %} -{% endblock %} diff --git a/core/templates/wm/panel.html b/core/templates/wm/panel.html deleted file mode 100644 index b180b38..0000000 --- a/core/templates/wm/panel.html +++ /dev/null @@ -1,17 +0,0 @@ - - diff --git a/core/templates/wm/widget.html b/core/templates/wm/widget.html deleted file mode 100644 index 9ef8154..0000000 --- a/core/templates/wm/widget.html +++ /dev/null @@ -1,37 +0,0 @@ -
-
-
- - -
-
-
- - -{% block custom_end %} -{% endblock %} \ No newline at end of file diff --git a/core/templates/wm/window.html b/core/templates/wm/window.html deleted file mode 100644 index 3a9a776..0000000 --- a/core/templates/wm/window.html +++ /dev/null @@ -1,10 +0,0 @@ - - {% extends 'wm/panel.html' %} - {% block heading %} - {{ title }} - {% endblock %} - - {% block panel_content %} - {% include window_content %} - {% endblock %} - \ No newline at end of file diff --git a/core/views/ui/drilldown.py b/core/views/ui/drilldown.py index deaef8c..b97b993 100644 --- a/core/views/ui/drilldown.py +++ b/core/views/ui/drilldown.py @@ -98,10 +98,11 @@ def make_graph(results): class DrilldownTableView(SingleTableView): table_class = DrilldownTable - template_name = "wm/widget.html" + template_name = "mixins/wm/widget.html" window_content = "window-content/results.html" # htmx_partial = "partials/" paginate_by = settings.DRILLDOWN_RESULTS_PER_PAGE + widget_options = 'gs-w="10" gs-h="1" gs-y="10" gs-x="1"' def common_request(self, request, **kwargs): extra_params = {} @@ -112,6 +113,7 @@ class DrilldownTableView(SingleTableView): sizes = settings.MAIN_SIZES if request.GET: + print("GET") self.template_name = "index.html" # GET arguments in URL like ?query=xyz query_params = request.GET.dict() @@ -119,6 +121,7 @@ class DrilldownTableView(SingleTableView): if request.resolver_match.url_name == "search_partial": self.template_name = "partials/results_table.html" elif request.POST: + print("POST") query_params = request.POST.dict() else: self.template_name = "index.html" @@ -126,10 +129,12 @@ class DrilldownTableView(SingleTableView): # Don't try to search, since there's clearly nothing to do params_with_defaults = {} add_defaults(params_with_defaults) + print("GOT TO CONTEXT") context = { "sizes": sizes, "params": params_with_defaults, "unique": "results", + "widget_options": self.widget_options, "window_content": self.window_content, "title": "Results", } @@ -187,6 +192,7 @@ class DrilldownTableView(SingleTableView): # We don't want a random one since we only want one results pane. context["unique"] = "results" context["window_content"] = self.window_content + context["widget_options"] = self.widget_options context["title"] = "Results" # Valid sizes