From b4146773d9cf26a258830ea9a9b53ef406687396 Mon Sep 17 00:00:00 2001 From: vismayajochem Date: Mon, 23 Feb 2026 14:29:12 +0100 Subject: [PATCH 01/13] Search query first attempt #2233 --- login/templates/login/user_tables.html | 29 ++++++++++++++++----- login/views.py | 36 +++++++++++++++++++++----- 2 files changed, 52 insertions(+), 13 deletions(-) diff --git a/login/templates/login/user_tables.html b/login/templates/login/user_tables.html index 374cb5629..edd5ae915 100644 --- a/login/templates/login/user_tables.html +++ b/login/templates/login/user_tables.html @@ -5,6 +5,22 @@ {% block main-content-body %} {% if profile_user == request.user %} {% include "login/user_nav.html" %} + + +

Published tables

@@ -177,21 +193,21 @@

Published tables

{% if published_tables_page.has_previous %}
  • Previous
  • {% endif %}
  • + href="?published_page={{ published_tables_page.number }}&draft_page={{ draft_page }}&search={{ search_query }}"> {{ published_tables_page.number }}
  • {% if published_tables_page.has_next %}
  • Next + href="?published_page={{ published_tables_page.next_page_number }}&draft_page={{ draft_page }}&search={{ search_query }}">Next
  • {% endif %} @@ -356,21 +372,21 @@

    Draft tables

    {% if draft_tables_page.has_previous %}
  • Previous
  • {% endif %}
  • + href="?draft_page={{ draft_tables_page.number }}&published_page={{ published_page }}&search={{ search_query }}"> {{ draft_tables_page.number }}
  • {% if draft_tables_page.has_next %}
  • Next + href="?draft_page={{ draft_tables_page.next_page_number }}&published_page={{ published_page }}&search={{ search_query }}">Next
  • {% endif %} @@ -399,6 +415,7 @@

    Draft tables

    + {% endif %} {% endif %} diff --git a/login/views.py b/login/views.py index 99203b38d..aab9fad43 100644 --- a/login/views.py +++ b/login/views.py @@ -36,6 +36,7 @@ from django.views.decorators.http import require_POST from django.views.generic import RedirectView, View from django.views.generic.edit import DeleteView +from django.db.models import F, Q from rest_framework.authtoken.models import Token import login.permissions @@ -58,10 +59,11 @@ class TablesView(View): - @method_decorator(never_cache) - def get(self, request, user_id): - user = get_object_or_404(OepUser, pk=user_id) + + def _get_filtered_tables(self, user, search_query=""): + """Return filtered querysets for draft and published tables.""" tables_set = user.get_tables_queryset(min_permission_level=WRITE_PERM) + draft_tables = tables_set.filter(is_publish=False).order_by( F("date_updated").desc(nulls_last=True), "human_readable_name" ) @@ -69,11 +71,28 @@ def get(self, request, user_id): F("date_updated").desc(nulls_last=True), "human_readable_name" ) + if search_query: + from django.db.models import Q + + q_filter = Q(name__icontains=search_query) | Q( + human_readable_name__icontains=search_query + ) + draft_tables = draft_tables.filter(q_filter) + published_tables = published_tables.filter(q_filter) + + return draft_tables, published_tables + + @method_decorator(never_cache) + def get(self, request, user_id): + user = get_object_or_404(OepUser, pk=user_id) + search_query = request.GET.get("search", "").strip() + + draft_tables, published_tables = self._get_filtered_tables(user, search_query) + # Paginate tables published_paginator = Paginator(published_tables, ITEMS_PER_PAGE) draft_paginator = Paginator(draft_tables, ITEMS_PER_PAGE) - # Check if the request contains a page published_page = request.GET.get("published_page", 1) published_page_obj = published_paginator.get_page(published_page) @@ -87,12 +106,15 @@ def get(self, request, user_id): "topics": [t.name for t in Topic.objects.all()], "draft_page": draft_page, "published_page": published_page, + "search_query": search_query, } - # TODO: Fix this is_ajax as it is outdated according to django documentation ... - # provide better api endpoint for http requests via HTMX if "HX-Request" in request.headers: - return render(request, "login/partials/user_partial_tables.html", context) + return render( + request, + "login/partials/user_partial_tables.html", + context, + ) else: return render(request, "login/user_tables.html", context) From 0205eb385d3d001a8930bb6b658ca6ded4cc0f6b Mon Sep 17 00:00:00 2001 From: vismayajochem Date: Mon, 23 Feb 2026 15:45:28 +0100 Subject: [PATCH 02/13] after swap #2233 --- login/templates/login/user_tables.html | 1 + 1 file changed, 1 insertion(+) diff --git a/login/templates/login/user_tables.html b/login/templates/login/user_tables.html index edd5ae915..0f3aa9a61 100644 --- a/login/templates/login/user_tables.html +++ b/login/templates/login/user_tables.html @@ -18,6 +18,7 @@ hx-target="#tables-container" hx-include="this" hx-push-url="true" + hx-on::after-swap="this.focus()" />
    From 39fb95247a2b27ce3281b236335185c48cd524eb Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 25 Feb 2026 10:26:16 +0000 Subject: [PATCH 03/13] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- login/templates/login/user_tables.html | 657 +++++++++++++------------ login/views.py | 3 +- 2 files changed, 330 insertions(+), 330 deletions(-) diff --git a/login/templates/login/user_tables.html b/login/templates/login/user_tables.html index edd5ae915..d9634163f 100644 --- a/login/templates/login/user_tables.html +++ b/login/templates/login/user_tables.html @@ -5,8 +5,10 @@ {% block main-content-body %} {% if profile_user == request.user %} {% include "login/user_nav.html" %} - -
    @@ -492,8 +493,8 @@

    Draft tables

    // Refresh the page after any htmx request ... keep until partials are // implemented for the draft & published tables document.addEventListener("htmx:afterRequest", function (event) { - if (event.detail.successful) { - window.location.reload(); + if (event.detail.successful && event.detail.elt.id !== 'table-search') { + window.location.reload(); } }); diff --git a/login/views.py b/login/views.py index aab9fad43..dd618457a 100644 --- a/login/views.py +++ b/login/views.py @@ -36,7 +36,7 @@ from django.views.decorators.http import require_POST from django.views.generic import RedirectView, View from django.views.generic.edit import DeleteView -from django.db.models import F, Q +from django.db.models import Q from rest_framework.authtoken.models import Token import login.permissions @@ -72,7 +72,6 @@ def _get_filtered_tables(self, user, search_query=""): ) if search_query: - from django.db.models import Q q_filter = Q(name__icontains=search_query) | Q( human_readable_name__icontains=search_query @@ -86,6 +85,7 @@ def _get_filtered_tables(self, user, search_query=""): def get(self, request, user_id): user = get_object_or_404(OepUser, pk=user_id) search_query = request.GET.get("search", "").strip() + has_search_param = "search" in request.GET draft_tables, published_tables = self._get_filtered_tables(user, search_query) @@ -109,7 +109,7 @@ def get(self, request, user_id): "search_query": search_query, } - if "HX-Request" in request.headers: + if "HX-Request" in request.headers and not has_search_param: return render( request, "login/partials/user_partial_tables.html", From 691c3f4fffa4af84ab9d5aee76e3d5581ee51373 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 25 Feb 2026 12:55:25 +0000 Subject: [PATCH 05/13] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- login/templates/login/user_tables.html | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/login/templates/login/user_tables.html b/login/templates/login/user_tables.html index a61fe548e..742b4c4f4 100644 --- a/login/templates/login/user_tables.html +++ b/login/templates/login/user_tables.html @@ -21,8 +21,7 @@ hx-select="#tables-container" hx-include="this" hx-push-url="true" - hx-swap="outerHTML" - /> + hx-swap="outerHTML" />
    @@ -495,7 +494,7 @@

    Draft tables

    // Refresh the page after any htmx request ... keep until partials are // implemented for the draft & published tables document.addEventListener("htmx:afterRequest", function (event) { - if (event.detail.successful && event.detail.elt.id !== 'table-search') { + if (event.detail.successful && event.detail.elt.id !== 'table-search') { window.location.reload(); } }); From ceac7d2b26dbecc517b14fd339b66723c7449f9a Mon Sep 17 00:00:00 2001 From: vismayajochem Date: Wed, 25 Feb 2026 14:26:05 +0100 Subject: [PATCH 06/13] Fix empty search #2233 --- login/views.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/login/views.py b/login/views.py index 5be541b0e..cc643f23a 100644 --- a/login/views.py +++ b/login/views.py @@ -111,9 +111,15 @@ def get(self, request, user_id): if "HX-Request" in request.headers and not has_search_param: return render( request, - "login/partials/user_partial_tables.html", + "login/partials/tables_sections.html", context, ) + # elif "HX-Request" in request.headers: + # return render( + # request, + # "login/partials/user_partial_tables.html", + # context, + # ) else: return render(request, "login/user_tables.html", context) From 11cb84aee57a279e67991655bd5f10555eea5f66 Mon Sep 17 00:00:00 2001 From: vismayajochem Date: Wed, 25 Feb 2026 14:31:30 +0100 Subject: [PATCH 07/13] Fix empty search #2233 --- .../login/partials/tables_sections.html | 397 ++++++++++++++++++ 1 file changed, 397 insertions(+) create mode 100644 login/templates/login/partials/tables_sections.html diff --git a/login/templates/login/partials/tables_sections.html b/login/templates/login/partials/tables_sections.html new file mode 100644 index 000000000..82eeb5d3a --- /dev/null +++ b/login/templates/login/partials/tables_sections.html @@ -0,0 +1,397 @@ + +
    +

    Published tables

    + {% if published_tables_page %} +
    +
    + {% for table in published_tables_page %} + {% with license_status=table.validate_open_data_license %} +
    +
    +
    +
    + {% for topic in table.topics.all %} +
    + + + + + {{ topic.name }} +
    + {% endfor %} + {% if license_status.status %} +
    + + + + License +
    + {% else %} +
    + + + + License check failed +
    + {% endif %} +
    +
    + +
    +
    + + {% comment %} + {% if table.is_reviewed %} +
    + + + + Reviewed +
    +
    + + + +
    + {% else %} +
    + Not reviewed +
    + {% endif %} + {% endcomment %} + +
    + + +
    + {% if not license_status.status %} +
    +
    + + + + +
    +
    + Potential publishing without an open license. +
    +
    +

    + +

    +
    + License check failed because of: + {{ license_status.error }} +
    +
    + Please use a SPDX license identifier. +
    +
    + Please revisit your metadata and check the license + information. Do not publish data that does not hold an + open license. +
    +
    +
    + {% endif %} +
    +
    + {% endwith %} + {% endfor %} +
    +
    + + {% else %} + You have never published a table. + {% endif %} +
    + +
    +

    Draft tables

    + {% if draft_tables_page.object_list %} +
    +
    + {% for table in draft_tables_page %} + {% with license_status=table.validate_open_data_license %} +
    +
    +
    +
    + {% for topic in table.topics.all %} +
    + + + + + {{ topic.name }} +
    + {% endfor %} + {% if license_status.status %} +
    + + + + License +
    + {% else %} +
    + + + + License check failed +
    + {% endif %} +
    +
    + {% if license_status.status %} + + {% else %} + + {% endif %} + +
    +
    + + {% comment %} + {% if table.is_reviewed %} +
    + + + + Reviewed +
    +
    +
    + + +
    + {% else %} +
    + Not reviewed +
    + {% endif %} + {% endcomment %} + +
    + + +
    + {% if not license_status.status %} +
    +
    + + + + +
    +
    + {{ table.license_status.error }} +
    + +
    + {% endif %} +
    +
    + {% endwith %} + {% endfor %} +
    +
    + + {% else %} + +
    +
    +
    + No table has been uploaded yet! +
    +
    + + + + + +
    + + +
    +
    +
    +{% endif %} + From fa6fc586695228af09e89bb52df93512a82ec865 Mon Sep 17 00:00:00 2001 From: vismayajochem Date: Wed, 25 Feb 2026 14:35:41 +0100 Subject: [PATCH 08/13] make reuse compliant #2233 --- REUSE.toml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/REUSE.toml b/REUSE.toml index 910cfafb0..af3b3a9f9 100644 --- a/REUSE.toml +++ b/REUSE.toml @@ -861,6 +861,14 @@ SPDX-FileCopyrightText = [ "2024 Jonas Huber © Reiner Lemoine Institut", ] +[[annotations]] +path = "login/templates/login/partials/tables_sections.html" +precedence = "override" +SPDX-License-Identifier = "AGPL-3.0-or-later" +SPDX-FileCopyrightText = [ + "2025 Vismaya Jochem © Reiner Lemoine Institut", +] + [[annotations]] path = "login/templates/login/partials/badge_icon.html" precedence = "override" From e463d87235513a422b4018ed868b9c48e601b44e Mon Sep 17 00:00:00 2001 From: vismayajochem Date: Wed, 25 Feb 2026 14:46:23 +0100 Subject: [PATCH 09/13] Delete user_partial_tables #2233 --- .../login/partials/user_partial_tables.html | 73 ------------------- login/views.py | 6 -- 2 files changed, 79 deletions(-) delete mode 100644 login/templates/login/partials/user_partial_tables.html diff --git a/login/templates/login/partials/user_partial_tables.html b/login/templates/login/partials/user_partial_tables.html deleted file mode 100644 index 1f49f7d87..000000000 --- a/login/templates/login/partials/user_partial_tables.html +++ /dev/null @@ -1,73 +0,0 @@ -{% load compress %} -{% load django_bootstrap5 %} -{% load static %} -{% if profile_user == request.user %} -
    -
    -
    -

    Published

    -
    -
    - {% for table in published_tables %} -
    -
    -
    -
    {{ table.name }}
    - View Table -
    -
    -
    - {% endfor %} -
    -
    -

    Draft

    -
    -
    - {% for table in draft_tables %} -
    -
    -
    -
    {{ table.name }}
    - View Table - {% if table.is_reviewed and not table.is_publish %} - - - {% endif %} -
    -
    -
    - {% endfor %} -
    -
    - -
    -
    -
    -{% endif %} -{% comment "@Daryna what is this used for?" %} - -{% endcomment %} - diff --git a/login/views.py b/login/views.py index cc643f23a..8876721c3 100644 --- a/login/views.py +++ b/login/views.py @@ -114,12 +114,6 @@ def get(self, request, user_id): "login/partials/tables_sections.html", context, ) - # elif "HX-Request" in request.headers: - # return render( - # request, - # "login/partials/user_partial_tables.html", - # context, - # ) else: return render(request, "login/user_tables.html", context) From 9fe8c75db02937ee30191d5253b38d9a751cc9af Mon Sep 17 00:00:00 2001 From: vismayajochem Date: Wed, 25 Feb 2026 14:46:40 +0100 Subject: [PATCH 10/13] Resuse compliance #2233 --- REUSE.toml | 8 -------- script/reuse/.reuse/dep5 | 4 ---- 2 files changed, 12 deletions(-) diff --git a/REUSE.toml b/REUSE.toml index af3b3a9f9..4c49b6fbc 100644 --- a/REUSE.toml +++ b/REUSE.toml @@ -845,14 +845,6 @@ SPDX-FileCopyrightText = [ "2024 Jonas Huber © Reiner Lemoine Institut", ] -[[annotations]] -path = "login/templates/login/partials/user_partial_tables.html" -precedence = "override" -SPDX-License-Identifier = "AGPL-3.0-or-later" -SPDX-FileCopyrightText = [ - "2024 Jonas Huber © Reiner Lemoine Institut", -] - [[annotations]] path = "login/templates/login/partials/group_component_invite_user.html" precedence = "override" diff --git a/script/reuse/.reuse/dep5 b/script/reuse/.reuse/dep5 index d2b1c8d32..670a36e6e 100644 --- a/script/reuse/.reuse/dep5 +++ b/script/reuse/.reuse/dep5 @@ -502,10 +502,6 @@ Files: login/templates/login/partials/group_component_form_edit.html Copyright: Jonas Huber License: MIT -Files: login/templates/login/partials/user_partial_tables.html -Copyright: Jonas Huber -License: MIT - Files: login/templates/login/partials/group_component_invite_user.html Copyright: Jonas Huber License: MIT From 070d2183a03cbd4246eb24cee5ac269d1e4b2861 Mon Sep 17 00:00:00 2001 From: vismayajochem Date: Wed, 25 Feb 2026 14:50:41 +0100 Subject: [PATCH 11/13] Clean up html into partials #2233 --- login/templates/login/user_tables.html | 399 +------------------------ 1 file changed, 2 insertions(+), 397 deletions(-) diff --git a/login/templates/login/user_tables.html b/login/templates/login/user_tables.html index 742b4c4f4..0f32f6751 100644 --- a/login/templates/login/user_tables.html +++ b/login/templates/login/user_tables.html @@ -24,403 +24,8 @@ hx-swap="outerHTML" />
    - -
    -

    Published tables

    - {% if published_tables_page %} -
    -
    - {% for table in published_tables_page %} - {% with license_status=table.validate_open_data_license %} -
    -
    -
    -
    - {% for topic in table.topics.all %} -
    - - - - - {{ topic.name }} -
    - {% endfor %} - {% if license_status.status %} -
    - - - - License -
    - {% else %} -
    - - - - License check failed -
    - {% endif %} -
    -
    - -
    -
    - - {% comment %} - {% if table.is_reviewed %} -
    - - - - Reviewed -
    -
    - - - -
    - {% else %} -
    - Not reviewed -
    - {% endif %} - {% endcomment %} - -
    - - -
    - {% if not license_status.status %} -
    -
    - - - - -
    -
    - Potential publishing without an open license. -
    -
    -

    - -

    -
    - License check failed because of: - {{ license_status.error }} -
    -
    - Please use a SPDX license identifier. -
    -
    - Please revisit your metadata and check the license - information. Do not publish data that does not hold an - open license. -
    -
    -
    - {% endif %} -
    -
    - {% endwith %} - {% endfor %} -
    -
    - - {% else %} - You have never published a table. - {% endif %} -
    - -
    -

    Draft tables

    - {% if draft_tables_page.object_list %} -
    -
    - {% for table in draft_tables_page %} - {% with license_status=table.validate_open_data_license %} -
    -
    -
    -
    - {% for topic in table.topics.all %} -
    - - - - - {{ topic.name }} -
    - {% endfor %} - {% if license_status.status %} -
    - - - - License -
    - {% else %} -
    - - - - License check failed -
    - {% endif %} -
    -
    - {% if license_status.status %} - - {% else %} - - {% endif %} - -
    -
    - - {% comment %} - {% if table.is_reviewed %} -
    - - - - Reviewed -
    -
    -
    - - -
    - {% else %} -
    - Not reviewed -
    - {% endif %} - {% endcomment %} - -
    - - -
    - {% if not license_status.status %} -
    -
    - - - - -
    -
    - {{ table.license_status.error }} -
    - -
    - {% endif %} -
    -
    - {% endwith %} - {% endfor %} -
    -
    - - {% else %} - -
    -
    -
    - No table has been uploaded yet! -
    -
    - - - - - -
    - - -
    -
    -
    - {% endif %} - + {% include "login/partials/tables_sections.html" %} + {% endif %} From 67b55f3331ef52fcda0913162995024f0d8ffc9b Mon Sep 17 00:00:00 2001 From: vismayajochem Date: Wed, 25 Feb 2026 15:09:01 +0100 Subject: [PATCH 12/13] Update changelog #2233 --- versions/changelogs/current.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/versions/changelogs/current.md b/versions/changelogs/current.md index 60855a501..5045b37fe 100644 --- a/versions/changelogs/current.md +++ b/versions/changelogs/current.md @@ -10,8 +10,14 @@ SPDX-License-Identifier: CC0-1.0 ## Changes +- Create tables_sections.html, delete user_partial_tables + [(#2248)](https://github.com/OpenEnergyPlatform/oeplatform/pull/2248) + ### Features +- Build search field to search in the user's tables + [(#2248)](https://github.com/OpenEnergyPlatform/oeplatform/pull/2248) + ### Bugs ## Documentation updates From ecf14f73f427b445a19c3a868bd11df65e91adaf Mon Sep 17 00:00:00 2001 From: vismayajochem Date: Wed, 25 Feb 2026 15:09:41 +0100 Subject: [PATCH 13/13] Fix language #2233 --- login/templates/login/user_tables.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/login/templates/login/user_tables.html b/login/templates/login/user_tables.html index 0f32f6751..51fe24072 100644 --- a/login/templates/login/user_tables.html +++ b/login/templates/login/user_tables.html @@ -5,7 +5,7 @@ {% block main-content-body %} {% if profile_user == request.user %} {% include "login/user_nav.html" %} - +