Compare commits
No commits in common. "2736c2ae9dc224d8972c41c639b686201c75ab32" and "b05c3e67607b0b66ae3451710f01ed53fc8f6a3f" have entirely different histories.
2736c2ae9d
...
b05c3e6760
21 changed files with 59 additions and 161 deletions
|
@ -1,16 +0,0 @@
|
|||
# Generated by Django 4.1.4 on 2023-04-22 09:28
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("account", "0001_initial"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelTable(
|
||||
name="account",
|
||||
table=None,
|
||||
),
|
||||
]
|
|
@ -27,10 +27,10 @@ class Account(UserModel):
|
|||
return str(self.name)
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse("account", args=(self.pk,))
|
||||
return reverse("account", kwargs={"pk": self.pk})
|
||||
|
||||
def get_delete_url(self):
|
||||
return reverse("del_account", args=(self.pk,))
|
||||
return reverse("del_account", kwargs={"pk": self.pk})
|
||||
|
||||
class Meta:
|
||||
ordering = ["-default", "name"]
|
||||
|
|
|
@ -1,35 +1,33 @@
|
|||
from django.urls import path
|
||||
from statement.views import StatementCreateView
|
||||
from transaction.views import TransactionMonthView
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path("", views.AccountCreateView.as_view(), name="new_account"),
|
||||
path("<account>", views.AccountUpdateView.as_view(), name="account"),
|
||||
path("account", views.AccountCreateView.as_view(), name="new_account"),
|
||||
path("account/<pk>", views.AccountUpdateView.as_view(), name="account"),
|
||||
path(
|
||||
"<account>/transactions",
|
||||
"account/<pk>/transactions",
|
||||
views.AccountTListView.as_view(),
|
||||
name="account_transactions",
|
||||
),
|
||||
path(
|
||||
"<account>/statements",
|
||||
"account/<pk>/statements",
|
||||
views.AccountSListView.as_view(),
|
||||
name="account_statements",
|
||||
),
|
||||
path(
|
||||
"<account>/statement",
|
||||
StatementCreateView.as_view(),
|
||||
"account/<account>/statement",
|
||||
views.StatementCreateView.as_view(),
|
||||
name="new_statement",
|
||||
),
|
||||
path(
|
||||
"<account>/delete",
|
||||
"account/<pk>/delete",
|
||||
views.AccountDeleteView.as_view(),
|
||||
name="del_account",
|
||||
),
|
||||
path(
|
||||
"<account>/history/<int:year>/<int:month>",
|
||||
TransactionMonthView.as_view(),
|
||||
"account/<account>/history/<int:year>/<int:month>",
|
||||
views.TransactionMonthView.as_view(),
|
||||
name="transaction_month",
|
||||
),
|
||||
]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from django.urls import reverse_lazy
|
||||
from main.views import NummiCreateView, NummiDeleteView, NummiUpdateView
|
||||
from statement.views import StatementListView
|
||||
from snapshot.views import SnapshotListView
|
||||
from transaction.utils import history
|
||||
from transaction.views import TransactionListView
|
||||
|
||||
|
@ -11,12 +11,13 @@ from .models import Account
|
|||
class AccountCreateView(NummiCreateView):
|
||||
model = Account
|
||||
form_class = AccountForm
|
||||
template_name = "main/form/account.html"
|
||||
|
||||
|
||||
class AccountUpdateView(NummiUpdateView):
|
||||
model = Account
|
||||
form_class = AccountForm
|
||||
pk_url_kwarg = "account"
|
||||
template_name = "main/form/account.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
_max = 8
|
||||
|
@ -28,34 +29,34 @@ class AccountUpdateView(NummiUpdateView):
|
|||
data["transactions_url"] = reverse_lazy(
|
||||
"account_transactions", args=(account.pk,)
|
||||
)
|
||||
_statements = account.statement_set.all()
|
||||
if _statements.count() > _max:
|
||||
data["statements_url"] = reverse_lazy(
|
||||
"account_statements", args=(account.pk,)
|
||||
_snapshots = account.snapshot_set.all()
|
||||
if _snapshots.count() > _max:
|
||||
data["snapshots_url"] = reverse_lazy(
|
||||
"account_snapshots", args=(account.pk,)
|
||||
)
|
||||
|
||||
return data | {
|
||||
"transactions": _transactions[:8],
|
||||
"new_statement_url": reverse_lazy(
|
||||
"new_statement", kwargs={"account": account.pk}
|
||||
"new_snapshot_url": reverse_lazy(
|
||||
"new_snapshot", kwargs={"account": account.pk}
|
||||
),
|
||||
"statements": _statements[:8],
|
||||
"snapshots": _snapshots[:8],
|
||||
"history": history(account.transaction_set),
|
||||
}
|
||||
|
||||
|
||||
class AccountDeleteView(NummiDeleteView):
|
||||
model = Account
|
||||
pk_url_kwarg = "account"
|
||||
|
||||
|
||||
class AccountMixin:
|
||||
def get_queryset(self):
|
||||
return super().get_queryset().filter(account=self.kwargs.get("account"))
|
||||
return super().get_queryset().filter(account=self.kwargs.get("pk"))
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
return super().get_context_data(**kwargs) | {
|
||||
"account": Account.objects.get(pk=self.kwargs.get("account")),
|
||||
"object": Account.objects.get(pk=self.kwargs.get("pk")),
|
||||
"account": True,
|
||||
}
|
||||
|
||||
|
||||
|
@ -63,5 +64,5 @@ class AccountTListView(AccountMixin, TransactionListView):
|
|||
pass
|
||||
|
||||
|
||||
class AccountSListView(AccountMixin, StatementListView):
|
||||
class AccountSListView(AccountMixin, SnapshotListView):
|
||||
pass
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
# Generated by Django 4.1.4 on 2023-04-22 09:28
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("category", "0001_initial"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelTable(
|
||||
name="category",
|
||||
table=None,
|
||||
),
|
||||
]
|
|
@ -1,5 +1,4 @@
|
|||
from django.urls import path
|
||||
from transaction.views import TransactionMonthView
|
||||
|
||||
from . import views
|
||||
|
||||
|
@ -16,7 +15,7 @@ urlpatterns = [
|
|||
),
|
||||
path(
|
||||
"category/<category>/history/<int:year>/<int:month>",
|
||||
TransactionMonthView.as_view(),
|
||||
views.TransactionMonthView.as_view(),
|
||||
name="transaction_month",
|
||||
),
|
||||
]
|
||||
|
|
|
@ -25,7 +25,6 @@ class Migration(migrations.Migration):
|
|||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField("Transaction", "snapshot", "statement"),
|
||||
migrations.SeparateDatabaseAndState(
|
||||
database_operations=database_operations,
|
||||
state_operations=state_operations,
|
||||
|
|
|
@ -33,9 +33,9 @@
|
|||
accesskey="h">{% translate "Home" %}</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{% url "statements" %}"
|
||||
class="{% if request.resolver_match.url_name == "statements" %}cur{% endif %}">
|
||||
{% translate "Statements" %}
|
||||
<a href="{% url "snapshots" %}"
|
||||
class="{% if request.resolver_match.url_name == "snapshots" %}cur{% endif %}">
|
||||
{% translate "Snapshots" %}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
|
@ -50,9 +50,9 @@
|
|||
accesskey="a">{% translate "Create account" %}</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{% url "new_statement" %}"
|
||||
class="{% if request.resolver_match.url_name == "new_statement" %}cur{% endif %}"
|
||||
accesskey="s">{% translate "Create statement" %}</a>
|
||||
<a href="{% url "new_snapshot" %}"
|
||||
class="{% if request.resolver_match.url_name == "new_snapshot" %}cur{% endif %}"
|
||||
accesskey="s">{% translate "Create snapshot" %}</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{% url "new_category" %}"
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
{% block tables %}
|
||||
{% if not form.instance|adding %}
|
||||
<h3>{% translate "Statements" %}</h3>
|
||||
{% include "main/table/statement.html" %}
|
||||
{% include "main/table/snapshot.html" %}
|
||||
{% endif %}
|
||||
{% if transactions %}
|
||||
<h3>{% translate "Transactions" %}</h3>
|
|
@ -36,9 +36,9 @@
|
|||
</p>
|
||||
{% endspaceless %}
|
||||
{% endif %}
|
||||
{% if statements %}
|
||||
<h2>{% translate "Statements" %}</h2>
|
||||
{% include "main/table/statement.html" %}
|
||||
{% if snapshots %}
|
||||
<h2>{% translate "Snapshots" %}</h2>
|
||||
{% include "main/table/snapshot.html" %}
|
||||
{% endif %}
|
||||
{% if history.data %}
|
||||
<h2>{% translate "History" %}</h2>
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
{% load i18n %}
|
||||
{% block title %}
|
||||
{% translate "Statements" %}
|
||||
{% if account %}– {{ account }}{% endif %}
|
||||
{% if category %}– {{ category }}{% endif %}
|
||||
{% if object %}– {{ object }}{% endif %}
|
||||
– Nummi
|
||||
{% endblock %}
|
||||
{% block link %}
|
||||
|
@ -19,21 +18,12 @@
|
|||
{% endblock %}
|
||||
{% block body %}
|
||||
<h2>{% translate "Statements" %}</h2>
|
||||
{% if account %}
|
||||
<p>
|
||||
<a href="{{ account.get_absolute_url }}">{{ account.icon|remix }}{{ account }}</a>
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if category %}
|
||||
<p>
|
||||
<a href="{{ category.get_absolute_url }}">{{ category.icon|remix }}{{ category }}</a>
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if statements %}
|
||||
{% if object %}<a href="{{ object.get_absolute_url }}">{{ object }}</a>{% endif %}
|
||||
{% if snapshots %}
|
||||
{% include "main/list/pagination.html" %}
|
||||
{% include "main/table/statement.html" %}
|
||||
{% include "main/table/snapshot.html" %}
|
||||
{% include "main/list/pagination.html" %}
|
||||
{% else %}
|
||||
<p>{% translate "No statements to show" %}</p>
|
||||
<p>{% translate "No snapshots to show" %}</p>
|
||||
{% endif %}
|
||||
{% endblock %}
|
|
@ -4,8 +4,7 @@
|
|||
{% load i18n %}
|
||||
{% block title %}
|
||||
{% translate "Transactions" %}
|
||||
{% if account %}– {{ account }}{% endif %}
|
||||
{% if category %}– {{ category }}{% endif %}
|
||||
{% if object %}– {{ object }}{% endif %}
|
||||
{% if search %}
|
||||
– {% translate "Search" %}
|
||||
{% endif %}
|
||||
|
@ -22,16 +21,7 @@
|
|||
{% endblock %}
|
||||
{% block body %}
|
||||
<h2>{% translate "Transactions" %}</h2>
|
||||
{% if account %}
|
||||
<p>
|
||||
<a href="{{ account.get_absolute_url }}">{{ account.icon|remix }}{{ account }}</a>
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if category %}
|
||||
<p>
|
||||
<a href="{{ category.get_absolute_url }}">{{ category.icon|remix }}{{ category }}</a>
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if object %}<a href="{{ object.get_absolute_url }}">{{ object }}</a>{% endif %}
|
||||
{% if search %}
|
||||
<a href="{% url "search" %}">{% translate "Search" %}</a>
|
||||
{% endif %}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{% load main_extras %}
|
||||
{% load i18n %}
|
||||
{% if new_statement_url %}
|
||||
{% if new_snapshot_url %}
|
||||
<p>
|
||||
<a href="{{ new_statement_url }}">{% translate "Create statement" %}</a>
|
||||
<a href="{{ new_snapshot_url }}">{% translate "Create statement" %}</a>
|
||||
</p>
|
||||
{% endif %}
|
||||
<div id="statements" class="table">
|
||||
<table class="full-width {% if statements_url %}more{% endif %}">
|
||||
<div id="snapshots" class="table">
|
||||
<table class="full-width {% if snapshots_url %}more{% endif %}">
|
||||
<colgroup>
|
||||
<col class="icon" span="2">
|
||||
<col class="date">
|
||||
|
@ -28,7 +28,7 @@
|
|||
<th>{% translate "Transactions" %}</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for snap in statements %}
|
||||
{% for snap in snapshots %}
|
||||
<tr>
|
||||
{% if snap.sum == snap.diff %}
|
||||
<td class="c green">{{ "check"|remix }}</td>
|
||||
|
@ -39,12 +39,12 @@
|
|||
{% if snap.file %}<a href="{{ snap.file.url }}">{{ "attachment"|remix }}</a>{% endif %}
|
||||
</td>
|
||||
<th class="date" scope="row">
|
||||
<a href="{% url "statement" snap.id %}">{{ snap.date|date:"Y-m-d" }}</a>
|
||||
<a href="{% url "snapshot" pk=snap.id %}">{{ snap.date|date:"Y-m-d" }}</a>
|
||||
</th>
|
||||
{% if not account %}
|
||||
<td class="r">{{ snap.account.icon|remix }}</td>
|
||||
<td>
|
||||
<a href="{% url "account" snap.account.id %}">{{ snap.account }}</a>
|
||||
<a href="{% url "account" pk=snap.account.id %}">{{ snap.account }}</a>
|
||||
</td>
|
||||
{% endif %}
|
||||
<td class="value">{{ snap.value|value }}</td>
|
||||
|
@ -55,8 +55,8 @@
|
|||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% if statements_url %}
|
||||
{% if snapshots_url %}
|
||||
<p>
|
||||
<a href="{{ statements_url }}">{% translate "View all statements" %}</a>
|
||||
<a href="{{ snapshots_url }}">{% translate "View all statements" %}</a>
|
||||
</p>
|
||||
{% endif %}
|
|
@ -43,7 +43,7 @@
|
|||
</td>
|
||||
<td class="date">{{ trans.date|date:"Y-m-d" }}</td>
|
||||
<th scope="row" class="l">
|
||||
<a href="{% url "transaction" trans.id %}">{{ trans.name }}</a>
|
||||
<a href="{% url "transaction" pk=trans.id %}">{{ trans.name }}</a>
|
||||
</th>
|
||||
<td class="value">{{ trans.value|pmvalue }}</td>
|
||||
<td>{{ trans.trader|default_if_none:"" }}</td>
|
||||
|
@ -51,7 +51,7 @@
|
|||
{% if trans.category %}
|
||||
<td class="r">{{ trans.category.icon|remix }}</td>
|
||||
<td>
|
||||
<a href="{% url "category" trans.category.id %}">{{ trans.category }}</a>
|
||||
<a href="{% url "category" pk=trans.category.id %}">{{ trans.category }}</a>
|
||||
</td>
|
||||
{% else %}
|
||||
<td colspan="2"></td>
|
||||
|
@ -60,7 +60,7 @@
|
|||
{% if not account %}
|
||||
<td class="r">{{ trans.account.icon|remix }}</td>
|
||||
<td>
|
||||
<a href="{% url "account" trans.account.id %}">{{ trans.account }}</a>
|
||||
<a href="{% url "account" pk=trans.account.id %}">{{ trans.account }}</a>
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from django.urls import include, path
|
||||
from django.urls import path
|
||||
|
||||
from . import views
|
||||
|
||||
|
@ -6,9 +6,4 @@ urlpatterns = [
|
|||
path("", views.IndexView.as_view(), name="index"),
|
||||
path("login", views.LoginView.as_view(), name="login"),
|
||||
path("logout", views.LogoutView.as_view(), name="logout"),
|
||||
path("account/", include("account.urls")),
|
||||
path("category/", include("category.urls")),
|
||||
path("statement/", include("statement.urls")),
|
||||
path("transaction/", include("transaction.urls")),
|
||||
path("search/", include("search.urls")),
|
||||
]
|
||||
|
|
|
@ -66,11 +66,6 @@ class NummiDeleteView(UserMixin, DeleteView):
|
|||
template_name = "main/confirm_delete.html"
|
||||
success_url = reverse_lazy("index")
|
||||
|
||||
def get_form_kwargs(self):
|
||||
_res = super().get_form_kwargs()
|
||||
_res.pop("user")
|
||||
return _res
|
||||
|
||||
|
||||
class LoginView(auth_views.LoginView):
|
||||
template_name = "main/login.html"
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
# Generated by Django 4.1.4 on 2023-04-22 09:28
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("statement", "0001_initial"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelTable(
|
||||
name="statement",
|
||||
table=None,
|
||||
),
|
||||
]
|
|
@ -1,10 +1,9 @@
|
|||
from django.urls import path
|
||||
from transaction.views import TransactionCreateView
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path("statements", views.StatementListView.as_view(), name="statements"),
|
||||
path("statements", views.SnapshotListView.as_view(), name="statements"),
|
||||
path("statement", views.StatementCreateView.as_view(), name="new_statement"),
|
||||
path("statement/<pk>", views.StatementUpdateView.as_view(), name="statement"),
|
||||
path(
|
||||
|
@ -14,7 +13,7 @@ urlpatterns = [
|
|||
),
|
||||
path(
|
||||
"statement/<statement>/transaction",
|
||||
TransactionCreateView.as_view(),
|
||||
views.TransactionCreateView.as_view(),
|
||||
name="new_transaction",
|
||||
),
|
||||
path(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from category.models import Category
|
||||
from main.forms import NummiFileInput, NummiForm
|
||||
from statement.models import Statement
|
||||
from Statement.models import Statement
|
||||
|
||||
from .models import Invoice, Transaction
|
||||
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
# Generated by Django 4.1.4 on 2023-04-22 09:28
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("transaction", "0001_initial"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelTable(
|
||||
name="invoice",
|
||||
table=None,
|
||||
),
|
||||
migrations.AlterModelTable(
|
||||
name="transaction",
|
||||
table=None,
|
||||
),
|
||||
]
|
Loading…
Reference in a new issue