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