changes, fixes and improvements

This commit is contained in:
Herculino Trotta
2024-10-16 00:16:48 -03:00
parent d0f4dcc957
commit 07cbfefb95
40 changed files with 1008 additions and 330 deletions

View File

@@ -3,7 +3,8 @@ from django.urls import path
from . import views
urlpatterns = [
path("currencies/", views.currency_list, name="currencies_list"),
path("currencies/", views.currencies_index, name="currencies_index"),
path("currencies/list/", views.currencies_list, name="currencies_list"),
path("currencies/add/", views.currency_add, name="currency_add"),
path(
"currencies/<int:pk>/edit/",

View File

@@ -14,9 +14,23 @@ from apps.currencies.models import Currency
@login_required
@require_http_methods(["GET"])
def currency_list(request):
def currencies_index(request):
return render(
request,
"currencies/pages/index.html",
)
@only_htmx
@login_required
@require_http_methods(["GET"])
def currencies_list(request):
currencies = Currency.objects.all().order_by("id")
return render(request, "currencies/pages/list.html", {"currencies": currencies})
return render(
request,
"currencies/fragments/list.html",
{"currencies": currencies},
)
@only_htmx
@@ -32,8 +46,7 @@ def currency_add(request, **kwargs):
return HttpResponse(
status=204,
headers={
"HX-Location": reverse("currencies_list"),
"HX-Trigger": "hide_offcanvas, toasts",
"HX-Trigger": "updated, hide_offcanvas, toasts",
},
)
else:
@@ -61,8 +74,7 @@ def currency_edit(request, pk):
return HttpResponse(
status=204,
headers={
"HX-Location": reverse("currencies_list"),
"HX-Trigger": "hide_offcanvas, toasts",
"HX-Trigger": "updated, hide_offcanvas, toasts",
},
)
else:
@@ -88,5 +100,7 @@ def currency_delete(request, pk):
return HttpResponse(
status=204,
headers={"HX-Location": reverse("currencies_list")},
headers={
"HX-Trigger": "updated, hide_offcanvas, toasts",
},
)