Compare commits

..

No commits in common. "d8c95fac253a321e835e9bb6cee935f17e814920" and "757ce1f45f147c2c5d9d07ad46e3829526339774" have entirely different histories.

8 changed files with 82 additions and 84 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-28 10:16+0100\n" "POT-Creation-Date: 2022-12-26 18:10+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,89 +17,90 @@ 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:16 .\main\models.py:26 .\main\models.py:60 #: .\main\models.py:15 .\main\models.py:25 .\main\models.py:59
#: .\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:16 .\main\models.py:41 .\main\models.py:107 #: .\main\models.py:15 .\main\models.py:40 .\main\models.py:103
#: .\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:18 #: .\main\models.py:17
msgid "Icon" msgid "Icon"
msgstr "Icône" msgstr "Icône"
#: .\main\models.py:19 #: .\main\models.py:18
msgid "Budget" msgid "Budget"
msgstr "Budget" msgstr "Budget"
#: .\main\models.py:27 .\main\templates\main\index.html:25 #: .\main\models.py:26 .\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:41 .\main\models.py:79 .\main\templates\main\base.html:39 #: .\main\models.py:40 .\main\models.py:75 .\main\templates\main\base.html:39
msgid "Transaction" msgid "Transaction"
msgstr "Transaction" msgstr "Transaction"
#: .\main\models.py:43 .\main\templates\main\tag\transaction_table.html:11 #: .\main\models.py:42 .\main\templates\main\tag\transaction_table.html:11
msgid "Description" msgid "Description"
msgstr "Description" msgstr "Description"
#: .\main\models.py:45 .\main\models.py:146 .\main\templates\main\index.html:40 #: .\main\models.py:44 .\main\models.py:142 .\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:47 .\main\models.py:144 .\main\templates\main\index.html:39 #: .\main\models.py:46 .\main\models.py:140 .\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:48 #: .\main\models.py:47
msgid "Real date" msgid "Real date"
msgstr "Date réelle" msgstr "Date réelle"
#: .\main\models.py:50 .\main\templates\main\tag\transaction_table.html:9 #: .\main\models.py:49 .\main\templates\main\tag\transaction_table.html:9
msgid "Trader" msgid "Trader"
msgstr "Commerçant" msgstr "Commerçant"
#: .\main\models.py:53 #: .\main\models.py:52
msgid "Payment" msgid "Payment"
msgstr "Paiement" msgstr "Paiement"
#: .\main\models.py:80 .\main\templates\main\category.html:26 #: .\main\models.py:76 .\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:107 .\main\models.py:125 #: .\main\models.py:103 .\main\models.py:121
msgid "Invoice" msgid "Invoice"
msgstr "Facture" msgstr "Facture"
#: .\main\models.py:112 .\main\models.py:157 #: .\main\models.py:108 .\main\models.py:153
msgid "File" msgid "File"
msgstr "Fichier" msgstr "Fichier"
#: .\main\models.py:126 #: .\main\models.py:122 .\main\templates\main\transaction.html:29
msgid "Invoices" msgid "Invoices"
msgstr "Factures" msgstr "Factures"
#: .\main\models.py:163 #: .\main\models.py:159
#, 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:265 .\main\templates\main\base.html:49 #: .\main\models.py:261 .\main\templates\main\base.html:49
msgid "Snapshot" msgid "Snapshot"
msgstr "Relevé" msgstr "Relevé"
#: .\main\models.py:266 .\main\templates\main\index.html:35 #: .\main\models.py:262 .\main\templates\main\index.html:35
msgid "Snapshots" msgid "Snapshots"
msgstr "Relevés" msgstr "Relevés"
@ -111,19 +112,6 @@ 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"
@ -137,15 +125,19 @@ 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:8 #: .\main\templates\main\tag\form_buttons.html:12
msgid "Save" msgid "Save"
msgstr "Enregistrer" msgstr "Enregistrer"
#~ msgid "Add invoice" #: .\main\templates\main\transaction.html:51
#~ msgstr "Ajouter une facture" msgid "Add invoice"
msgstr "Ajouter une facture"
#~ msgid "Add" #: .\main\templates\main\transaction.html:59
#~ msgstr "Ajouter" msgid "Add"
msgstr "Ajouter"

