Use different urls for create pages
This commit is contained in:
parent
b673950e99
commit
c744c87baa
4 changed files with 35 additions and 41 deletions
|
@ -54,7 +54,7 @@ class Account(NummiModel):
|
||||||
return str(self.name)
|
return str(self.name)
|
||||||
|
|
||||||
def get_create_url(self):
|
def get_create_url(self):
|
||||||
return reverse("account")
|
return reverse("new_account")
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse("account", kwargs={"pk": self.pk})
|
return reverse("account", kwargs={"pk": self.pk})
|
||||||
|
@ -103,7 +103,7 @@ class Category(NummiModel):
|
||||||
return str(self.name)
|
return str(self.name)
|
||||||
|
|
||||||
def get_create_url(self):
|
def get_create_url(self):
|
||||||
return reverse("category")
|
return reverse("new_category")
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse("category", kwargs={"pk": self.pk})
|
return reverse("category", kwargs={"pk": self.pk})
|
||||||
|
@ -190,7 +190,7 @@ class Snapshot(AccountModel):
|
||||||
super().delete(*args, **kwargs)
|
super().delete(*args, **kwargs)
|
||||||
|
|
||||||
def get_create_url(self):
|
def get_create_url(self):
|
||||||
return reverse("snapshot")
|
return reverse("new_snapshot")
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse("snapshot", kwargs={"pk": self.pk})
|
return reverse("snapshot", kwargs={"pk": self.pk})
|
||||||
|
@ -255,7 +255,7 @@ class Transaction(NummiModel):
|
||||||
return f"{self.name}"
|
return f"{self.name}"
|
||||||
|
|
||||||
def get_create_url(self):
|
def get_create_url(self):
|
||||||
return reverse("transaction")
|
return reverse("new_transaction")
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse("transaction", kwargs={"pk": self.pk})
|
return reverse("transaction", kwargs={"pk": self.pk})
|
||||||
|
@ -307,7 +307,7 @@ class Invoice(NummiModel):
|
||||||
super().delete(*args, **kwargs)
|
super().delete(*args, **kwargs)
|
||||||
|
|
||||||
def get_create_url(self):
|
def get_create_url(self):
|
||||||
return reverse("invoice", kwargs={"transaction_pk": self.transaction.pk})
|
return reverse("new_invoice", kwargs={"transaction_pk": self.transaction.pk})
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse(
|
return reverse(
|
||||||
|
|
|
@ -9,15 +9,9 @@
|
||||||
{% block title %}Nummi{% endblock %}
|
{% block title %}Nummi{% endblock %}
|
||||||
</title>
|
</title>
|
||||||
{% block link %}
|
{% block link %}
|
||||||
<link rel="icon"
|
<link rel="icon" href="{% static "main/svg/logo.svg" %}" type="image/svg+xml" />
|
||||||
href="{% static 'main/svg/logo.svg' %}"
|
<link rel="stylesheet" href="{% static "main/css/main.css" %}" type="text/css" />
|
||||||
type="image/svg+xml" />
|
<link rel="stylesheet" href="{% static "main/remixicon/remixicon.css" %}" type="text/css" />
|
||||||
<link rel="stylesheet"
|
|
||||||
href="{% static 'main/css/main.css' %}"
|
|
||||||
type="text/css" />
|
|
||||||
<link rel="stylesheet"
|
|
||||||
href="{% static 'main/remixicon/remixicon.css' %}"
|
|
||||||
type="text/css" />
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@ -25,7 +19,7 @@
|
||||||
{% spaceless %}
|
{% spaceless %}
|
||||||
<nav>
|
<nav>
|
||||||
<h1>
|
<h1>
|
||||||
<img src="{% static 'main/svg/logo.svg' %}" alt="" />
|
<img src="{% static "main/svg/logo.svg" %}" alt="" />
|
||||||
Nummi
|
Nummi
|
||||||
</h1>
|
</h1>
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -34,49 +28,49 @@
|
||||||
</li>
|
</li>
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
<li>
|
<li>
|
||||||
<a href="{% url 'index' %}"
|
<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 %}"
|
||||||
accesskey="h">{% translate "Home" %}</a>
|
accesskey="h">{% translate "Home" %}</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="{% url 'snapshots' %}"
|
<a href="{% url "snapshots" %}"
|
||||||
class="{% if request.resolver_match.url_name == 'snapshots' %}cur{% endif %}">
|
class="{% if request.resolver_match.url_name == "snapshots" %}cur{% endif %}">
|
||||||
{% translate "Snapshots" %}
|
{% translate "Snapshots" %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="{% url 'transactions' %}"
|
<a href="{% url "transactions" %}"
|
||||||
class="{% if request.resolver_match.url_name == 'transactions' %}cur{% endif %}">
|
class="{% if request.resolver_match.url_name == "transactions" %}cur{% endif %}">
|
||||||
{% translate "Transactions" %}
|
{% translate "Transactions" %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="{% url 'account' %}"
|
<a href="{% url "new_account" %}"
|
||||||
class="{% if request.resolver_match.url_name == 'account' %}cur{% endif %}"
|
class="{% if request.resolver_match.url_name == "new_account" %}cur{% endif %}"
|
||||||
accesskey="a">{% translate "Create account" %}</a>
|
accesskey="a">{% translate "Create account" %}</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="{% url 'snapshot' %}"
|
<a href="{% url "new_snapshot" %}"
|
||||||
class="{% if request.resolver_match.url_name == 'snapshot' %}cur{% endif %}"
|
class="{% if request.resolver_match.url_name == "new_snapshot" %}cur{% endif %}"
|
||||||
accesskey="s">{% translate "Create snapshot" %}</a>
|
accesskey="s">{% translate "Create snapshot" %}</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="{% url 'category' %}"
|
<a href="{% url "new_category" %}"
|
||||||
class="{% if request.resolver_match.url_name == 'category' %}cur{% endif %}"
|
class="{% if request.resolver_match.url_name == "new_category" %}cur{% endif %}"
|
||||||
accesskey="c">{% translate "Create category" %}</a>
|
accesskey="c">{% translate "Create category" %}</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="{% url 'transaction' %}"
|
<a href="{% url "new_transaction" %}"
|
||||||
class="{% if request.resolver_match.url_name == 'transaction' %}cur{% endif %}"
|
class="{% if request.resolver_match.url_name == "new_transaction" %}cur{% endif %}"
|
||||||
accesskey="t">{% translate "Create transaction" %}</a>
|
accesskey="t">{% translate "Create transaction" %}</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="{% url 'search' %}"
|
<a href="{% url "search" %}"
|
||||||
class="{% if request.resolver_match.url_name == 'search' %}cur{% endif %}"
|
class="{% if request.resolver_match.url_name == "search" %}cur{% endif %}"
|
||||||
accesskey="r">{% translate "Search" %}</a>
|
accesskey="r">{% translate "Search" %}</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="{% url 'logout' %}" accesskey="l">{% translate "Log out" %}</a>
|
<a href="{% url "logout" %}" accesskey="l">{% translate "Log out" %}</a>
|
||||||
</li>
|
</li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li>
|
<li>
|
||||||
|
|
|
@ -9,15 +9,15 @@ urlpatterns = [
|
||||||
path("logout", views.LogoutView.as_view(), name="logout"),
|
path("logout", views.LogoutView.as_view(), name="logout"),
|
||||||
path("transactions", views.TransactionListView.as_view(), name="transactions"),
|
path("transactions", views.TransactionListView.as_view(), name="transactions"),
|
||||||
path("snapshots", views.SnapshotListView.as_view(), name="snapshots"),
|
path("snapshots", views.SnapshotListView.as_view(), name="snapshots"),
|
||||||
path("account", views.AccountCreateView.as_view(), name="account"),
|
path("account", views.AccountCreateView.as_view(), name="new_account"),
|
||||||
path("transaction", views.TransactionCreateView.as_view(), name="transaction"),
|
path("transaction", views.TransactionCreateView.as_view(), name="new_transaction"),
|
||||||
path(
|
path(
|
||||||
"transaction/<transaction_pk>/invoice",
|
"transaction/<transaction_pk>/invoice",
|
||||||
views.InvoiceCreateView.as_view(),
|
views.InvoiceCreateView.as_view(),
|
||||||
name="invoice",
|
name="new_invoice",
|
||||||
),
|
),
|
||||||
path("category", views.CategoryCreateView.as_view(), name="category"),
|
path("category", views.CategoryCreateView.as_view(), name="new_category"),
|
||||||
path("snapshot", views.SnapshotCreateView.as_view(), name="snapshot"),
|
path("snapshot", views.SnapshotCreateView.as_view(), name="new_snapshot"),
|
||||||
path("account/<pk>", views.AccountUpdateView.as_view(), name="account"),
|
path("account/<pk>", views.AccountUpdateView.as_view(), name="account"),
|
||||||
path(
|
path(
|
||||||
"account/<pk>/transactions",
|
"account/<pk>/transactions",
|
||||||
|
@ -32,7 +32,7 @@ urlpatterns = [
|
||||||
path(
|
path(
|
||||||
"account/<account>/snapshot",
|
"account/<account>/snapshot",
|
||||||
views.SnapshotCreateView.as_view(),
|
views.SnapshotCreateView.as_view(),
|
||||||
name="snapshot",
|
name="new_snapshot",
|
||||||
),
|
),
|
||||||
path("transaction/<pk>", views.TransactionUpdateView.as_view(), name="transaction"),
|
path("transaction/<pk>", views.TransactionUpdateView.as_view(), name="transaction"),
|
||||||
path(
|
path(
|
||||||
|
@ -55,7 +55,7 @@ urlpatterns = [
|
||||||
path(
|
path(
|
||||||
"snapshot/<snapshot>/transaction",
|
"snapshot/<snapshot>/transaction",
|
||||||
views.TransactionCreateView.as_view(),
|
views.TransactionCreateView.as_view(),
|
||||||
name="transaction",
|
name="new_transaction",
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"account/<pk>/delete",
|
"account/<pk>/delete",
|
||||||
|
|
|
@ -183,7 +183,7 @@ class AccountUpdateView(NummiUpdateView):
|
||||||
return data | {
|
return data | {
|
||||||
"transactions": _transactions[:8],
|
"transactions": _transactions[:8],
|
||||||
"new_snapshot_url": reverse_lazy(
|
"new_snapshot_url": reverse_lazy(
|
||||||
"snapshot", kwargs={"account": account.pk}
|
"new_snapshot", kwargs={"account": account.pk}
|
||||||
),
|
),
|
||||||
"snapshots": _snapshots[:8],
|
"snapshots": _snapshots[:8],
|
||||||
"history": history(account.transaction_set),
|
"history": history(account.transaction_set),
|
||||||
|
@ -267,7 +267,7 @@ class SnapshotUpdateView(NummiUpdateView):
|
||||||
return data | {
|
return data | {
|
||||||
"account": snapshot.account,
|
"account": snapshot.account,
|
||||||
"new_transaction_url": reverse_lazy(
|
"new_transaction_url": reverse_lazy(
|
||||||
"transaction", kwargs={"snapshot": snapshot.pk}
|
"new_transaction", kwargs={"snapshot": snapshot.pk}
|
||||||
),
|
),
|
||||||
"transactions": _transactions,
|
"transactions": _transactions,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue