Show title as New on forms

This commit is contained in:
Edgar P. Burkhart 2023-04-20 11:28:06 +02:00
parent 9263af0d40
commit 110a699f1a
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
9 changed files with 71 additions and 45 deletions

View file

@ -10,7 +10,7 @@ class NummiFileInput(forms.ClearableFileInput):
class NummiForm(forms.ModelForm): class NummiForm(forms.ModelForm):
template_name = "main/form/base.html" template_name = "main/form/form_base.html"
def __init__(self, *args, user, **kwargs): def __init__(self, *args, user, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)

View file

@ -16,19 +16,25 @@
type="text/css" /> type="text/css" />
{% endblock %} {% endblock %}
{% block body %} {% block body %}
<h1>{{ form.instance.icon|remix }}{{ form.instance }}</h1> {% with account=form.instance %}
<form method="post"> {% if account.adding %}
{% csrf_token %} <h1>{% translate "New account" %}</h1>
{{ form }} {% else %}
</form> <h1>{{ account.icon|remix }}{{ account }}</h1>
{% if not form.instance.adding %} {% endif %}
<h2>{% translate "Statements" %}</h2> <form method="post">
{% include "main/table/snapshot.html" %} {% csrf_token %}
{% endif %} {{ form }}
{% if transactions %} </form>
<h2>{% translate "Transactions" %}</h2> {% if not account.adding %}
{% include "main/table/transaction.html" %} <h2>{% translate "Statements" %}</h2>
<h2>{% translate "History" %}</h2> {% include "main/table/snapshot.html" %}
{% include "main/plot/history.html" %} {% endif %}
{% endif %} {% if transactions %}
<h2>{% translate "Transactions" %}</h2>
{% include "main/table/transaction.html" %}
<h2>{% translate "History" %}</h2>
{% include "main/plot/history.html" %}
{% endif %}
{% endwith %}
{% endblock %} {% endblock %}

View file

@ -16,15 +16,21 @@
type="text/css" /> type="text/css" />
{% endblock %} {% endblock %}
{% block body %} {% block body %}
<h1>{{ form.instance.icon|remix }}{{ form.instance }}</h1> {% with category=form.instance %}
<form method="post"> {% if category.adding %}
{% csrf_token %} <h1>{% translate "New category" %}</h1>
{{ form }} {% else %}
</form> <h1>{{ category.icon|remix }}{{ category }}</h1>
{% if form.instance.transactions %} {% endif %}
<h2>{% translate "Transactions" %}</h2> <form method="post">
{% include "main/table/transaction.html" %} {% csrf_token %}
<h2>{% translate "History" %}</h2> {{ form }}
{% include "main/plot/history.html" %} </form>
{% endif %} {% if category.transactions %}
<h2>{% translate "Transactions" %}</h2>
{% include "main/table/transaction.html" %}
<h2>{% translate "History" %}</h2>
{% include "main/plot/history.html" %}
{% endif %}
{% endwith %}
{% endblock %} {% endblock %}

View file

@ -14,7 +14,11 @@
{% endblock %} {% endblock %}
{% block body %} {% block body %}
{% with invoice=form.instance %} {% with invoice=form.instance %}
<h1>{{ invoice }}</h1> {% if invoice.adding %}
<h1>{% translate "New invoice" %}</h1>
{% else %}
<h1>{{ invoice }}</h1>
{% endif %}
<p> <p>
<a href="{{ invoice.transaction.get_absolute_url }}">{{ invoice.transaction }}</a> <a href="{{ invoice.transaction.get_absolute_url }}">{{ invoice.transaction }}</a>
</p> </p>

View file

@ -1,4 +1,4 @@
{% extends "main/form/base.html" %} {% extends "main/form/form_base.html" %}
{% load i18n %} {% load i18n %}
{% block buttons %} {% block buttons %}
<input hidden value="{{ next }}" name="next" /> <input hidden value="{{ next }}" name="next" />

View file

@ -1,4 +1,4 @@
{% extends "main/form/base.html" %} {% extends "main/form/form_base.html" %}
{% load i18n %} {% load i18n %}
{% block buttons %} {% block buttons %}
<input type="reset" /> <input type="reset" />

View file

@ -17,10 +17,14 @@
{% endblock %} {% endblock %}
{% block body %} {% block body %}
{% with snapshot=form.instance %} {% with snapshot=form.instance %}
<h1> {% if snapshot.adding %}
<span class="ri-{% if snapshot.sum == snapshot.diff %}check-line green{% else %}close-line red{% endif %}"></span> <h1>{% translate "New snapshot" %}</h1>
{{ snapshot }} {% else %}
</h1> <h1>
<span class="ri-{% if snapshot.sum == snapshot.diff %}check-line green{% else %}close-line red{% endif %}"></span>
{{ snapshot }}
</h1>
{% endif %}
<form method="post" enctype="multipart/form-data"> <form method="post" enctype="multipart/form-data">
{% csrf_token %} {% csrf_token %}
{{ form }} {{ form }}

View file

@ -13,15 +13,21 @@
type="text/css" /> type="text/css" />
{% endblock %} {% endblock %}
{% block body %} {% block body %}
<h1>{{ form.instance }}</h1> {% with transaction=form.instance %}
{% spaceless %} {% if transaction.adding %}
<form id="transaction" method="post"> <h1>{% translate "New transaction" %}</h1>
{% csrf_token %} {% else %}
{{ form }} <h1>{{ form.instance }}</h1>
</form> {% endif %}
{% endspaceless %} {% spaceless %}
{% if not form.instance.adding %} <form id="transaction" method="post">
<h2>{% translate "Invoices" %}</h2> {% csrf_token %}
{% include "main/table/invoice.html" %} {{ form }}
{% endif %} </form>
{% endspaceless %}
{% if not form.instance.adding %}
<h2>{% translate "Invoices" %}</h2>
{% include "main/table/invoice.html" %}
{% endif %}
{% endwith %}
{% endblock %} {% endblock %}