diff --git a/nummi/main/templates/main/base.html b/nummi/main/templates/main/base.html index cfc0531..66732a7 100644 --- a/nummi/main/templates/main/base.html +++ b/nummi/main/templates/main/base.html @@ -18,19 +18,23 @@ {% spaceless %} + class="home{% if request.resolver_match.url_name == 'index' %}cur{% endif %}"> Nummi + + Transactions + + class="{% if request.resolver_match.url_name == 'transaction' %}cur{% endif %}"> Add transaction + class="{% if request.resolver_match.url_name == 'category' %}cur{% endif %}"> Add category + class="{% if request.resolver_match.url_name == 'snapshot' %}cur{% endif %}"> Add snapshot +{% endblock %} + +{% block body %} +Transactions +{% transaction_table transactions %} + + + + {% if page_obj.has_previous %} + ↞ + ← + {% endif %} + + + {{ page_obj.number }}/{{ page_obj.paginator.num_pages }} + + + {% if page_obj.has_next %} + → + ↠ + {% endif %} + + +{% endblock %} diff --git a/nummi/main/urls.py b/nummi/main/urls.py index 44141fd..6ea01f7 100644 --- a/nummi/main/urls.py +++ b/nummi/main/urls.py @@ -6,6 +6,7 @@ urlpatterns = [ path("", views.index, name="index"), path("login", views.LoginView.as_view(), name="login"), path("logout", views.LogoutView.as_view(), name="logout"), + path("transactions", views.TransactionListView.as_view(), name="transactions"), path("transaction", views.transaction, name="transaction"), path("transaction/", views.transaction, name="transaction"), path( diff --git a/nummi/main/views.py b/nummi/main/views.py index 8890288..adcd5b9 100644 --- a/nummi/main/views.py +++ b/nummi/main/views.py @@ -2,6 +2,9 @@ from django.shortcuts import render, get_object_or_404, redirect from django.http import HttpResponse from django.contrib.auth.decorators import login_required from django.contrib.auth import views as auth_views +from django.contrib.auth.mixins import LoginRequiredMixin +from django.views.generic import ListView +from django.core.paginator import Paginator from .models import ( Transaction, @@ -38,6 +41,13 @@ class LogoutView(auth_views.LogoutView): next_page = "login" +class TransactionListView(LoginRequiredMixin, ListView): + paginate_by = 20 + model = Transaction + template_name = "main/transactions.html" + context_object_name = "transactions" + + @login_required def transaction(request, uuid=None): if uuid is None: