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

View file

@ -12,16 +12,14 @@
type="text/css" /> type="text/css" />
{% endblock %} {% endblock %}
{% block body %} {% block body %}
{% if accounts %}
<h2>{% translate "Accounts" %}</h2> <h2>{% translate "Accounts" %}</h2>
{% spaceless %}
<p> <p>
{% for acc in accounts %} {% 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 %} {% endfor %}
</p> </p>
{% endspaceless %}
{% endif %}
{% if transactions %} {% if transactions %}
<h2>{% translate "Transactions" %}</h2> <h2>{% translate "Transactions" %}</h2>
{% include "transaction/transaction_table.html" %} {% include "transaction/transaction_table.html" %}
@ -31,7 +29,9 @@
{% spaceless %} {% spaceless %}
<p> <p>
{% for cat in categories %} {% 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 %} {% endfor %}
</p> </p>
{% endspaceless %} {% endspaceless %}

View file

@ -39,12 +39,12 @@
{% if snap.file %}<a href="{{ snap.file.url }}">{{ "attachment"|remix }}</a>{% endif %} {% if snap.file %}<a href="{{ snap.file.url }}">{{ "attachment"|remix }}</a>{% endif %}
</td> </td>
<th class="date" scope="row"> <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> </th>
{% if not account %} {% if not account %}
<td class="r">{{ snap.account.icon|remix }}</td> <td class="r">{{ snap.account.icon|remix }}</td>
<td> <td>
<a href="{% url "account" snap.account.id %}">{{ snap.account }}</a> <a href="{{ snap.account.get_absolute_url }}">{{ snap.account }}</a>
</td> </td>
{% endif %} {% endif %}
<td class="value">{{ snap.value|value }}</td> <td class="value">{{ snap.value|value }}</td>

View file

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

View file

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

View file

@ -43,7 +43,7 @@
</td> </td>
<td class="date">{{ trans.date|date:"Y-m-d" }}</td> <td class="date">{{ trans.date|date:"Y-m-d" }}</td>
<th scope="row" class="l"> <th scope="row" class="l">
<a href="{% url "transaction" trans.id %}">{{ trans.name }}</a> <a href="{{ trans.get_absolute_url }}">{{ trans.name }}</a>
</th> </th>
<td class="value">{{ trans.value|pmvalue }}</td> <td class="value">{{ trans.value|pmvalue }}</td>
<td>{{ trans.trader|default_if_none:"" }}</td> <td>{{ trans.trader|default_if_none:"" }}</td>
@ -51,7 +51,7 @@
{% if trans.category %} {% if trans.category %}
<td class="r">{{ trans.category.icon|remix }}</td> <td class="r">{{ trans.category.icon|remix }}</td>
<td> <td>
<a href="{% url "category" trans.category.id %}">{{ trans.category }}</a> <a href="{{ trans.category.get_absolute_url }}">{{ trans.category }}</a>
</td> </td>
{% else %} {% else %}
<td colspan="2"></td> <td colspan="2"></td>
@ -60,7 +60,7 @@
{% if not account %} {% if not account %}
<td class="r">{{ trans.account.icon|remix }}</td> <td class="r">{{ trans.account.icon|remix }}</td>
<td> <td>
<a href="{% url "account" trans.account.id %}">{{ trans.account }}</a> <a href="{{ trans.account.get_absolute_url }}">{{ trans.account }}</a>
</td> </td>
{% endif %} {% endif %}
</tr> </tr>