Compare commits
2 commits
e4f70c67e3
...
7a365212f5
Author | SHA1 | Date | |
---|---|---|---|
7a365212f5 | |||
fdcdff7bcc |
5 changed files with 54 additions and 4 deletions
3
nummi/main/static/main/css/page.css
Normal file
3
nummi/main/static/main/css/page.css
Normal file
|
@ -0,0 +1,3 @@
|
|||
.pagination .current {
|
||||
font-feature-settings: "tnum", "ss01";
|
||||
}
|
|
@ -18,19 +18,23 @@
|
|||
{% spaceless %}
|
||||
<nav>
|
||||
<a href="{% url 'index' %}"
|
||||
class="home{% if request.resolver_match.url_name == "index" %} cur{% endif %}">
|
||||
class="home{% if request.resolver_match.url_name == 'index' %}cur{% endif %}">
|
||||
Nummi
|
||||
</a>
|
||||
<a href="{% url 'transactions' %}"
|
||||
class="{% if request.resolver_match.url_name == 'transactions' %}cur{% endif %}">
|
||||
Transactions
|
||||
</a>
|
||||
<a href="{% url 'transaction' %}"
|
||||
class="{% if request.resolver_match.url_name == "transaction" %} cur{% endif %}">
|
||||
class="{% if request.resolver_match.url_name == 'transaction' %}cur{% endif %}">
|
||||
Add transaction
|
||||
</a>
|
||||
<a href="{% url 'category' %}"
|
||||
class="{% if request.resolver_match.url_name == "category" %} cur{% endif %}">
|
||||
class="{% if request.resolver_match.url_name == 'category' %}cur{% endif %}">
|
||||
Add category
|
||||
</a>
|
||||
<a href="{% url 'snapshot' %}"
|
||||
class="{% if request.resolver_match.url_name == "snapshot" %} cur{% endif %}">
|
||||
class="{% if request.resolver_match.url_name == 'snapshot' %}cur{% endif %}">
|
||||
Add snapshot
|
||||
</a>
|
||||
<a href="{% url 'logout' %}"
|
||||
|
|
32
nummi/main/templates/main/transactions.html
Normal file
32
nummi/main/templates/main/transactions.html
Normal file
|
@ -0,0 +1,32 @@
|
|||
{% extends "main/base.html" %}
|
||||
{% load static %}
|
||||
{% load main_extras %}
|
||||
|
||||
{% block link %}
|
||||
{{ block.super }}
|
||||
<link rel="stylesheet" href="{% static 'main/css/table.css' %}" type="text/css" />
|
||||
<link rel="stylesheet" href="{% static 'main/css/page.css' %}" type="text/css" />
|
||||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Transactions</h1>
|
||||
{% transaction_table transactions %}
|
||||
|
||||
<div class="pagination">
|
||||
<span class="step-links">
|
||||
{% if page_obj.has_previous %}
|
||||
<a href="?page=1">↞</a>
|
||||
<a href="?page={{ page_obj.previous_page_number }}">←</a>
|
||||
{% endif %}
|
||||
|
||||
<span class="current">
|
||||
{{ page_obj.number }}/{{ page_obj.paginator.num_pages }}
|
||||
</span>
|
||||
|
||||
{% if page_obj.has_next %}
|
||||
<a href="?page={{ page_obj.next_page_number }}">→</a>
|
||||
<a href="?page={{ page_obj.paginator.num_pages }}">↠</a>
|
||||
{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -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/<uuid>", views.transaction, name="transaction"),
|
||||
path(
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue