Skip to content

Commit

Permalink
Cleanup theme template naming
Browse files Browse the repository at this point in the history
* Mark theme_dropdown.html as partial
* Mark theme_list.html as partial
* Remove unused view
  • Loading branch information
hmpf authored Nov 13, 2024
1 parent d1ddb2a commit 0150380
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 43 deletions.
2 changes: 1 addition & 1 deletion src/argus_htmx/templates/htmx/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
Logged in as: <span class="text-info">{{ request.user }}</span>
<div class="divider divider-secondary my-0"></div>
</li>
<li>{% include "htmx/themes/theme_dropdown.html" %}</li>
<li>{% include "htmx/themes/_theme_dropdown.html" %}</li>
<li>{% include "htmx/dateformat/_dateformat_dropdown.html" %}</li>
<li>
<a href="{% url 'htmx:user-preferences' %}">Preferences…</a>
Expand Down
22 changes: 0 additions & 22 deletions src/argus_htmx/templates/htmx/themes/themes_list.html

This file was deleted.

1 change: 0 additions & 1 deletion src/argus_htmx/themes/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
]
21 changes: 2 additions & 19 deletions src/argus_htmx/themes/views.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down

0 comments on commit 0150380

Please sign in to comment.