Use get_absolute_url to get model urls

This commit is contained in:
Edgar P. Burkhart 2023-04-23 08:08:43 +02:00
parent 1bad7d7291
commit a0872b65c4
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
8 changed files with 37 additions and 24 deletions

View file

@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-04-22 15:16+0200\n"
"PO-Revision-Date: 2023-04-22 15:19+0200\n"
"POT-Creation-Date: 2023-04-23 08:02+0200\n"
"PO-Revision-Date: 2023-04-23 08:03+0200\n"
"Last-Translator: Edgar P. Burkhart <traduction@edgarpierre.fr>\n"
"Language-Team: \n"
"Language: fr_FR\n"
@ -33,7 +33,7 @@ msgstr "Accueil"
msgid "Statements"
msgstr "Relevés"
#: .\main\templates\main\base.html:44 .\main\templates\main\index.html:26
#: .\main\templates\main\base.html:44 .\main\templates\main\index.html:24
msgid "Transactions"
msgstr "Transactions"
@ -105,14 +105,22 @@ msgstr "Créer"
msgid "Save"
msgstr "Enregistrer"
#: .\main\templates\main\index.html:16
#: .\main\templates\main\index.html:15
msgid "Accounts"
msgstr "Comptes"
#: .\main\templates\main\index.html:30
#: .\main\templates\main\index.html:20
msgid "No account"
msgstr "Aucun compte"
#: .\main\templates\main\index.html:28
msgid "Categories"
msgstr "Catégories"
#: .\main\templates\main\index.html:34
msgid "No category"
msgstr "Aucune catégorie"
#: .\main\templates\main\index.html:44
msgid "History"
msgstr "Historique"

View file

@ -12,16 +12,14 @@
type="text/css" />
{% endblock %}
{% block body %}
{% if accounts %}
<h2>{% translate "Accounts" %}</h2>
{% spaceless %}
<p>
{% for acc in accounts %}
<a class="big-link" href="{% url 'account' acc.id %}">{{ acc.icon|remix }}{{ acc }}</a>
<a class="big-link" href="{{ acc.get_absolute_url }}">{{ acc.icon|remix }}{{ acc }}</a>
{% empty %}
{% translate "No account" %}
{% endfor %}
</p>
{% endspaceless %}
{% endif %}
{% if transactions %}
<h2>{% translate "Transactions" %}</h2>
{% include "transaction/transaction_table.html" %}
@ -31,7 +29,9 @@
{% spaceless %}
<p>
{% for cat in categories %}
<a class="big-link" href="{% url 'category' cat.id %}">{{ cat.icon|remix }}{{ cat }}</a>
<a class="big-link" href="{{ cat.get_absolute_url }}">{{ cat.icon|remix }}{{ cat }}</a>
{% empty %}
{% translate "No category" %}
{% endfor %}
</p>
{% endspaceless %}

View file

@ -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="{{ snap.get_absolute_url }}">{{ 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="{{ snap.account.get_absolute_url }}">{{ snap.account }}</a>
</td>
{% endif %}
<td class="value">{{ snap.value|value }}</td>

View file

@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-04-22 15:16+0200\n"
"PO-Revision-Date: 2023-04-22 15:23+0200\n"
"POT-Creation-Date: 2023-04-23 08:02+0200\n"
"PO-Revision-Date: 2023-04-23 08:03+0200\n"
"Last-Translator: Edgar P. Burkhart <traduction@edgarpierre.fr>\n"
"Language-Team: \n"
"Language: fr_FR\n"
@ -69,6 +69,7 @@ msgid "Account"
msgstr "Compte"
#: .\transaction\models.py:83
#: .\transaction\templates\transaction\transaction_archive_month.html:12
#: .\transaction\templates\transaction\transaction_list.html:4
#: .\transaction\templates\transaction\transaction_list.html:7
msgid "Transactions"
@ -107,6 +108,10 @@ msgstr "Supprimer"
msgid "No invoice"
msgstr "Aucune facture"
#: .\transaction\templates\transaction\transaction_archive_month.html:15
msgid "Categories"
msgstr "Catégories"
#: .\transaction\templates\transaction\transaction_form.html:5
#: .\transaction\templates\transaction\transaction_table.html:5
msgid "Create transaction"

View file

@ -64,7 +64,7 @@ class Transaction(UserModel):
return f"{self.name}"
def get_absolute_url(self):
return reverse("transaction", kwargs={"pk": self.pk})
return reverse("transaction", args=(self.pk,))
def get_delete_url(self):
return reverse("del_transaction", args=(self.pk,))

View file

@ -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="{{ trans.get_absolute_url }}">{{ 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="{{ trans.category.get_absolute_url }}">{{ 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="{{ trans.account.get_absolute_url }}">{{ trans.account }}</a>
</td>
{% endif %}
</tr>