From 110a699f1ab4cb0843990df377c2e8c527aaf683 Mon Sep 17 00:00:00 2001 From: "Edgar P. Burkhart" Date: Thu, 20 Apr 2023 11:28:06 +0200 Subject: [PATCH] Show title as New on forms --- nummi/main/forms.py | 2 +- nummi/main/templates/main/form/account.html | 36 +++++++++++-------- nummi/main/templates/main/form/category.html | 28 +++++++++------ .../main/form/{base.html => form_base.html} | 0 nummi/main/templates/main/form/invoice.html | 6 +++- nummi/main/templates/main/form/login.html | 2 +- nummi/main/templates/main/form/search.html | 2 +- nummi/main/templates/main/form/snapshot.html | 12 ++++--- .../main/templates/main/form/transaction.html | 28 +++++++++------ 9 files changed, 71 insertions(+), 45 deletions(-) rename nummi/main/templates/main/form/{base.html => form_base.html} (100%) diff --git a/nummi/main/forms.py b/nummi/main/forms.py index d1e5de1..aff90df 100644 --- a/nummi/main/forms.py +++ b/nummi/main/forms.py @@ -10,7 +10,7 @@ class NummiFileInput(forms.ClearableFileInput): class NummiForm(forms.ModelForm): - template_name = "main/form/base.html" + template_name = "main/form/form_base.html" def __init__(self, *args, user, **kwargs): super().__init__(*args, **kwargs) diff --git a/nummi/main/templates/main/form/account.html b/nummi/main/templates/main/form/account.html index f14da2d..f6c8f7c 100644 --- a/nummi/main/templates/main/form/account.html +++ b/nummi/main/templates/main/form/account.html @@ -16,19 +16,25 @@ type="text/css" /> {% endblock %} {% block body %} -

{{ form.instance.icon|remix }}{{ form.instance }}

-
- {% csrf_token %} - {{ form }} -
- {% if not form.instance.adding %} -

{% translate "Statements" %}

- {% include "main/table/snapshot.html" %} - {% endif %} - {% if transactions %} -

{% translate "Transactions" %}

- {% include "main/table/transaction.html" %} -

{% translate "History" %}

- {% include "main/plot/history.html" %} - {% endif %} + {% with account=form.instance %} + {% if account.adding %} +

{% translate "New account" %}

+ {% else %} +

{{ account.icon|remix }}{{ account }}

+ {% endif %} +
+ {% csrf_token %} + {{ form }} +
+ {% if not account.adding %} +

{% translate "Statements" %}

+ {% include "main/table/snapshot.html" %} + {% endif %} + {% if transactions %} +

{% translate "Transactions" %}

+ {% include "main/table/transaction.html" %} +

{% translate "History" %}

+ {% include "main/plot/history.html" %} + {% endif %} + {% endwith %} {% endblock %} diff --git a/nummi/main/templates/main/form/category.html b/nummi/main/templates/main/form/category.html index 27ae5e9..c5dd794 100644 --- a/nummi/main/templates/main/form/category.html +++ b/nummi/main/templates/main/form/category.html @@ -16,15 +16,21 @@ type="text/css" /> {% endblock %} {% block body %} -

{{ form.instance.icon|remix }}{{ form.instance }}

-
- {% csrf_token %} - {{ form }} -
- {% if form.instance.transactions %} -

{% translate "Transactions" %}

- {% include "main/table/transaction.html" %} -

{% translate "History" %}

- {% include "main/plot/history.html" %} - {% endif %} + {% with category=form.instance %} + {% if category.adding %} +

{% translate "New category" %}

+ {% else %} +

{{ category.icon|remix }}{{ category }}

+ {% endif %} +
+ {% csrf_token %} + {{ form }} +
+ {% if category.transactions %} +

{% translate "Transactions" %}

+ {% include "main/table/transaction.html" %} +

{% translate "History" %}

+ {% include "main/plot/history.html" %} + {% endif %} + {% endwith %} {% endblock %} diff --git a/nummi/main/templates/main/form/base.html b/nummi/main/templates/main/form/form_base.html similarity index 100% rename from nummi/main/templates/main/form/base.html rename to nummi/main/templates/main/form/form_base.html diff --git a/nummi/main/templates/main/form/invoice.html b/nummi/main/templates/main/form/invoice.html index 26c9dd1..95afb16 100644 --- a/nummi/main/templates/main/form/invoice.html +++ b/nummi/main/templates/main/form/invoice.html @@ -14,7 +14,11 @@ {% endblock %} {% block body %} {% with invoice=form.instance %} -

{{ invoice }}

+ {% if invoice.adding %} +

{% translate "New invoice" %}

+ {% else %} +

{{ invoice }}

+ {% endif %}

{{ invoice.transaction }}

diff --git a/nummi/main/templates/main/form/login.html b/nummi/main/templates/main/form/login.html index 841e941..8a74bc7 100644 --- a/nummi/main/templates/main/form/login.html +++ b/nummi/main/templates/main/form/login.html @@ -1,4 +1,4 @@ -{% extends "main/form/base.html" %} +{% extends "main/form/form_base.html" %} {% load i18n %} {% block buttons %} diff --git a/nummi/main/templates/main/form/search.html b/nummi/main/templates/main/form/search.html index 58d3a2f..af7b012 100644 --- a/nummi/main/templates/main/form/search.html +++ b/nummi/main/templates/main/form/search.html @@ -1,4 +1,4 @@ -{% extends "main/form/base.html" %} +{% extends "main/form/form_base.html" %} {% load i18n %} {% block buttons %} diff --git a/nummi/main/templates/main/form/snapshot.html b/nummi/main/templates/main/form/snapshot.html index 78ebae8..54c7c18 100644 --- a/nummi/main/templates/main/form/snapshot.html +++ b/nummi/main/templates/main/form/snapshot.html @@ -17,10 +17,14 @@ {% endblock %} {% block body %} {% with snapshot=form.instance %} -

- - {{ snapshot }} -

+ {% if snapshot.adding %} +

{% translate "New snapshot" %}

+ {% else %} +

+ + {{ snapshot }} +

+ {% endif %}
{% csrf_token %} {{ form }} diff --git a/nummi/main/templates/main/form/transaction.html b/nummi/main/templates/main/form/transaction.html index 9813d40..c70a855 100644 --- a/nummi/main/templates/main/form/transaction.html +++ b/nummi/main/templates/main/form/transaction.html @@ -13,15 +13,21 @@ type="text/css" /> {% endblock %} {% block body %} -

{{ form.instance }}

- {% spaceless %} - - {% csrf_token %} - {{ form }} -
- {% endspaceless %} - {% if not form.instance.adding %} -

{% translate "Invoices" %}

- {% include "main/table/invoice.html" %} - {% endif %} + {% with transaction=form.instance %} + {% if transaction.adding %} +

{% translate "New transaction" %}

+ {% else %} +

{{ form.instance }}

+ {% endif %} + {% spaceless %} +
+ {% csrf_token %} + {{ form }} +
+ {% endspaceless %} + {% if not form.instance.adding %} +

{% translate "Invoices" %}

+ {% include "main/table/invoice.html" %} + {% endif %} + {% endwith %} {% endblock %}