Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup theme template naming #231

Merged
merged 3 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading