Added delete view for transaction

This commit is contained in:
Edgar P. Burkhart 2022-12-28 10:17:30 +01:00
parent a48e34281f
commit d8c95fac25
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
7 changed files with 80 additions and 43 deletions

View file

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 0.0.1\n" "Project-Id-Version: 0.0.1\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-12-26 18:10+0100\n" "POT-Creation-Date: 2022-12-28 10:16+0100\n"
"PO-Revision-Date: 2022-12-21 17:30+0100\n" "PO-Revision-Date: 2022-12-21 17:30+0100\n"
"Last-Translator: edpibu <git@edgarpierre.fr>\n" "Last-Translator: edpibu <git@edgarpierre.fr>\n"
"Language-Team: edpibu <git@edgarpierre.fr>\n" "Language-Team: edpibu <git@edgarpierre.fr>\n"
@ -17,90 +17,89 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: .\main\models.py:15 .\main\models.py:25 .\main\models.py:59 #: .\main\models.py:16 .\main\models.py:26 .\main\models.py:60
#: .\main\templates\main\base.html:44 #: .\main\templates\main\base.html:44
#: .\main\templates\main\tag\transaction_table.html:10 #: .\main\templates\main\tag\transaction_table.html:10
msgid "Category" msgid "Category"
msgstr "Catégorie" msgstr "Catégorie"
#: .\main\models.py:15 .\main\models.py:40 .\main\models.py:103 #: .\main\models.py:16 .\main\models.py:41 .\main\models.py:107
#: .\main\templates\main\tag\transaction_table.html:7 #: .\main\templates\main\tag\transaction_table.html:7
#: .\main\templates\main\transaction.html:33
msgid "Name" msgid "Name"
msgstr "Nom" msgstr "Nom"
#: .\main\models.py:17 #: .\main\models.py:18
msgid "Icon" msgid "Icon"
msgstr "Icône" msgstr "Icône"
#: .\main\models.py:18 #: .\main\models.py:19
msgid "Budget" msgid "Budget"
msgstr "Budget" msgstr "Budget"
#: .\main\models.py:26 .\main\templates\main\index.html:25 #: .\main\models.py:27 .\main\templates\main\index.html:25
#: .\main\templates\main\snapshot.html:37 #: .\main\templates\main\snapshot.html:37
msgid "Categories" msgid "Categories"
msgstr "Catégories" msgstr "Catégories"
#: .\main\models.py:40 .\main\models.py:75 .\main\templates\main\base.html:39 #: .\main\models.py:41 .\main\models.py:79 .\main\templates\main\base.html:39
msgid "Transaction" msgid "Transaction"
msgstr "Transaction" msgstr "Transaction"
#: .\main\models.py:42 .\main\templates\main\tag\transaction_table.html:11 #: .\main\models.py:43 .\main\templates\main\tag\transaction_table.html:11
msgid "Description" msgid "Description"
msgstr "Description" msgstr "Description"
#: .\main\models.py:44 .\main\models.py:142 .\main\templates\main\index.html:40 #: .\main\models.py:45 .\main\models.py:146 .\main\templates\main\index.html:40
#: .\main\templates\main\tag\transaction_table.html:8 #: .\main\templates\main\tag\transaction_table.html:8
msgid "Value" msgid "Value"
msgstr "Valeur" msgstr "Valeur"
#: .\main\models.py:46 .\main\models.py:140 .\main\templates\main\index.html:39 #: .\main\models.py:47 .\main\models.py:144 .\main\templates\main\index.html:39
#: .\main\templates\main\tag\transaction_table.html:6 #: .\main\templates\main\tag\transaction_table.html:6
msgid "Date" msgid "Date"
msgstr "Date" msgstr "Date"
#: .\main\models.py:47 #: .\main\models.py:48
msgid "Real date" msgid "Real date"
msgstr "Date réelle" msgstr "Date réelle"
#: .\main\models.py:49 .\main\templates\main\tag\transaction_table.html:9 #: .\main\models.py:50 .\main\templates\main\tag\transaction_table.html:9
msgid "Trader" msgid "Trader"
msgstr "Commerçant" msgstr "Commerçant"
#: .\main\models.py:52 #: .\main\models.py:53
msgid "Payment" msgid "Payment"
msgstr "Paiement" msgstr "Paiement"
#: .\main\models.py:76 .\main\templates\main\category.html:26 #: .\main\models.py:80 .\main\templates\main\category.html:26
#: .\main\templates\main\index.html:17 .\main\templates\main\index.html:42 #: .\main\templates\main\index.html:17 .\main\templates\main\index.html:42
#: .\main\templates\main\snapshot.html:78 #: .\main\templates\main\snapshot.html:78
#: .\main\templates\main\transactions.html:15 #: .\main\templates\main\transactions.html:15
msgid "Transactions" msgid "Transactions"
msgstr "Transactions" msgstr "Transactions"
#: .\main\models.py:103 .\main\models.py:121 #: .\main\models.py:107 .\main\models.py:125
msgid "Invoice" msgid "Invoice"
msgstr "Facture" msgstr "Facture"
#: .\main\models.py:108 .\main\models.py:153 #: .\main\models.py:112 .\main\models.py:157
msgid "File" msgid "File"
msgstr "Fichier" msgstr "Fichier"
#: .\main\models.py:122 .\main\templates\main\transaction.html:29 #: .\main\models.py:126
msgid "Invoices" msgid "Invoices"
msgstr "Factures" msgstr "Factures"
#: .\main\models.py:159 #: .\main\models.py:163
#, python-format #, python-format
msgid "%(date)s snapshot" msgid "%(date)s snapshot"
msgstr "Relevé du %(date)s" msgstr "Relevé du %(date)s"
#: .\main\models.py:261 .\main\templates\main\base.html:49 #: .\main\models.py:265 .\main\templates\main\base.html:49
msgid "Snapshot" msgid "Snapshot"
msgstr "Relevé" msgstr "Relevé"
#: .\main\models.py:262 .\main\templates\main\index.html:35 #: .\main\models.py:266 .\main\templates\main\index.html:35
msgid "Snapshots" msgid "Snapshots"
msgstr "Relevés" msgstr "Relevés"
@ -112,6 +111,19 @@ msgstr "Rechercher"
msgid "Log out" msgid "Log out"
msgstr "Se déconnecter" msgstr "Se déconnecter"
#: .\main\templates\main\confirm_delete.html:19
#, python-format
msgid "Are you sure you want do delete <%(object)s> ?"
msgstr "Êtes-vous sûr de vouloir supprimer <%(object)s> ?"
#: .\main\templates\main\confirm_delete.html:23
msgid "Cancel"
msgstr "Annuler"
#: .\main\templates\main\confirm_delete.html:24
msgid "Confirm"
msgstr "Confirmer"
#: .\main\templates\main\index.html:41 #: .\main\templates\main\index.html:41
msgid "Difference" msgid "Difference"
msgstr "Différence" msgstr "Différence"
@ -125,19 +137,15 @@ msgid "Log In"
msgstr "Se connecter" msgstr "Se connecter"
#: .\main\templates\main\tag\form_buttons.html:4 #: .\main\templates\main\tag\form_buttons.html:4
#: .\main\templates\main\transaction.html:42
#: .\main\templates\main\transaction.html:43
msgid "Delete" msgid "Delete"
msgstr "Supprimer" msgstr "Supprimer"
#: .\main\templates\main\tag\form_buttons.html:12 #: .\main\templates\main\tag\form_buttons.html:8
msgid "Save" msgid "Save"
msgstr "Enregistrer" msgstr "Enregistrer"
#: .\main\templates\main\transaction.html:51 #~ msgid "Add invoice"
msgid "Add invoice" #~ msgstr "Ajouter une facture"
msgstr "Ajouter une facture"
#: .\main\templates\main\transaction.html:59 #~ msgid "Add"
msgid "Add" #~ msgstr "Ajouter"
msgstr "Ajouter"

View file

@ -81,7 +81,8 @@ form > .buttons > *:hover {
form > .buttons input[type="submit"] { form > .buttons input[type="submit"] {
background: var(--green-1); background: var(--green-1);
} }
form > .buttons a.del { form > .buttons a.del,
form > .buttons input.del {
background: var(--red); background: var(--red);
color: var(--text-inv); color: var(--text-inv);
} }

View file

@ -0,0 +1,28 @@
{% extends "main/base.html" %}
{% load static %}
{% load main_extras %}
{% load i18n %}
{% block link %}
{{ block.super }}
<link rel="stylesheet"
href="{% static 'main/css/form.css' %}"
type="text/css"/>
<link rel="stylesheet"
href="{% static 'main/css/table.css' %}"
type="text/css"/>
{% endblock %}
{% block body %}
{% spaceless %}
<form method="post">
{% csrf_token %}
<p>
{% blocktranslate %}Are you sure you want do delete <{{ object }}> ?{% endblocktranslate %}
</p>
{{ form }}
<div class="buttons">
<a class="btn" href="{{ object.get_absolute_url }}">{% translate "Cancel" %}</a>
<input class="del" type="submit" value="{% translate "Confirm" %}" />
</div>
</form>
{% endspaceless %}
{% endblock %}

View file

@ -2,11 +2,7 @@
<div class="buttons"> <div class="buttons">
{% if not adding %} {% if not adding %}
{% translate "Delete" as del %} {% translate "Delete" as del %}
<a class="btn del" <a class="btn del" href="{% url del_url instance.id %}">{{ del }}</a>
onclick="return confirm('{{ del }} <{{ instance }}> ?')"
href="{% url del_url instance.id %}">
{{ del }}
</a>
{% endif %} {% endif %}
<input type="reset" /> <input type="reset" />
<input type="submit" value="{% translate 'Save' %}" /> <input type="submit" value="{% translate 'Save' %}" />

View file

@ -9,7 +9,11 @@ urlpatterns = [
path("transactions", views.TransactionListView.as_view(), name="transactions"), path("transactions", views.TransactionListView.as_view(), name="transactions"),
path("transaction", views.TransactionCreateView.as_view(), name="transaction"), path("transaction", views.TransactionCreateView.as_view(), name="transaction"),
path("transaction/<pk>", views.TransactionUpdateView.as_view(), name="transaction"), path("transaction/<pk>", views.TransactionUpdateView.as_view(), name="transaction"),
path("transaction/<uuid>/del", views.del_transaction, name="del_transaction"), path(
"transaction/delete/<pk>",
views.TransactionDeleteView.as_view(),
name="del_transaction",
),
path("del_invoice/<uuid>/<invoice_id>", views.del_invoice, name="del_invoice"), path("del_invoice/<uuid>/<invoice_id>", views.del_invoice, name="del_invoice"),
path("invoice/<uuid>", views.invoice, name="invoice"), path("invoice/<uuid>", views.invoice, name="invoice"),
path("category", views.category, name="category"), path("category", views.category, name="category"),

View file

@ -11,7 +11,8 @@ from django.core.paginator import Paginator
from django.db import models from django.db import models
from django.http import HttpResponse from django.http import HttpResponse
from django.shortcuts import get_object_or_404, redirect, render from django.shortcuts import get_object_or_404, redirect, render
from django.views.generic import CreateView, ListView, UpdateView from django.urls import reverse_lazy
from django.views.generic import CreateView, DeleteView, ListView, UpdateView
from .models import ( from .models import (
Category, Category,
@ -65,11 +66,10 @@ class TransactionUpdateView(LoginRequiredMixin, UpdateView):
form_class = TransactionForm form_class = TransactionForm
@login_required class TransactionDeleteView(LoginRequiredMixin, DeleteView):
def del_transaction(request, uuid): model = Transaction
_transaction = get_object_or_404(Transaction, id=uuid) template_name = "main/confirm_delete.html"
_transaction.delete() success_url = reverse_lazy("index")
return redirect(index)
@login_required @login_required