From d8c95fac253a321e835e9bb6cee935f17e814920 Mon Sep 17 00:00:00 2001 From: "Edgar P. Burkhart" Date: Wed, 28 Dec 2022 10:17:30 +0100 Subject: [PATCH] Added delete view for transaction --- nummi/main/locale/fr/LC_MESSAGES/django.mo | Bin 1509 -> 1613 bytes nummi/main/locale/fr/LC_MESSAGES/django.po | 68 ++++++++++-------- nummi/main/static/main/css/form.css | 3 +- nummi/main/templates/main/confirm_delete.html | 28 ++++++++ .../main/templates/main/tag/form_buttons.html | 6 +- nummi/main/urls.py | 6 +- nummi/main/views.py | 12 ++-- 7 files changed, 80 insertions(+), 43 deletions(-) create mode 100644 nummi/main/templates/main/confirm_delete.html diff --git a/nummi/main/locale/fr/LC_MESSAGES/django.mo b/nummi/main/locale/fr/LC_MESSAGES/django.mo index 66f405c201d280d164628ab32f0f2cbec6b162e5..f7f01a9a6e6c96fa41d6faede95d5e45e1c3b0ed 100644 GIT binary patch delta 880 zcmZ|NKWG#|6vy%BnKQ;aH5dORMh%N-Fogs+Yzj9}?M1l~!DsYUT)?U-a_}7l~2C7asQ5z-p z69+V)O{_dAjNbGvY9)D;=AmXr0K-ut}oz3)BG``+EX`w}fyV$Pu<259{>CuGbpzM*12Y)l6p zU<6Mwif34lm)ML~*oe32;DeoiLai^O*1g*K&p(Uin@$50Kd1x|swlCGy5EUPn6%>* zHZdNu_eW6c$578t+W9$qe*v|DC3MllI^3#SG-ij+6sO(APA0CYroxY?aT!(M9hK+{ zb&?QS=o%Nbp$^o1(mIIBGm3hC!j5N98=Xg&`eu<%8!jVzFq?KkpaqO~QHl3Zg^y5) zPf&@@?fixH8ui>As_?V5g8Hg0v=~jfihW#?wA$!mz}KjT-heix|D%\n" "Language-Team: edpibu \n" @@ -17,90 +17,89 @@ msgstr "" "Content-Transfer-Encoding: 8bit\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\tag\transaction_table.html:10 msgid "Category" 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\transaction.html:33 msgid "Name" msgstr "Nom" -#: .\main\models.py:17 +#: .\main\models.py:18 msgid "Icon" msgstr "Icône" -#: .\main\models.py:18 +#: .\main\models.py:19 msgid "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 msgid "Categories" 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" 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" 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 msgid "Value" 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 msgid "Date" msgstr "Date" -#: .\main\models.py:47 +#: .\main\models.py:48 msgid "Real date" 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" msgstr "Commerçant" -#: .\main\models.py:52 +#: .\main\models.py:53 msgid "Payment" 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\snapshot.html:78 #: .\main\templates\main\transactions.html:15 msgid "Transactions" msgstr "Transactions" -#: .\main\models.py:103 .\main\models.py:121 +#: .\main\models.py:107 .\main\models.py:125 msgid "Invoice" msgstr "Facture" -#: .\main\models.py:108 .\main\models.py:153 +#: .\main\models.py:112 .\main\models.py:157 msgid "File" msgstr "Fichier" -#: .\main\models.py:122 .\main\templates\main\transaction.html:29 +#: .\main\models.py:126 msgid "Invoices" msgstr "Factures" -#: .\main\models.py:159 +#: .\main\models.py:163 #, python-format msgid "%(date)s snapshot" 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" msgstr "Relevé" -#: .\main\models.py:262 .\main\templates\main\index.html:35 +#: .\main\models.py:266 .\main\templates\main\index.html:35 msgid "Snapshots" msgstr "Relevés" @@ -112,6 +111,19 @@ msgstr "Rechercher" msgid "Log out" 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 msgid "Difference" msgstr "Différence" @@ -125,19 +137,15 @@ msgid "Log In" msgstr "Se connecter" #: .\main\templates\main\tag\form_buttons.html:4 -#: .\main\templates\main\transaction.html:42 -#: .\main\templates\main\transaction.html:43 msgid "Delete" msgstr "Supprimer" -#: .\main\templates\main\tag\form_buttons.html:12 +#: .\main\templates\main\tag\form_buttons.html:8 msgid "Save" msgstr "Enregistrer" -#: .\main\templates\main\transaction.html:51 -msgid "Add invoice" -msgstr "Ajouter une facture" +#~ msgid "Add invoice" +#~ msgstr "Ajouter une facture" -#: .\main\templates\main\transaction.html:59 -msgid "Add" -msgstr "Ajouter" +#~ msgid "Add" +#~ msgstr "Ajouter" diff --git a/nummi/main/static/main/css/form.css b/nummi/main/static/main/css/form.css index e6c56a0..dff01e4 100644 --- a/nummi/main/static/main/css/form.css +++ b/nummi/main/static/main/css/form.css @@ -81,7 +81,8 @@ form > .buttons > *:hover { form > .buttons input[type="submit"] { background: var(--green-1); } -form > .buttons a.del { +form > .buttons a.del, +form > .buttons input.del { background: var(--red); color: var(--text-inv); } diff --git a/nummi/main/templates/main/confirm_delete.html b/nummi/main/templates/main/confirm_delete.html new file mode 100644 index 0000000..0a5083e --- /dev/null +++ b/nummi/main/templates/main/confirm_delete.html @@ -0,0 +1,28 @@ +{% extends "main/base.html" %} +{% load static %} +{% load main_extras %} +{% load i18n %} +{% block link %} + {{ block.super }} + + +{% endblock %} +{% block body %} + {% spaceless %} +
+ {% csrf_token %} +

+ {% blocktranslate %}Are you sure you want do delete <{{ object }}> ?{% endblocktranslate %} +

+ {{ form }} + +
+ {% endspaceless %} +{% endblock %} diff --git a/nummi/main/templates/main/tag/form_buttons.html b/nummi/main/templates/main/tag/form_buttons.html index 54c39db..707ece3 100644 --- a/nummi/main/templates/main/tag/form_buttons.html +++ b/nummi/main/templates/main/tag/form_buttons.html @@ -2,11 +2,7 @@
{% if not adding %} {% translate "Delete" as del %} - - {{ del }} - + {{ del }} {% endif %} diff --git a/nummi/main/urls.py b/nummi/main/urls.py index bd15b5a..ae9ae5d 100644 --- a/nummi/main/urls.py +++ b/nummi/main/urls.py @@ -9,7 +9,11 @@ urlpatterns = [ path("transactions", views.TransactionListView.as_view(), name="transactions"), path("transaction", views.TransactionCreateView.as_view(), name="transaction"), path("transaction/", views.TransactionUpdateView.as_view(), name="transaction"), - path("transaction//del", views.del_transaction, name="del_transaction"), + path( + "transaction/delete/", + views.TransactionDeleteView.as_view(), + name="del_transaction", + ), path("del_invoice//", views.del_invoice, name="del_invoice"), path("invoice/", views.invoice, name="invoice"), path("category", views.category, name="category"), diff --git a/nummi/main/views.py b/nummi/main/views.py index f41a05f..f82ac16 100644 --- a/nummi/main/views.py +++ b/nummi/main/views.py @@ -11,7 +11,8 @@ from django.core.paginator import Paginator from django.db import models from django.http import HttpResponse 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 ( Category, @@ -65,11 +66,10 @@ class TransactionUpdateView(LoginRequiredMixin, UpdateView): form_class = TransactionForm -@login_required -def del_transaction(request, uuid): - _transaction = get_object_or_404(Transaction, id=uuid) - _transaction.delete() - return redirect(index) +class TransactionDeleteView(LoginRequiredMixin, DeleteView): + model = Transaction + template_name = "main/confirm_delete.html" + success_url = reverse_lazy("index") @login_required