Implemented frontend for statements

This commit is contained in:
Edgar P. Burkhart 2023-04-22 12:30:08 +02:00
parent c9d1496e00
commit a98b073eea
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
5 changed files with 16 additions and 16 deletions

View file

@ -79,10 +79,10 @@ class Statement(AccountModel):
super().delete(*args, **kwargs)
def get_absolute_url(self):
return reverse("statement", kwargs={"pk": self.pk})
return reverse("statement", args=(self.pk,))
def get_delete_url(self):
return reverse("del_statement", kwargs={"pk": self.pk})
return reverse("del_statement", args=(self.pk,))
class Meta:
ordering = ["-date", "account"]

View file

@ -4,21 +4,21 @@ from transaction.views import TransactionCreateView
from . import views
urlpatterns = [
path("statements", views.StatementListView.as_view(), name="statements"),
path("statement", views.StatementCreateView.as_view(), name="new_statement"),
path("statement/<pk>", views.StatementUpdateView.as_view(), name="statement"),
path("list", views.StatementListView.as_view(), name="statements"),
path("new", views.StatementCreateView.as_view(), name="new_statement"),
path("<statement>", views.StatementUpdateView.as_view(), name="statement"),
path(
"statement/<pk>/transactions",
"<statement>/transaction/list",
views.StatementTListView.as_view(),
name="statement_transactions",
),
path(
"statement/<statement>/transaction",
"<statement>/transaction/new",
TransactionCreateView.as_view(),
name="new_transaction",
),
path(
"statement/<pk>/delete",
"<statement>/delete",
views.StatementDeleteView.as_view(),
name="del_statement",
),

View file

@ -12,7 +12,6 @@ from .models import Statement
class StatementCreateView(NummiCreateView):
model = Statement
form_class = StatementForm
template_name = "main/form/statement.html"
def get_initial(self):
_queryset = Account.objects.filter(user=self.request.user)
@ -36,7 +35,7 @@ class StatementCreateView(NummiCreateView):
class StatementUpdateView(NummiUpdateView):
model = Statement
form_class = StatementForm
template_name = "main/form/statement.html"
pk_url_kwarg = "statement"
def get_context_data(self, **kwargs):
data = super().get_context_data(**kwargs)
@ -74,23 +73,24 @@ class StatementUpdateView(NummiUpdateView):
class StatementDeleteView(NummiDeleteView):
model = Statement
pk_url_kwarg = "statement"
class StatementListView(NummiListView):
model = Statement
template_name = "main/list/statement.html"
context_object_name = "statements"
class StatementMixin:
def get_queryset(self):
return super().get_queryset().filter(statement=self.kwargs.get("pk"))
self.statement = get_object_or_404(
Statement.objects.filter(user=self.request.user),
pk=self.kwargs.get("statement"),
)
return super().get_queryset().filter(statement=self.statement)
def get_context_data(self, **kwargs):
return super().get_context_data(**kwargs) | {
"object": Statement.objects.get(pk=self.kwargs.get("pk")),
"statement": True,
}
return super().get_context_data(**kwargs) | {"statement": self.statement}
class StatementTListView(StatementMixin, TransactionListView):