View file

@ -16,12 +16,10 @@ form ul.errorlist {
form input, form input,
form select, form select,
form textarea,
form a { form a {
padding: 0 var(--gap); padding: 0 var(--gap);
} }
form textarea {
padding: var(--gap);
}
form input { form input {
color: inherit; color: inherit;
@ -81,8 +79,7 @@ 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

@ -49,7 +49,7 @@
{% translate "Snapshot" %} {% translate "Snapshot" %}
</a> </a>
<form id="search" action="{% url 'search_post' %}" method="post"> <form id="search" action="{% url 'search_post' %}" method="post">
{% csrf_token %} {% csrf_token %}
<input type="text" <input type="text"
name="search" name="search"
placeholder="{% translate "Search" %}" placeholder="{% translate "Search" %}"

View file

@ -1,28 +0,0 @@
{% 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,7 +2,11 @@
<div class="buttons"> <div class="buttons">
{% if not adding %} {% if not adding %}
{% translate "Delete" as del %} {% translate "Delete" as del %}
<a class="btn del" href="{% url del_url instance.id %}">{{ del }}</a> <a class="btn del"
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,11 +9,7 @@ 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( path("transaction/<uuid>/del", views.del_transaction, name="del_transaction"),
"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,8 +11,7 @@ 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.urls import reverse_lazy from django.views.generic import CreateView, ListView, UpdateView
from django.views.generic import CreateView, DeleteView, ListView, UpdateView
from .models import ( from .models import (
Category, Category,
@ -56,6 +55,43 @@ class TransactionListView(LoginRequiredMixin, ListView):
context_object_name = "transactions" context_object_name = "transactions"
@login_required
def transaction(request, uuid=None):
_form = None
_inv_form = None
if request.method == "GET":
if uuid is None:
_transaction = Transaction()
else:
_transaction = get_object_or_404(Transaction, id=uuid)
elif request.method == "POST":
if request.POST["form"] == "transaction":
_transaction, _ = Transaction.objects.get_or_create(id=uuid)
_form = TransactionForm(request.POST, instance=_transaction)
if _form.is_valid():
_form.save()
return redirect(transaction, uuid=uuid)
_inv_form = InvoiceForm(instance=Invoice(transaction=_transaction))
elif request.POST["form"] == "invoice":
_transaction = get_object_or_404(Transaction, id=uuid)
_invoice = Invoice(transaction=_transaction)
_inv_form = InvoiceForm(request.POST, request.FILES, instance=_invoice)
if _inv_form.is_valid():
_inv_form.save()
return redirect(transaction, uuid=uuid)
return render(
request,
"main/transaction.html",
{
"transaction": _transaction,
"form": _form or TransactionForm(instance=_transaction),
"invoice_form": _inv_form
or InvoiceForm(instance=Invoice(transaction=_transaction)),
},
)
class TransactionCreateView(LoginRequiredMixin, CreateView): class TransactionCreateView(LoginRequiredMixin, CreateView):
model = Transaction model = Transaction
form_class = TransactionForm form_class = TransactionForm
@ -66,10 +102,11 @@ class TransactionUpdateView(LoginRequiredMixin, UpdateView):
form_class = TransactionForm form_class = TransactionForm
class TransactionDeleteView(LoginRequiredMixin, DeleteView): @login_required
model = Transaction def del_transaction(request, uuid):
template_name = "main/confirm_delete.html" _transaction = get_object_or_404(Transaction, id=uuid)
success_url = reverse_lazy("index") _transaction.delete()
return redirect(index)
@login_required @login_required