diff --git a/src/argus_htmx/templates/htmx/base.html b/src/argus_htmx/templates/htmx/base.html index 8ffc0bc0..3b366edb 100644 --- a/src/argus_htmx/templates/htmx/base.html +++ b/src/argus_htmx/templates/htmx/base.html @@ -43,7 +43,7 @@ Logged in as: {{ request.user }}
-
  • {% include "htmx/themes/theme_dropdown.html" %}
  • +
  • {% include "htmx/themes/_theme_dropdown.html" %}
  • {% include "htmx/dateformat/_dateformat_dropdown.html" %}
  • Preferences… diff --git a/src/argus_htmx/templates/htmx/themes/theme_dropdown.html b/src/argus_htmx/templates/htmx/themes/_theme_dropdown.html similarity index 100% rename from src/argus_htmx/templates/htmx/themes/theme_dropdown.html rename to src/argus_htmx/templates/htmx/themes/_theme_dropdown.html diff --git a/src/argus_htmx/templates/htmx/themes/theme_list.html b/src/argus_htmx/templates/htmx/themes/_theme_list.html similarity index 100% rename from src/argus_htmx/templates/htmx/themes/theme_list.html rename to src/argus_htmx/templates/htmx/themes/_theme_list.html diff --git a/src/argus_htmx/templates/htmx/themes/themes_list.html b/src/argus_htmx/templates/htmx/themes/themes_list.html deleted file mode 100644 index 9b53644b..00000000 --- a/src/argus_htmx/templates/htmx/themes/themes_list.html +++ /dev/null @@ -1,22 +0,0 @@ -{% extends "htmx/base.html" %} -{% block main %} -
    -

    Switch theme

    - {% if preferences.argus_htmx.theme %} -

    Theme is set to: {{ preferences.argus_htmx.theme }}

    - {% else %} -

    No theme set

    - {% endif %} - -
    -{% endblock main %} diff --git a/src/argus_htmx/themes/urls.py b/src/argus_htmx/themes/urls.py index 87d96469..267667b8 100644 --- a/src/argus_htmx/themes/urls.py +++ b/src/argus_htmx/themes/urls.py @@ -5,7 +5,6 @@ app_name = "htmx" urlpatterns = [ - path("", views.ThemeListView.as_view(), name="theme-list"), path("names/", views.theme_names, name="theme-names"), path("change/", views.change_theme, name="change-theme"), ] diff --git a/src/argus_htmx/themes/views.py b/src/argus_htmx/themes/views.py index 8954cf09..9a21c3b0 100644 --- a/src/argus_htmx/themes/views.py +++ b/src/argus_htmx/themes/views.py @@ -1,10 +1,9 @@ import logging from django.shortcuts import render -from django.views.generic import ListView from django.views.decorators.http import require_GET, require_POST -from django.http import HttpResponse, HttpResponseRedirect +from django.http import HttpResponse from django_htmx.http import HttpResponseClientRefresh from argus.auth.utils import get_preference, save_preference @@ -16,26 +15,10 @@ THEMES_MODULE = "argus_htmx" -class ThemeListView(ListView): - http_method_names = ["get", "post", "head", "options", "trace"] - template_name = "htmx/themes/themes_list.html" - - def setup(self, request, *args, **kwargs): - super().setup(request, *args, **kwargs) - self.themes = THEME_NAMES - - def get_queryset(self): - return self.themes - - def post(self, request, *args, **kwargs): - save_preference(request, request.POST, "argus_htmx", "theme") - return HttpResponseRedirect("") - - @require_GET def theme_names(request: HtmxHttpRequest) -> HttpResponse: themes = THEME_NAMES - return render(request, "htmx/themes/theme_list.html", {"theme_list": themes}) + return render(request, "htmx/themes/_theme_list.html", {"theme_list": themes}) @require_POST