Implemented frontend for statements
This commit is contained in:
parent
c9d1496e00
commit
a98b073eea
5 changed files with 16 additions and 16 deletions
|
@ -79,10 +79,10 @@ class Statement(AccountModel):
|
||||||
super().delete(*args, **kwargs)
|
super().delete(*args, **kwargs)
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse("statement", kwargs={"pk": self.pk})
|
return reverse("statement", args=(self.pk,))
|
||||||
|
|
||||||
def get_delete_url(self):
|
def get_delete_url(self):
|
||||||
return reverse("del_statement", kwargs={"pk": self.pk})
|
return reverse("del_statement", args=(self.pk,))
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ["-date", "account"]
|
ordering = ["-date", "account"]
|
||||||
|
|
|
@ -4,21 +4,21 @@ from transaction.views import TransactionCreateView
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("statements", views.StatementListView.as_view(), name="statements"),
|
path("list", views.StatementListView.as_view(), name="statements"),
|
||||||
path("statement", views.StatementCreateView.as_view(), name="new_statement"),
|
path("new", views.StatementCreateView.as_view(), name="new_statement"),
|
||||||
path("statement/<pk>", views.StatementUpdateView.as_view(), name="statement"),
|
path("<statement>", views.StatementUpdateView.as_view(), name="statement"),
|
||||||
path(
|
path(
|
||||||
"statement/<pk>/transactions",
|
"<statement>/transaction/list",
|
||||||
views.StatementTListView.as_view(),
|
views.StatementTListView.as_view(),
|
||||||
name="statement_transactions",
|
name="statement_transactions",
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"statement/<statement>/transaction",
|
"<statement>/transaction/new",
|
||||||
TransactionCreateView.as_view(),
|
TransactionCreateView.as_view(),
|
||||||
name="new_transaction",
|
name="new_transaction",
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"statement/<pk>/delete",
|
"<statement>/delete",
|
||||||
views.StatementDeleteView.as_view(),
|
views.StatementDeleteView.as_view(),
|
||||||
name="del_statement",
|
name="del_statement",
|
||||||
),
|
),
|
||||||
|
|
|
@ -12,7 +12,6 @@ from .models import Statement
|
||||||
class StatementCreateView(NummiCreateView):
|
class StatementCreateView(NummiCreateView):
|
||||||
model = Statement
|
model = Statement
|
||||||
form_class = StatementForm
|
form_class = StatementForm
|
||||||
template_name = "main/form/statement.html"
|
|
||||||
|
|
||||||
def get_initial(self):
|
def get_initial(self):
|
||||||
_queryset = Account.objects.filter(user=self.request.user)
|
_queryset = Account.objects.filter(user=self.request.user)
|
||||||
|
@ -36,7 +35,7 @@ class StatementCreateView(NummiCreateView):
|
||||||
class StatementUpdateView(NummiUpdateView):
|
class StatementUpdateView(NummiUpdateView):
|
||||||
model = Statement
|
model = Statement
|
||||||
form_class = StatementForm
|
form_class = StatementForm
|
||||||
template_name = "main/form/statement.html"
|
pk_url_kwarg = "statement"
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
data = super().get_context_data(**kwargs)
|
data = super().get_context_data(**kwargs)
|
||||||
|
@ -74,23 +73,24 @@ class StatementUpdateView(NummiUpdateView):
|
||||||
|
|
||||||
class StatementDeleteView(NummiDeleteView):
|
class StatementDeleteView(NummiDeleteView):
|
||||||
model = Statement
|
model = Statement
|
||||||
|
pk_url_kwarg = "statement"
|
||||||
|
|
||||||
|
|
||||||
class StatementListView(NummiListView):
|
class StatementListView(NummiListView):
|
||||||
model = Statement
|
model = Statement
|
||||||
template_name = "main/list/statement.html"
|
|
||||||
context_object_name = "statements"
|
context_object_name = "statements"
|
||||||
|
|
||||||
|
|
||||||
class StatementMixin:
|
class StatementMixin:
|
||||||
def get_queryset(self):
|
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):
|
def get_context_data(self, **kwargs):
|
||||||
return super().get_context_data(**kwargs) | {
|
return super().get_context_data(**kwargs) | {"statement": self.statement}
|
||||||
"object": Statement.objects.get(pk=self.kwargs.get("pk")),
|
|
||||||
"statement": True,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class StatementTListView(StatementMixin, TransactionListView):
|
class StatementTListView(StatementMixin, TransactionListView):
|
||||||
|
|
Loading…
Reference in a new issue